![]() |
WPILibC++ 2025.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 |
| Foonathan namespace. | |
Typedefs | |
| typedef unsigned int | WPI_Handle |
| Generic handle for all WPI handle-based interfaces. | |
| typedef WPI_Handle | WPI_EventHandle |
| An event handle. | |
| typedef WPI_Handle | WPI_SemaphoreHandle |
| A semaphore handle. | |
Functions | |
| WPI_EventHandle | wpi::CreateEvent (bool manualReset=false, bool initialState=false) |
| Creates an event. | |
| void | wpi::DestroyEvent (WPI_EventHandle handle) |
| Destroys an event. | |
| void | wpi::SetEvent (WPI_EventHandle handle) |
| Sets an event to signaled state. | |
| void | wpi::ResetEvent (WPI_EventHandle handle) |
| Sets an event to non-signaled state. | |
| WPI_SemaphoreHandle | wpi::CreateSemaphore (int initialCount=0, int maximumCount=INT_MAX) |
| Creates a semaphore. | |
| void | wpi::DestroySemaphore (WPI_SemaphoreHandle handle) |
| Destroys a semaphore. | |
| bool | wpi::ReleaseSemaphore (WPI_SemaphoreHandle handle, int releaseCount=1, int *prevCount=nullptr) |
| Releases N counts of a semaphore. | |
| bool | wpi::WaitForObject (WPI_Handle handle) |
| Waits for an handle to be signaled. | |
| bool | wpi::WaitForObject (WPI_Handle handle, double timeout, bool *timedOut) |
| Waits for an handle to be signaled, with timeout. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| void | wpi::CreateSignalObject (WPI_Handle handle, bool manualReset=false, bool initialState=false) |
| Sets up signaling for an arbitrary handle. | |
| void | wpi::SetSignalObject (WPI_Handle handle) |
| Sets a handle to signaled state. | |
| void | wpi::ResetSignalObject (WPI_Handle handle) |
| Sets a handle to non-signaled state. | |
| void | wpi::DestroySignalObject (WPI_Handle handle) |
| Cleans up signaling for a handle. | |
| WPI_EventHandle | WPI_CreateEvent (int manual_reset, int initial_state) |
| Creates an event. | |
| void | WPI_DestroyEvent (WPI_EventHandle handle) |
| Destroys an event. | |
| void | WPI_SetEvent (WPI_EventHandle handle) |
| Sets an event to signaled state. | |
| void | WPI_ResetEvent (WPI_EventHandle handle) |
| Sets an event to non-signaled state. | |
| WPI_SemaphoreHandle | WPI_CreateSemaphore (int initial_count, int maximum_count) |
| Creates a semaphore. | |
| void | WPI_DestroySemaphore (WPI_SemaphoreHandle handle) |
| Destroys a semaphore. | |
| int | WPI_ReleaseSemaphore (WPI_SemaphoreHandle handle, int release_count, int *prev_count) |
| Releases N counts of a semaphore. | |
| int | WPI_WaitForObject (WPI_Handle handle) |
| Waits for an handle to be signaled. | |
| int | WPI_WaitForObjectTimeout (WPI_Handle handle, double timeout, int *timed_out) |
| Waits for an handle to be signaled, with timeout. | |
| int | WPI_WaitForObjects (const WPI_Handle *handles, int handles_count, WPI_Handle *signaled) |
| Waits for one or more handles to be signaled. | |
| 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. | |
| void | WPI_CreateSignalObject (WPI_Handle handle, int manual_reset, int initial_state) |
| Sets up signaling for an arbitrary handle. | |
| void | WPI_SetSignalObject (WPI_Handle handle) |
| Sets a handle to signaled state. | |
| void | WPI_ResetSignalObject (WPI_Handle handle) |
| Sets a handle to non-signaled state. | |
| void | WPI_DestroySignalObject (WPI_Handle handle) |
| Cleans up signaling for a handle. | |
Variables | |
| constexpr unsigned int | wpi::kInvalidHandle = 0 |
| Constant representing an invalid handle. | |
| constexpr int | wpi::kHandleTypeEvent = 1 |
| Standard types for handles. | |
| constexpr int | wpi::kHandleTypeSemaphore = 2 |
| constexpr int | wpi::kHandleTypeCSBase = 3 |
| constexpr int | wpi::kHandleTypeNTBase = 16 |
| constexpr int | wpi::kHandleTypeHALBase = 48 |
| constexpr int | wpi::kHandleTypeUserBase = 80 |
| 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 semaphore'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) |