diff options
author | Pixel <pixel@nobis-crew.org> | 2011-12-05 09:16:42 -0800 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2011-12-05 09:16:42 -0800 |
commit | 2f36082049c30562f2cb3061438c4aaebc8d8fe5 (patch) | |
tree | c1a93f96750cce63e9801b0907499c8a4d2b969e /includes | |
parent | b419f3e159212c9998b3f86c1fee332620472f4e (diff) |
Adding read-write locks, and applying them immediately to the http server.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/HttpServer.h | 2 | ||||
-rw-r--r-- | includes/Threads.h | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/includes/HttpServer.h b/includes/HttpServer.h index 3867252..37353ac 100644 --- a/includes/HttpServer.h +++ b/includes/HttpServer.h @@ -55,7 +55,7 @@ class HttpServer { String m_local; typedef std::list<Action *> ActionList; ActionList m_actions; - Lock m_actionsLock; + RWLock m_actionsLock; friend class HttpWorker; }; diff --git a/includes/Threads.h b/includes/Threads.h index f6aed5a..67143ca 100644 --- a/includes/Threads.h +++ b/includes/Threads.h @@ -20,6 +20,17 @@ class Lock { friend class Queue; }; +class RWLock { + public: + RWLock(); + ~RWLock() { pthread_rwlock_destroy(&m_lock); } + void enterR() { pthread_rwlock_rdlock(&m_lock); } + void enterW() { pthread_rwlock_wrlock(&m_lock); } + void leave() { pthread_rwlock_unlock(&m_lock); } + private: + pthread_rwlock_t m_lock; +}; + class ThreadHelper; class Thread { |