golib
0.5
|
Semaphore class. More...
#include <gothread.h>
Public Member Functions | |
void | dec () |
void | inc () |
Protected Attributes | |
sem_t | semaphore |
Semaphore class.
This class implements a semaphore. A semaphore represents a value that can be incremented and decremented. If the semaphore's value is 0 and decrement is called, the calling thread is blocked until the semaphore is > 0, then the value is decremented. Increments and decrements are atomic operations, i.e. they are thread-safe.
void goSemaphore::dec | ( | ) |
Waits until semaphore is > 0, then decrements it atomically.
void goSemaphore::inc | ( | ) |
Increments the semaphore atomically.