1 #ifndef __ACTIONS_INL_H__
2 #define __ACTIONS_INL_H__
6 #include "stg/locker.h"
8 // Polymorphick action invocation
9 template <class ACTIVE_CLASS, typename DATA_TYPE>
11 void ACTION<ACTIVE_CLASS, DATA_TYPE>::Invoke()
13 (activeClass.*actor)(data);
17 ACTIONS_LIST::ACTIONS_LIST()
21 // Delete all actions before deleting list
23 ACTIONS_LIST::~ACTIONS_LIST()
25 std::lock_guard lock(m_mutex);
27 parent::iterator it(parent::begin());
28 while (it != parent::end())
33 ACTIONS_LIST::parent::iterator ACTIONS_LIST::begin()
35 std::lock_guard lock(m_mutex);
36 return parent::begin();
40 ACTIONS_LIST::parent::iterator ACTIONS_LIST::end()
42 std::lock_guard lock(m_mutex);
47 ACTIONS_LIST::parent::const_iterator ACTIONS_LIST::begin() const
49 std::lock_guard lock(m_mutex);
50 return parent::begin();
54 ACTIONS_LIST::parent::const_iterator ACTIONS_LIST::end() const
56 std::lock_guard lock(m_mutex);
61 bool ACTIONS_LIST::empty() const
63 std::lock_guard lock(m_mutex);
64 return parent::empty();
68 size_t ACTIONS_LIST::size() const
70 std::lock_guard lock(m_mutex);
71 return parent::size();
75 void ACTIONS_LIST::swap(ACTIONS_LIST & list)
77 std::lock_guard lock(m_mutex);
81 template <class ACTIVE_CLASS, typename DATA_TYPE>
83 void ACTIONS_LIST::Enqueue(ACTIVE_CLASS & ac,
84 typename ACTOR<ACTIVE_CLASS, DATA_TYPE>::TYPE a,
87 std::lock_guard lock(m_mutex);
88 push_back(new ACTION<ACTIVE_CLASS, DATA_TYPE>(ac, a, d));
92 void ACTIONS_LIST::InvokeAll()
94 std::lock_guard lock(m_mutex);
98 [](auto action){ action->Invoke(); });