#include <mcllib/MCSemaphore.h>
Inheritance diagram for MCSemaphore:
Public Member Functions | |
virtual void | lock () |
Lock the semaphore object. | |
MCSemaphore (const char *name, mcintn mode, mcintn initialValue=0, bool excl=false) | |
Create or open a named semaphore. | |
MCSemaphore (const char *name) | |
Open a named semaphore. | |
virtual void | notify () |
Signal a single thread. | |
void | post () |
Post (signal) the semaphore. | |
virtual void | unlock () |
Unlock the semaphore object. | |
virtual void | wait () |
Wait for the semaphore to be signalled (posted). | |
~MCSemaphore () | |
Close the semaphore. | |
Static Public Member Functions | |
void | remove (const char *name) |
Remove a named semaphore. |
Semaphores can be shared across processes. A name specified when the object is created is used to allow the IPC.
|
Open a named semaphore. The named semaphore must already exist. This means that some process must have called the alternate constructor which allows the semaphore to be created. If the named semaphore does not already exist an exception is thrown.
|
|
Create or open a named semaphore. If the named semaphore does not exist, it is created.
|
|
Close the semaphore. Note that the named semaphore will not be removed even if:-
The static remove() function must be called to remove the named semaphore object from the system. |
|
Lock the semaphore object. If another thread has locked the semaphore object and has not yet unlocked it, the calling thread blocks indefinitely until the other thread calls unlock() or notify(). This is the same as calling wait() on the semaphore. Implements MCMutex. |
|
Signal a single thread. This is the same as calling post() or unlock() on the semaphore. Implements MCWaitNotify. |
|
Post (signal) the semaphore. The value of the semaphore is incremented by one. This is the same as calling notify() or unlock() on the semaphore. |
|
Remove a named semaphore.
|
|
Unlock the semaphore object. If there are any threads blocked waiting for the semaphore to be unlocked, one of them will be woken up. This is the same as calling post() or notify() on the semaphore. Implements MCMutex. |
|
Wait for the semaphore to be signalled (posted). This is the same as calling lock() on the semaphore Implements MCWaitNotify. |