lwpa
0.1.0
LightWeight Platform Abstraction (lwpa)
|
View other versions:
|
A signal object.
Sometimes also referred to as a binary semaphore or event. Used for thread synchronization; a call to lwpa_signal_wait() blocks until lwpa_signal_post() is called.
Typedefs | |
typedef UNDEFINED | lwpa_signal_t |
The signal identifier. More... | |
Functions | |
bool | lwpa_signal_create (lwpa_signal_t *id) |
Create a new signal. More... | |
bool | lwpa_signal_wait (lwpa_signal_t *id, int wait_ms) |
Wait for a signal. More... | |
void | lwpa_signal_post (lwpa_signal_t *id) |
Post a signal. More... | |
void | lwpa_signal_destroy (lwpa_signal_t *id) |
Destroy a signal object. More... | |
typedef UNDEFINED lwpa_signal_t |
The signal identifier.
Depending on the platform, this could be a scalar type or a struct.
bool lwpa_signal_create | ( | lwpa_signal_t * | id | ) |
Create a new signal.
Signals are created in the "unsignaled" state; that is, the first call to lwpa_signal_wait() will block.
[in,out] | id | Signal identifier on which to create a signal. If this function returns true, id becomes valid for calls to lwpa_signal_wait() and lwpa_signal_post(). |
void lwpa_signal_destroy | ( | lwpa_signal_t * | id | ) |
Destroy a signal object.
[in] | id | Identifier for the signal to destroy. |
void lwpa_signal_post | ( | lwpa_signal_t * | id | ) |
Post a signal.
If no threads are waiting for the signal, puts the signal object in the "signaled" state (a subsequent call to lwpa_signal_wait() will return immediately). Otherwise, wakes up the first thread that waited for the signal.
[in] | id | Identifier for the signal to post. |
bool lwpa_signal_wait | ( | lwpa_signal_t * | id, |
int | wait_ms | ||
) |
Wait for a signal.
If this is the first call to lwpa_signal_wait() after the signal object has been posted via lwpa_signal_post(), returns immediately. Otherwise, blocks until a call to lwpa_signal_post() on the signal object.
[in] | id | Identifier for the signal for which to wait. |
[in] | wait_ms | How long to wait for the signal, in milliseconds (use LWPA_WAIT_FOREVER to wait indefinitely). |