API Guides > ConceptRT 3.x
Semaphore Class Reference

Abstraction of a semaphore. A semaphore object is a synchronization object that maintains a count between zero and a specified maximum value. The count is decremented each time a thread completes a wait for the semaphore object and incremented each time a thread releases the semaphore. When the count reaches zero, no more threads can successfully wait for the semaphore object state to become signaled. The state of a semaphore is set to signaled when its count is greater than zero, and nonsignaled when its count is zero. More...

Detailed Description

Abstraction of a semaphore. A semaphore object is a synchronization object that maintains a count between zero and a specified maximum value. The count is decremented each time a thread completes a wait for the semaphore object and incremented each time a thread releases the semaphore. When the count reaches zero, no more threads can successfully wait for the semaphore object state to become signaled. The state of a semaphore is set to signaled when its count is greater than zero, and nonsignaled when its count is zero.

+ Inheritance diagram for Semaphore:

Public Member Methods

 Semaphore (Int32 initialCount)
 Constructor. More...
 
 Semaphore (Int32 initialCount, Int32 maxCount)
 Constructor. More...
 
 Semaphore (PCChar8 name, Int32 initialCount, Int32 maxCount)
 Constructor. More...
 
 Semaphore (PCChar8 name, Int32 initialCount)
 Constructor. More...
 
 ~Semaphore ()
 Destructor. More...
 
void Lock ()
 Locks the Semaphore. More...
 
bool Lock (TimeSpan timeOut)
 Locks the Semaphore. More...
 
void Unlock ()
 Unlocks the Semaphore. More...
 

Constructor & Destructor Documentation

Semaphore ( Int32  initialCount)

Constructor.

Parameters
initialCountInitial value of the semaphore. maxCount limit fixed at MaxInt32
Semaphore ( Int32  initialCount,
Int32  maxCount 
)

Constructor.

Parameters
initialCountInitial value of the semaphore.
maxCountMaximum value of the semaphore.
Semaphore ( PCChar8  name,
Int32  initialCount,
Int32  maxCount 
)

Constructor.

Parameters
nameThe name.
initialCountInitial value of the semaphore.
maxCountMaximum value of the semaphore.
Warning
Non-Deterministic. Determinism when using ConceptRT library can be ensure by using Context Time Critical mechanisms.
Semaphore ( PCChar8  name,
Int32  initialCount 
)

Constructor.

Parameters
nameThe name.
initialCountInitial value of the semaphore.
Warning
Non-Deterministic. Determinism when using ConceptRT library can be ensure by using Context Time Critical mechanisms.
~Semaphore ( )

Destructor.

Warning
Non-Deterministic. Determinism when using ConceptRT library can be ensure by using Context Time Critical mechanisms.

Methods Documentation

void Lock ( )

Locks the Semaphore.

bool Lock ( TimeSpan  timeOut)

Locks the Semaphore.

Parameters
timeOutThe time out.
Returns
true if lock success, false if timeout occurs.
void Unlock ( )

Unlocks the Semaphore.