diff options
author | Martin Sustrik <sustrik@fastmq.commkdir> | 2009-08-08 16:01:58 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@fastmq.commkdir> | 2009-08-08 16:01:58 +0200 |
commit | a8b410e66c3c75809c8e9c01dd3e35c579f02347 (patch) | |
tree | 7af63906dce0216f86e5ff0767efaddfd6492cfd /src/mutex.hpp | |
parent | 0b5cc026fbe7ccc6de66907be29471562a2d344d (diff) |
lockfree interaction patter for 3 theads implemented
Diffstat (limited to 'src/mutex.hpp')
-rw-r--r-- | src/mutex.hpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/mutex.hpp b/src/mutex.hpp index 9b51955..e233c9e 100644 --- a/src/mutex.hpp +++ b/src/mutex.hpp @@ -72,43 +72,47 @@ namespace zmq namespace zmq { - + class mutex_t { public: inline mutex_t () { int rc = pthread_mutex_init (&mutex, NULL); - errno_assert (rc == 0); + if (rc) + posix_assert (rc); } - + inline ~mutex_t () { int rc = pthread_mutex_destroy (&mutex); - errno_assert (rc == 0); + if (rc) + posix_assert (rc); } - + inline void lock () { int rc = pthread_mutex_lock (&mutex); - errno_assert (rc == 0); + if (rc) + posix_assert (rc); } - + inline void unlock () { int rc = pthread_mutex_unlock (&mutex); - errno_assert (rc == 0); + if (rc) + posix_assert (rc); } - + private: - + pthread_mutex_t mutex; - - // Disable copy construction and assignment. + + // Disable copy construction and assignment. mutex_t (const mutex_t&); void operator = (const mutex_t&); }; - + } #endif |