X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/4271ab433cd55bbd2612292bcf39e4dc3d7274f1..0907aa4037b12b6b88ee24495d4577a064d4f8db:/stargazer/actions.inl.h diff --git a/stargazer/actions.inl.h b/stargazer/actions.inl.h deleted file mode 100644 index 1b713f1d..00000000 --- a/stargazer/actions.inl.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef __ACTIONS_INL_H__ -#define __ACTIONS_INL_H__ - -#include - -#include "stg/locker.h" - -// Polymorphick action invocation -template -inline -void ACTION::Invoke() -{ -(activeClass.*actor)(data); -} - -inline -ACTIONS_LIST::ACTIONS_LIST() - : mutex() -{ -pthread_mutex_init(&mutex, NULL); -} - -// Delete all actions before deleting list -inline -ACTIONS_LIST::~ACTIONS_LIST() -{ - - { - STG_LOCKER lock(&mutex); - - parent::iterator it(parent::begin()); - while (it != parent::end()) - { - delete *it++; - } - } - -pthread_mutex_destroy(&mutex); -} - -inline -ACTIONS_LIST::parent::iterator ACTIONS_LIST::begin() -{ -STG_LOCKER lock(&mutex); -return parent::begin(); -} - -inline -ACTIONS_LIST::parent::iterator ACTIONS_LIST::end() -{ -STG_LOCKER lock(&mutex); -return parent::end(); -} - -inline -ACTIONS_LIST::parent::const_iterator ACTIONS_LIST::begin() const -{ -STG_LOCKER lock(&mutex); -return parent::begin(); -} - -inline -ACTIONS_LIST::parent::const_iterator ACTIONS_LIST::end() const -{ -STG_LOCKER lock(&mutex); -return parent::end(); -} - -inline -bool ACTIONS_LIST::empty() const -{ -STG_LOCKER lock(&mutex); -return parent::empty(); -} - -inline -size_t ACTIONS_LIST::size() const -{ -STG_LOCKER lock(&mutex); -return parent::size(); -} - -inline -void ACTIONS_LIST::swap(ACTIONS_LIST & list) -{ -STG_LOCKER lock(&mutex); -parent::swap(list); -} - -template -inline -void ACTIONS_LIST::Enqueue(ACTIVE_CLASS & ac, - typename ACTOR::TYPE a, - DATA_TYPE d) -{ -STG_LOCKER lock(&mutex); -push_back(new ACTION(ac, a, d)); -} - -inline -void ACTIONS_LIST::InvokeAll() -{ -STG_LOCKER lock(&mutex); -std::for_each( - parent::begin(), - parent::end(), - [](auto action){ action->Invoke(); }); -} - -#endif