mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-21 23:56:56 +02:00
Add try_lock() to mutex_t
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user