C12Adapter Opensource C++ Interface
|
Semaphore to be used to synchronize resource access. More...
Public Member Functions | |
virtual | ~MSemaphore () |
Constructor that creates semaphore. More... | |
virtual void | Unlock () |
Unlock semaphore to allow other threads/processes to access the resource. More... | |
long | UnlockWithCount (long count) |
Unlock semaphore with specific number of counts to allow other threads/processes to access the resource. More... | |
![]() | |
void | Lock () |
Lock without timeout. More... | |
bool | LockWithTimeout (long timeout) |
Additional Inherited Members | |
![]() | |
static void | WaitForAll (MSynchronizer *p0, MSynchronizer *p1, MSynchronizer *p2=0, MSynchronizer *p3=NULL, MSynchronizer *p4=NULL) |
Wait until all the objects in the list are set to nonsignaled state. More... | |
static bool | WaitWithTimeoutForAll (long timeout, MSynchronizer *p0, MSynchronizer *p1, MSynchronizer *p2=0, MSynchronizer *p3=NULL, MSynchronizer *p4=NULL) |
Wait until all the objects in the list are set to nonsignaled state, or timeout expires. More... | |
static unsigned | WaitForAny (MSynchronizer *p0, MSynchronizer *p1, MSynchronizer *p2=NULL, MSynchronizer *p3=NULL, MSynchronizer *p4=NULL) |
Wait until any of the objects in the list are set to nonsignaled state. More... | |
static bool | WaitWithTimeoutForAny (long timeout, unsigned *which, MSynchronizer *p0, MSynchronizer *p1, MSynchronizer *p2=0, MSynchronizer *p3=NULL, MSynchronizer *p4=NULL) |
Wait until any of the objects in the list are set to nonsignaled state, or timeout expires. More... | |
![]() | |
MSynchronizer () | |
Constructor that creates synchronizer. More... | |
virtual | ~MSynchronizer () |
Destructor. | |
Semaphore to be used to synchronize resource access.
The implementation of the class is system dependent.
The semaphore is very often used with MSynchronizer::Lock helper class as the following:
|
virtual |
Constructor that creates semaphore.
Destructor.
|
virtual |
Unlock semaphore to allow other threads/processes to access the resource.
This service unlocks the semaphore with the count of one. One needs to take into consideration the monitor-specific UnlockWithCount service too, which is also capable of returning a previous count.
Implements MSynchronizer.
long MSemaphore::UnlockWithCount | ( | long | count | ) |
Unlock semaphore with specific number of counts to allow other threads/processes to access the resource.
This is a semaphore-specific variation of Unlock service. The function can be used when the number of the resources is increased to add the resource to control.
The function allows adding more than one resource and knowing the previous resource count. The return value is the previous semaphore count.