diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/TaskMan.h | 2 | ||||
-rw-r--r-- | includes/Threads.h | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/includes/TaskMan.h b/includes/TaskMan.h index d8d0c80..fd00172 100644 --- a/includes/TaskMan.h +++ b/includes/TaskMan.h @@ -5,6 +5,7 @@ #include <ev++.h> #include <ext/hash_set> #include <vector> +#include <Threads.h> namespace gnu = __gnu_cxx; @@ -32,6 +33,7 @@ class TaskMan { typedef std::vector<Task *> taskList_t; taskHash_t m_tasks, m_signaledTasks; taskList_t m_pendingAdd; + Lock m_pendingLock; volatile bool m_stopped; struct ev_loop * m_loop; }; diff --git a/includes/Threads.h b/includes/Threads.h new file mode 100644 index 0000000..5a4ef61 --- /dev/null +++ b/includes/Threads.h @@ -0,0 +1,17 @@ +#pragma once + +#include <pthread.h> + +namespace Balau { + +class Lock { + public: + Lock(); + ~Lock() { pthread_mutex_destroy(&m_lock); } + void enter() { pthread_mutex_lock(&m_lock); } + void leave() { pthread_mutex_unlock(&m_lock); } + private: + pthread_mutex_t m_lock; +}; + +}; |