12 #ifndef ROC_CORE_MUTEX_H_
13 #define ROC_CORE_MUTEX_H_
44 const int err = pthread_mutex_trylock(&mutex_);
46 if (err != 0 && err != EBUSY && err != EAGAIN) {
55 if (
int err = pthread_mutex_lock(&mutex_)) {
64 if (
int err = pthread_mutex_unlock(&mutex_)) {
74 mutable pthread_mutex_t mutex_;
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
ScopedLock< Mutex > Lock
RAII lock.
void unlock() const
Unlock mutex.
ROC_ATTR_NODISCARD bool try_lock() const
Try to lock the mutex.
void lock() const
Lock mutex.
Base class for non-copyable objects.
#define roc_panic(...)
Print error message and terminate program gracefully.