#include <winstl/synch/semaphore.hpp>
Public Types | |
enum | { maxCountValue = 0x7fffffff } |
typedef semaphore | class_type |
This type. | |
typedef HANDLE | synch_handle_type |
The synchronisation handle type. | |
typedef bool | bool_type |
The Boolean type. | |
typedef size_t | count_type |
The count type. | |
typedef HANDLE | resource_type |
The resource type. | |
Public Member Functions | |
Construction | |
semaphore (synch_handle_type sem, bool_type bTakeOwnership) | |
Conversion constructor. | |
semaphore (count_type initialCount, count_type maxCount=maxCountValue) | |
Creates an instance of the semaphore. | |
semaphore (char const *name, count_type initialCount, count_type maxCount=maxCountValue) | |
Creates an instance of the semaphore. | |
semaphore (wchar_t const *name, count_type initialCount, count_type maxCount=maxCountValue) | |
Creates an instance of the semaphore. | |
semaphore (char const *name, LPSECURITY_ATTRIBUTES psa, count_type initialCount, count_type maxCount=maxCountValue) | |
Creates an instance of the semaphore. | |
semaphore (wchar_t const *name, LPSECURITY_ATTRIBUTES psa, count_type initialCount, count_type maxCount=maxCountValue) | |
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 | lock (ws_dword_t wait) |
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. | |
ws_long_t | unlock (count_type numLocksToRelease) |
Releases a number of aquired "locks" on the semaphore, increasing the semaphore's counter by the given value. | |
Accessors | |
synch_handle_type | handle () |
The underlying kernel object handle. | |
synch_handle_type | get () |
The underlying kernel object handle. |
typedef semaphore class_type |
This type.
typedef HANDLE synch_handle_type |
The synchronisation handle type.
typedef bool bool_type |
The Boolean type.
typedef size_t count_type |
The count type.
typedef HANDLE resource_type |
The resource type.
semaphore | ( | synch_handle_type | sem, | |
bool_type | bTakeOwnership | |||
) | [inline] |
semaphore | ( | count_type | initialCount, | |
count_type | maxCount = maxCountValue | |||
) | [inline, explicit] |
Creates an instance of the semaphore.
semaphore | ( | char const * | name, | |
count_type | initialCount, | |||
count_type | maxCount = maxCountValue | |||
) | [inline, explicit] |
Creates an instance of the semaphore.
semaphore | ( | wchar_t const * | name, | |
count_type | initialCount, | |||
count_type | maxCount = maxCountValue | |||
) | [inline, explicit] |
Creates an instance of the semaphore.
semaphore | ( | char const * | name, | |
LPSECURITY_ATTRIBUTES | psa, | |||
count_type | initialCount, | |||
count_type | maxCount = maxCountValue | |||
) | [inline, explicit] |
Creates an instance of the semaphore.
semaphore | ( | wchar_t const * | name, | |
LPSECURITY_ATTRIBUTES | psa, | |||
count_type | initialCount, | |||
count_type | maxCount = maxCountValue | |||
) | [inline, explicit] |
Creates an instance of the semaphore.
void lock | ( | ) | [inline] |
Acquires a lock on the semaphore, pending the thread until the lock is aquired.
References WINSTL_ASSERT.
bool_type lock | ( | ws_dword_t | wait | ) | [inline] |
Acquires a lock on the semaphore, pending the thread until the lock is aquired.
References WINSTL_ASSERT.
bool_type try_lock | ( | ) | [inline] |
void unlock | ( | ) | [inline] |
Releases an aquired lock on the semaphore, increasing the semaphore's counter by one.
References WINSTL_ASSERT.
ws_long_t unlock | ( | count_type | numLocksToRelease | ) | [inline] |
Releases a number of aquired "locks" on the semaphore, increasing the semaphore's counter by the given value.
numLocksToRelease | The number by which to increment the semaphore's counter. If this is greater than the available value, the function fails. (It will throw an exception, if exception handling is enabled, or return -1 otherwise.) |
-1 | Indicates call failure (only if exception handling is not enabled). |
References WINSTL_ASSERT.
synch_handle_type handle | ( | ) | [inline] |
The underlying kernel object handle.
synch_handle_type get | ( | ) | [inline] |
The underlying kernel object handle.
Referenced by winstl::get_kernel_handle(), and winstl::get_synch_handle().