oasys::Mutex Class Reference

#include <Mutex.h>

Inheritance diagram for oasys::Mutex:

oasys::Lock oasys::Logger

List of all members.


Detailed Description

Mutex wrapper class for pthread_mutex_t.

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

Member Enumeration Documentation

enum oasys::Mutex::lock_type_t

Different kinds of mutexes offered by Linux, distinguished by their response to a single thread attempting to acquire the same lock more than once.

Enumerator:
TYPE_FAST 
TYPE_RECURSIVE 

Definition at line 38 of file Mutex.h.


Constructor & Destructor Documentation

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_.


Member Function Documentation

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.


Friends And Related Function Documentation

friend class Monitor [friend]

Definition at line 28 of file Mutex.h.


Member Data Documentation

pthread_mutex_t oasys::Mutex::mutex_ [protected]

the underlying mutex

Definition at line 56 of file Mutex.h.

Referenced by lock(), Mutex(), try_lock(), unlock(), and ~Mutex().

lock_type_t oasys::Mutex::type_ [protected]

the mutex type

Definition at line 57 of file Mutex.h.

Referenced by Mutex().

bool oasys::Mutex::keep_quiet_ [protected]

no logging

Definition at line 58 of file Mutex.h.

Referenced by lock(), try_lock(), unlock(), and ~Mutex().


The documentation for this class was generated from the following files:
Generated on Sat Sep 8 08:36:26 2007 for DTN Reference Implementation by  doxygen 1.5.3