Cheetah Software
1.0
|
#include <SharedMemory.h>
Public Member Functions | |
void | init (unsigned int value) |
void | increment () |
void | decrement () |
bool | tryDecrement () |
bool | decrementTimeout (u64 seconds, u64 nanoseconds) |
void | destroy () |
Private Attributes | |
sem_t | _sem |
bool | _init = false |
A POSIX semaphore for shared memory. See https://linux.die.net/man/7/sem_overview for more deatils
Definition at line 27 of file SharedMemory.h.
|
inline |
If the semaphore's value is > 0, decrement the value. Otherwise, wait until its value is > 0, then decrement.
Definition at line 59 of file SharedMemory.h.
References _sem.
Like decrement, but after waiting ms milliseconds, will give up Returns true if the semaphore is successfully decremented
Definition at line 72 of file SharedMemory.h.
References _sem.
|
inline |
Delete the semaphore. Note that deleting a semaphore in one process while another is still using it results in very strange behavior.
Definition at line 86 of file SharedMemory.h.
References _sem.
|
inline |
Increment the value of the semaphore.
Definition at line 53 of file SharedMemory.h.
References _sem.
|
inline |
If semaphore is unitialized, initialize it and set its value. This can be called as many times as you want safely. It must be called at least once. Only one process needs to call this, even if it is used in multiple processes.
Note that if init() is called after the semaphore has been initialized, it will not change its value.
value | The initial value of the semaphore. |
Definition at line 39 of file SharedMemory.h.
|
inline |
If the semaphore's value is > 0, decrement the value and return true Otherwise, return false (doesn't decrement or wait)
Definition at line 66 of file SharedMemory.h.
References _sem.
|
private |
Definition at line 90 of file SharedMemory.h.
|
private |
Definition at line 89 of file SharedMemory.h.