Commit 9201009f authored by a4z's avatar a4z

Problem: socket_base uses macros for mutex lock and unlock

Solution: add a lock guard that takes optional a mutex and use it
parent fb34c323
......@@ -181,6 +181,33 @@ namespace zmq
scoped_lock_t (const scoped_lock_t&);
const scoped_lock_t &operator = (const scoped_lock_t&);
};
struct scoped_optional_lock_t
{
scoped_optional_lock_t (mutex_t* mutex_)
: mutex (mutex_)
{
if(mutex != 0)
mutex->lock ();
}
~scoped_optional_lock_t ()
{
if(mutex != 0)
mutex->unlock ();
}
private:
mutex_t* mutex;
// Disable copy construction and assignment.
scoped_optional_lock_t (const scoped_lock_t&);
const scoped_optional_lock_t &operator = (const scoped_lock_t&);
};
}
#endif
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment