mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-17 00:23:58 +00:00
Add scoped_lock_t syntactic sugar
This commit is contained in:
parent
87c84a252a
commit
4eac7e3e4f
@ -128,4 +128,30 @@ namespace zmq
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace zmq
|
||||||
|
{
|
||||||
|
struct scoped_lock_t
|
||||||
|
{
|
||||||
|
scoped_lock_t (mutex_t& mutex_)
|
||||||
|
: mutex (mutex_)
|
||||||
|
{
|
||||||
|
mutex.lock ();
|
||||||
|
}
|
||||||
|
|
||||||
|
~scoped_lock_t ()
|
||||||
|
{
|
||||||
|
mutex.unlock ();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
mutex_t& mutex;
|
||||||
|
|
||||||
|
// Disable copy construction and assignment.
|
||||||
|
scoped_lock_t (const scoped_lock_t&);
|
||||||
|
const scoped_lock_t &operator = (const scoped_lock_t&);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user