|
Yate
|
Semaphore implementation. More...
#include <yateclass.h>
Public Member Functions | |
| Semaphore (unsigned int maxcount=1, const char *name=0) | |
| Semaphore (const Semaphore &original) | |
| ~Semaphore () | |
| Semaphore & | operator= (const Semaphore &original) |
| virtual bool | lock (long maxwait=-1) |
| virtual bool | unlock () |
| virtual bool | locked () const |
Static Public Member Functions | |
| static int | count () |
| static int | locks () |
| static bool | efficientTimedLock () |
Friends | |
| class | SemaphorePrivate |
Semaphore implementation.
A semaphore object for synchronizing threads, can also be used as a token bucket
| Semaphore | ( | unsigned int | maxcount = 1, |
| const char * | name = 0 |
||
| ) | [explicit] |
Construct a new unlocked semaphore
| maxcount | Maximum unlock count, must be strictly positive |
| name | Static name of the semaphore (for debugging purpose only) |
Copy constructor, creates a shared semaphore
| original | Reference of the semaphore to share |
| ~Semaphore | ( | ) |
Destroy the semaphore
| static int count | ( | ) | [static] |
Get the number of semaphores counting the shared ones only once
| static bool efficientTimedLock | ( | ) | [static] |
Check if a timed lock() is efficient on this platform
| virtual bool lock | ( | long | maxwait = -1 | ) | [virtual] |
| virtual bool locked | ( | ) | const [virtual] |
Check if the semaphore is currently locked (waiting) - as it's asynchronous it guarantees nothing if other thread changes status
Implements Lockable.
| static int locks | ( | ) | [static] |
Get the number of currently locked (waiting) semaphores
Assignment operator makes the semaphore shared with the original
| original | Reference of the semaphore to share |
| virtual bool unlock | ( | ) | [virtual] |
Unlock the semaphore, does never wait nor get over counter maximum
Implements Lockable.
1.7.6.1