WPILibC++ 2024.3.2
|
#include <climits>
#include <initializer_list>
#include <span>
Go to the source code of this file.
Classes | |
class | wpi::Event |
An atomic signaling event for synchronization. More... | |
class | wpi::Semaphore |
A semaphore for synchronization. More... | |
class | wpi::SignalObject< T > |
RAII wrapper for signaling handles. More... | |
Namespaces | |
namespace | wpi |
Typedefs | |
typedef unsigned int | WPI_Handle |
Generic handle for all WPI handle-based interfaces. More... | |
typedef WPI_Handle | WPI_EventHandle |
An event handle. More... | |
typedef WPI_Handle | WPI_SemaphoreHandle |
A semaphore handle. More... | |
Functions | |
WPI_EventHandle | wpi::CreateEvent (bool manualReset=false, bool initialState=false) |
Creates an event. More... | |
void | wpi::DestroyEvent (WPI_EventHandle handle) |
Destroys an event. More... | |
void | wpi::SetEvent (WPI_EventHandle handle) |
Sets an event to signaled state. More... | |
void | wpi::ResetEvent (WPI_EventHandle handle) |
Sets an event to non-signaled state. More... | |
WPI_SemaphoreHandle | wpi::CreateSemaphore (int initialCount=0, int maximumCount=INT_MAX) |
Creates a semaphore. More... | |
void | wpi::DestroySemaphore (WPI_SemaphoreHandle handle) |
Destroys a semaphore. More... | |
bool | wpi::ReleaseSemaphore (WPI_SemaphoreHandle handle, int releaseCount=1, int *prevCount=nullptr) |
Releases N counts of a semaphore. More... | |
bool | wpi::WaitForObject (WPI_Handle handle) |
Waits for an handle to be signaled. More... | |
bool | wpi::WaitForObject (WPI_Handle handle, double timeout, bool *timedOut) |
Waits for an handle to be signaled, with timeout. More... | |
std::span< WPI_Handle > | wpi::WaitForObjects (std::span< const WPI_Handle > handles, std::span< WPI_Handle > signaled) |
Waits for one or more handles to be signaled. More... | |
std::span< WPI_Handle > | wpi::WaitForObjects (std::initializer_list< WPI_Handle > handles, std::span< WPI_Handle > signaled) |
Waits for one or more handles to be signaled. More... | |
std::span< WPI_Handle > | wpi::WaitForObjects (std::span< const WPI_Handle > handles, std::span< WPI_Handle > signaled, double timeout, bool *timedOut) |
Waits for one or more handles to be signaled, with timeout. More... | |
std::span< WPI_Handle > | wpi::WaitForObjects (std::initializer_list< WPI_Handle > handles, std::span< WPI_Handle > signaled, double timeout, bool *timedOut) |
Waits for one or more handles to be signaled, with timeout. More... | |
void | wpi::CreateSignalObject (WPI_Handle handle, bool manualReset=false, bool initialState=false) |
Sets up signaling for an arbitrary handle. More... | |
void | wpi::SetSignalObject (WPI_Handle handle) |
Sets a handle to signaled state. More... | |
void | wpi::ResetSignalObject (WPI_Handle handle) |
Sets a handle to non-signaled state. More... | |
void | wpi::DestroySignalObject (WPI_Handle handle) |
Cleans up signaling for a handle. More... | |
WPI_EventHandle | WPI_CreateEvent (int manual_reset, int initial_state) |
Creates an event. More... | |
void | WPI_DestroyEvent (WPI_EventHandle handle) |
Destroys an event. More... | |
void | WPI_SetEvent (WPI_EventHandle handle) |
Sets an event to signaled state. More... | |
void | WPI_ResetEvent (WPI_EventHandle handle) |
Sets an event to non-signaled state. More... | |
WPI_SemaphoreHandle | WPI_CreateSemaphore (int initial_count, int maximum_count) |
Creates a semaphore. More... | |
void | WPI_DestroySemaphore (WPI_SemaphoreHandle handle) |
Destroys a semaphore. More... | |
int | WPI_ReleaseSemaphore (WPI_SemaphoreHandle handle, int release_count, int *prev_count) |
Releases N counts of a semaphore. More... | |
int | WPI_WaitForObject (WPI_Handle handle) |
Waits for an handle to be signaled. More... | |
int | WPI_WaitForObjectTimeout (WPI_Handle handle, double timeout, int *timed_out) |
Waits for an handle to be signaled, with timeout. More... | |
int | WPI_WaitForObjects (const WPI_Handle *handles, int handles_count, WPI_Handle *signaled) |
Waits for one or more handles to be signaled. More... | |
int | WPI_WaitForObjectsTimeout (const WPI_Handle *handles, int handles_count, WPI_Handle *signaled, double timeout, int *timed_out) |
Waits for one or more handles to be signaled, with timeout. More... | |
void | WPI_CreateSignalObject (WPI_Handle handle, int manual_reset, int initial_state) |
Sets up signaling for an arbitrary handle. More... | |
void | WPI_SetSignalObject (WPI_Handle handle) |
Sets a handle to signaled state. More... | |
void | WPI_ResetSignalObject (WPI_Handle handle) |
Sets a handle to non-signaled state. More... | |
void | WPI_DestroySignalObject (WPI_Handle handle) |
Cleans up signaling for a handle. More... | |
typedef WPI_Handle WPI_EventHandle |
An event handle.
typedef unsigned int WPI_Handle |
Generic handle for all WPI handle-based interfaces.
Handle data layout:
typedef WPI_Handle WPI_SemaphoreHandle |
A semaphore handle.
WPI_EventHandle WPI_CreateEvent | ( | int | manual_reset, |
int | initial_state | ||
) |
Creates an event.
Events have binary state (signaled or not signaled) and may be either automatically reset or manually reset. Automatic-reset events go to non-signaled state when a WaitForObject is woken up by the event; manual-reset events require ResetEvent() to be called to set the event to non-signaled state; if ResetEvent() is not called, any waiter on that event will immediately wake when called.
manual_reset | true for manual reset, false for automatic reset |
initial_state | true to make the event initially in signaled state |
WPI_SemaphoreHandle WPI_CreateSemaphore | ( | int | initial_count, |
int | maximum_count | ||
) |
Creates a semaphore.
Semaphores keep an internal counter. Releasing the semaphore increases the count. A semaphore with a non-zero count is considered signaled. When a waiter wakes up it atomically decrements the count by 1. This is generally useful in a single-supplier, multiple-consumer scenario.
initial_count | initial value for the semaphore's internal counter |
maximum_count | maximum value for the samephore's internal counter |
void WPI_CreateSignalObject | ( | WPI_Handle | handle, |
int | manual_reset, | ||
int | initial_state | ||
) |
Sets up signaling for an arbitrary handle.
With this function, any handle can operate like an event handle.
handle | handle |
manual_reset | true for manual reset, false for automatic reset |
initial_state | true to make the handle initially in signaled state |
void WPI_DestroyEvent | ( | WPI_EventHandle | handle | ) |
Destroys an event.
Destruction wakes up any waiters.
handle | event handle |
void WPI_DestroySemaphore | ( | WPI_SemaphoreHandle | handle | ) |
Destroys a semaphore.
Destruction wakes up any waiters.
handle | semaphore handle |
void WPI_DestroySignalObject | ( | WPI_Handle | handle | ) |
Cleans up signaling for a handle.
Destruction wakes up any waiters.
handle | handle |
int WPI_ReleaseSemaphore | ( | WPI_SemaphoreHandle | handle, |
int | release_count, | ||
int * | prev_count | ||
) |
Releases N counts of a semaphore.
handle | semaphore handle |
release_count | amount to add to semaphore's internal counter; must be positive |
prev_count | if non-null, previous count (output parameter) |
void WPI_ResetEvent | ( | WPI_EventHandle | handle | ) |
Sets an event to non-signaled state.
handle | event handle |
void WPI_ResetSignalObject | ( | WPI_Handle | handle | ) |
Sets a handle to non-signaled state.
handle | handle |
void WPI_SetEvent | ( | WPI_EventHandle | handle | ) |
Sets an event to signaled state.
handle | event handle |
void WPI_SetSignalObject | ( | WPI_Handle | handle | ) |
Sets a handle to signaled state.
handle | handle |
int WPI_WaitForObject | ( | WPI_Handle | handle | ) |
Waits for an handle to be signaled.
handle | handle to wait on |
int WPI_WaitForObjects | ( | const WPI_Handle * | handles, |
int | handles_count, | ||
WPI_Handle * | signaled | ||
) |
Waits for one or more handles to be signaled.
Invalid handles are treated as signaled; the returned array will have the handle error bit set for any invalid handles.
handles | array of handles to wait on |
handles_count | length of the handles array |
signaled | output array for storage of signaled handles; must be at least the size of the handles input array |
int WPI_WaitForObjectsTimeout | ( | const WPI_Handle * | handles, |
int | handles_count, | ||
WPI_Handle * | signaled, | ||
double | timeout, | ||
int * | timed_out | ||
) |
Waits for one or more handles to be signaled, with timeout.
Invalid handles are treated as signaled; the returned array will have the handle error bit set for any invalid handles.
handles | array of handles to wait on |
handles_count | length of the handles array |
signaled | output array for storage of signaled handles; must be at least the size of the handles input array |
timeout | timeout in seconds |
timed_out | if non-null, set to non-zero if timeout reached without any handle being signaled; set to zero otherwise (output) |
int WPI_WaitForObjectTimeout | ( | WPI_Handle | handle, |
double | timeout, | ||
int * | timed_out | ||
) |
Waits for an handle to be signaled, with timeout.
handle | handle to wait on |
timeout | timeout in seconds |
timed_out | if non-null, set to non-zero if timeout reached without handle being signaled; set to zero otherwise (output) |