Commit 87c84a25 authored by danielkr's avatar danielkr

Add try_lock() to mutex_t

parent 503da83f
......@@ -50,6 +50,11 @@ namespace zmq
EnterCriticalSection (&cs);
}
inline bool try_lock ()
{
return (bool) TryEnterCriticalSection (&cs);
}
inline void unlock ()
{
LeaveCriticalSection (&cs);
......@@ -94,6 +99,16 @@ namespace zmq
posix_assert (rc);
}
inline bool try_lock ()
{
int rc = pthread_mutex_trylock (&mutex);
if (rc == EBUSY)
return false;
posix_assert (rc);
return true;
}
inline void unlock ()
{
int rc = pthread_mutex_unlock (&mutex);
......
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