semaphore Class Reference
[Synchronisation Library]

#include <unixstl/synch/semaphore.hpp>

Inheritance diagram for semaphore:

critical_section< STLSOFT_CRITICAL_SECTION_ISNOT_RECURSIVE, STLSOFT_CRITICAL_SECTION_IS_TRYABLE > synchronisable_object_tag critical_section_tag

List of all members.


Detailed Description

This class acts as an semaphore based on the POSIX semaphore object.

Public Types

Member Constants
enum  { maxCountValue = _POSIX_SEM_VALUE_MAX }
Member Types
typedef semaphore class_type
typedef sem_t * handle_type
typedef bool bool_type
typedef size_t count_type
typedef sem_t * resource_type

Public Member Functions

Construction
 semaphore (handle_type sem, bool_type bTakeOwnership)
 Conversion constructor.
 semaphore (count_type initialCount, bool_type bInterProcessShared=false)
 Creates an instance of the semaphore.
 ~semaphore () throw ()
 Destroys an instance of the semaphore.
Operations
void lock ()
 Acquires a lock on the semaphore, pending the thread until the lock is aquired.
bool_type try_lock ()
 Attempts to lock the semaphore.
void unlock ()
 Releases an aquired lock on the semaphore, increasing the semaphore's counter by one.
Accessors
handle_type handle () throw ()
 The underlying kernel object handle.
handle_type get () throw ()
 The underlying kernel object handle.

Constructor & Destructor Documentation

semaphore ( handle_type  sem,
bool_type  bTakeOwnership 
) [inline]

Conversion constructor.

References UNIXSTL_ASSERT.

semaphore ( count_type  initialCount,
bool_type  bInterProcessShared = false 
) [inline, explicit]

Creates an instance of the semaphore.

~semaphore (  )  throw () [inline]

Destroys an instance of the semaphore.


Member Function Documentation

void lock (  )  [inline]

Acquires a lock on the semaphore, pending the thread until the lock is aquired.

References UNIXSTL_ASSERT.

bool_type try_lock (  )  [inline]

Attempts to lock the semaphore.

Returns:
true if the semaphore was aquired, or false if not

References UNIXSTL_ASSERT.

void unlock (  )  [inline]

Releases an aquired lock on the semaphore, increasing the semaphore's counter by one.

References UNIXSTL_ASSERT.

handle_type handle (  )  throw () [inline]

The underlying kernel object handle.

handle_type get (  )  throw () [inline]

The underlying kernel object handle.


The documentation for this class was generated from the following file:

Generated on Thu Jun 10 08:59:08 2010 for STLSoft by  doxygen 1.5.6