6 // ACTIONS_LIST actionsList;
 
  11 // actionsList.Enqueue(myClass, &CLASS::myMethod1, myData1);
 
  12 // actionsList.Enqueue(myClass, &CLASS::myMethod2, myData2);
 
  14 // actionsList.InvokeAll();
 
  20 // Generalized actor type - a method of some class with one argument
 
  21 template <class ACTIVE_CLASS, typename DATA_TYPE>
 
  24 typedef void (ACTIVE_CLASS::*TYPE)(DATA_TYPE);
 
  27 // Abstract base action class for polymorphic action invocation
 
  31     virtual ~BASE_ACTION() {};
 
  32     virtual void Invoke() = 0;
 
  35 // Concrete generalized action type - an actor with it's data and owner
 
  36 template <class ACTIVE_CLASS, typename DATA_TYPE>
 
  37 class ACTION : public BASE_ACTION,
 
  38                public std::unary_function<ACTIVE_CLASS &, void>
 
  41     ACTION(ACTIVE_CLASS & ac,
 
  42            typename ACTOR<ACTIVE_CLASS, DATA_TYPE>::TYPE a,
 
  44         : activeClass(ac), actor(a), data(d) {};
 
  47     ACTIVE_CLASS & activeClass;
 
  48     typename ACTOR<ACTIVE_CLASS, DATA_TYPE>::TYPE actor;
 
  52 // A list of an actions
 
  53 // All methods are thread-safe
 
  54 class ACTIONS_LIST : private std::list<BASE_ACTION *>
 
  57     // Just a typedef for parent class
 
  58     typedef std::list<BASE_ACTION *> parent;
 
  62     // Delete actions and destroy mutex
 
  65     parent::iterator begin();
 
  66     parent::iterator end();
 
  67     parent::const_iterator begin() const;
 
  68     parent::const_iterator end() const;
 
  72     void swap(ACTIONS_LIST & list);
 
  74     // Add an action to list
 
  75     template <class ACTIVE_CLASS, typename DATA_TYPE>
 
  76     void Enqueue(ACTIVE_CLASS & ac,
 
  77                  typename ACTOR<ACTIVE_CLASS, DATA_TYPE>::TYPE a,
 
  79     // Invoke all actions in the list
 
  82     mutable pthread_mutex_t mutex;
 
  85 #include "actions.inl.h"