#include <Mutex.h>
Definition at line 27 of file Mutex.h.
Public Types | |
enum | lock_type_t { TYPE_FAST = 1, TYPE_RECURSIVE } |
Different kinds of mutexes offered by Linux, distinguished by their response to a single thread attempting to acquire the same lock more than once. More... | |
Public Member Functions | |
Mutex (const char *logbase, lock_type_t type=TYPE_RECURSIVE, bool keep_quiet=false) | |
Creates a mutex. By default, we create a TYPE_RECURSIVE. | |
~Mutex () | |
int | lock (const char *lock_user) |
Virtual from Lock. | |
int | unlock () |
Virtual from Lock. | |
int | try_lock (const char *lock_user) |
Virtual from Lock. | |
Protected Attributes | |
pthread_mutex_t | mutex_ |
the underlying mutex | |
lock_type_t | type_ |
the mutex type | |
bool | keep_quiet_ |
no logging | |
Friends | |
class | Monitor |
Different kinds of mutexes offered by Linux, distinguished by their response to a single thread attempting to acquire the same lock more than once.
oasys::Mutex::Mutex | ( | const char * | logbase, | |
lock_type_t | type = TYPE_RECURSIVE , |
|||
bool | keep_quiet = false | |||
) |
Creates a mutex. By default, we create a TYPE_RECURSIVE.
Definition at line 33 of file Mutex.cc.
References errno, oasys::Logger::logpathf(), mutex_, NOTREACHED, type_, TYPE_FAST, and TYPE_RECURSIVE.
oasys::Mutex::~Mutex | ( | ) |
Definition at line 71 of file Mutex.cc.
References keep_quiet_, log_debug, oasys::Logger::logpath_, and mutex_.
int oasys::Mutex::lock | ( | const char * | lock_user | ) | [virtual] |
Virtual from Lock.
Implements oasys::Lock.
Definition at line 79 of file Mutex.cc.
References oasys::Thread::current(), errno, keep_quiet_, oasys::Lock::lock_count_, oasys::Lock::lock_holder_, oasys::Lock::lock_holder_name_, log_debug, oasys::Logger::logpath_, mutex_, and oasys::atomic_t::value.
Referenced by dtn::GlobalStore::close().
int oasys::Mutex::unlock | ( | ) | [virtual] |
Virtual from Lock.
Implements oasys::Lock.
Definition at line 99 of file Mutex.cc.
References ASSERT, errno, oasys::Lock::is_locked_by_me(), keep_quiet_, oasys::Lock::lock_count_, oasys::Lock::lock_holder_, oasys::Lock::lock_holder_name_, log_debug, oasys::Logger::logpath_, mutex_, and oasys::atomic_t::value.
int oasys::Mutex::try_lock | ( | const char * | lock_user | ) | [virtual] |
Virtual from Lock.
Implements oasys::Lock.
Definition at line 121 of file Mutex.cc.
References oasys::Thread::current(), errno, keep_quiet_, oasys::Lock::lock_count_, oasys::Lock::lock_holder_, oasys::Lock::lock_holder_name_, log_debug, oasys::Logger::logpath_, mutex_, and oasys::atomic_t::value.
pthread_mutex_t oasys::Mutex::mutex_ [protected] |
lock_type_t oasys::Mutex::type_ [protected] |
bool oasys::Mutex::keep_quiet_ [protected] |