Rudiments
Public Member Functions
mutex Class Reference

List of all members.

Public Member Functions

 mutex ()
 mutex (void *mut)
 ~mutex ()
bool lock ()
bool tryLock ()
bool unlock ()
void * getInternalMutexStructure ()

Detailed Description

The mutex class provides an interface to pthreads mutual exclusion locks between separate threads of a single process.


Constructor & Destructor Documentation

mutex::mutex ( )

Creates an instance of the mutex class.

mutex::mutex ( void *  mut)

Creates an instance of the mutex class that uses an already-initialized, system-specific mutex structure. On unix systems, this would likely be an instance of struct pthread_mutex_t, though it could possibly be something else.

mutex::~mutex ( )

Deletes this instance of the mutex class.


Member Function Documentation

void* mutex::getInternalMutexStructure ( )

Returns the mutex structure used by the class internally. On unix systems this would most likely be a struct pthread_mutex_t *, though it could possible be something else.

bool mutex::lock ( )

Locks the mutex. Will wait until the lock succeds. Returns true on success and false if an error occurs.

bool mutex::tryLock ( )

Attempts to lock the mutex. Will return immediately if the mutex could not be locked, returning false and setting errno to EBUSY. Returns true on success and false if an error occurs.

bool mutex::unlock ( )

Unlocks the mutex. Returns true on success and false if an error occurs.