OnixS C++ FIX Engine 2.79.1.0
Semaphore Class Reference

List of all members.

Public Member Functions

 Semaphore (unsigned int count=1)
 ~Semaphore ()
void acquire ()
bool tryAcquire ()
void release ()

Detailed Description

Limits number of threads that can access shared resource simultaneously.


Constructor & Destructor Documentation

Semaphore ( unsigned int  count = 1)

Initializes the instance with given value of "count".

Parameters:
countindicates initial "count" for semaphore. State of semaphore is signaled when its count is greater than zero and non-signaled when it is zero.

Member Function Documentation

void acquire ( )

Decrements semaphore "counter" by one. If semaphore "counter" is already zero, blocks the thread until semaphore "count" becomes grater then zero.

void release ( )

Increments semaphore "counter" by one. If there are other threads waiting for the object, it blocks one the them.

bool tryAcquire ( )

Tries to acquire semaphore object. If its "counter" is already zero, returns false. In all cases, it doesn't block the thread and quites immediately.