summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-09 22:58:44 -0700
committerPixel <pixel@nobis-crew.org>2011-10-09 22:58:44 -0700
commitcf9a801ebcb4df0a8b1ea75e58ca8ea8960ba13b (patch)
treed27f9bf411f2c8d222a85935dec09a2616f61681 /includes
parent4010635b9c3d74e544d37d1e9295316cff01b014 (diff)
Adding basic locks from libpthread. Also, that 'pending' loop belongs after we activate the tasks.
Diffstat (limited to 'includes')
-rw-r--r--includes/TaskMan.h2
-rw-r--r--includes/Threads.h17
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;
+};
+
+};