X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/a5cb4cf37e5dfa9bb9ce5c5e4ccf8d5978d3576f..a500fb72810060e52d87ad2c2e4691531f0bcc5a:/projects/stargazer/actions.inl.h diff --git a/projects/stargazer/actions.inl.h b/projects/stargazer/actions.inl.h index 1b713f1d..7a0bac35 100644 --- a/projects/stargazer/actions.inl.h +++ b/projects/stargazer/actions.inl.h @@ -15,75 +15,66 @@ void ACTION::Invoke() inline ACTIONS_LIST::ACTIONS_LIST() - : mutex() { -pthread_mutex_init(&mutex, NULL); } // Delete all actions before deleting list inline ACTIONS_LIST::~ACTIONS_LIST() { +std::lock_guard lock(m_mutex); - { - STG_LOCKER lock(&mutex); - - parent::iterator it(parent::begin()); - while (it != parent::end()) - { - delete *it++; - } - } - -pthread_mutex_destroy(&mutex); +parent::iterator it(parent::begin()); +while (it != parent::end()) + delete *it++; } inline ACTIONS_LIST::parent::iterator ACTIONS_LIST::begin() { -STG_LOCKER lock(&mutex); +std::lock_guard lock(m_mutex); return parent::begin(); } inline ACTIONS_LIST::parent::iterator ACTIONS_LIST::end() { -STG_LOCKER lock(&mutex); +std::lock_guard lock(m_mutex); return parent::end(); } inline ACTIONS_LIST::parent::const_iterator ACTIONS_LIST::begin() const { -STG_LOCKER lock(&mutex); +std::lock_guard lock(m_mutex); return parent::begin(); } inline ACTIONS_LIST::parent::const_iterator ACTIONS_LIST::end() const { -STG_LOCKER lock(&mutex); +std::lock_guard lock(m_mutex); return parent::end(); } inline bool ACTIONS_LIST::empty() const { -STG_LOCKER lock(&mutex); +std::lock_guard lock(m_mutex); return parent::empty(); } inline size_t ACTIONS_LIST::size() const { -STG_LOCKER lock(&mutex); +std::lock_guard lock(m_mutex); return parent::size(); } inline void ACTIONS_LIST::swap(ACTIONS_LIST & list) { -STG_LOCKER lock(&mutex); +std::lock_guard lock(m_mutex); parent::swap(list); } @@ -93,14 +84,14 @@ void ACTIONS_LIST::Enqueue(ACTIVE_CLASS & ac, typename ACTOR::TYPE a, DATA_TYPE d) { -STG_LOCKER lock(&mutex); +std::lock_guard lock(m_mutex); push_back(new ACTION(ac, a, d)); } inline void ACTIONS_LIST::InvokeAll() { -STG_LOCKER lock(&mutex); +std::lock_guard lock(m_mutex); std::for_each( parent::begin(), parent::end(),