mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-22 16:02:31 +02:00
Add try_lock() to mutex_t
This commit is contained in:
@@ -50,6 +50,11 @@ namespace zmq
|
|||||||
EnterCriticalSection (&cs);
|
EnterCriticalSection (&cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool try_lock ()
|
||||||
|
{
|
||||||
|
return (bool) TryEnterCriticalSection (&cs);
|
||||||
|
}
|
||||||
|
|
||||||
inline void unlock ()
|
inline void unlock ()
|
||||||
{
|
{
|
||||||
LeaveCriticalSection (&cs);
|
LeaveCriticalSection (&cs);
|
||||||
@@ -94,6 +99,16 @@ namespace zmq
|
|||||||
posix_assert (rc);
|
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 ()
|
inline void unlock ()
|
||||||
{
|
{
|
||||||
int rc = pthread_mutex_unlock (&mutex);
|
int rc = pthread_mutex_unlock (&mutex);
|
||||||
|
Reference in New Issue
Block a user