8#include <initializer_list>
77 int maximumCount = INT_MAX);
97 int* prevCount =
nullptr);
132 std::span<WPI_Handle> signaled);
146 std::initializer_list<WPI_Handle> handles, std::span<WPI_Handle> signaled) {
147 return WaitForObjects(std::span{handles.begin(), handles.size()}, signaled);
165 std::span<WPI_Handle> signaled,
166 double timeout,
bool* timedOut);
182 std::initializer_list<WPI_Handle> handles, std::span<WPI_Handle> signaled,
183 double timeout,
bool* timedOut) {
184 return WaitForObjects(std::span{handles.begin(), handles.size()}, signaled,
197 bool initialState =
false);
238 explicit Event(
bool manualReset =
false,
bool initialState =
false)
239 : m_handle{
MakeEvent(manualReset, initialState)} {}
249 Event(
Event&& rhs) : m_handle{rhs.m_handle} { rhs.m_handle = 0; }
254 m_handle = rhs.m_handle;
303 explicit Semaphore(
int initialCount = 0,
int maximumCount = INT_MAX)
319 m_handle = rhs.m_handle;
347 bool Release(
int releaseCount = 1,
int* prevCount =
nullptr) {
372 bool initialState =
false)
392 m_handle = rhs.m_handle;
402 operator T()
const {
return m_handle; }
WPI_Handle WPI_SemaphoreHandle
A semaphore handle.
Definition Synchronization.h:21
unsigned int WPI_Handle
Generic handle for all WPI handle-based interfaces.
Definition Synchronization.h:15
WPI_Handle WPI_EventHandle
An event handle.
Definition Synchronization.h:18
~Event()
Definition Synchronization.hpp:240
Event(Event &&rhs)
Definition Synchronization.hpp:249
void Reset()
Sets the event to non-signaled state.
Definition Synchronization.hpp:281
Event & operator=(const Event &)=delete
WPI_EventHandle GetHandle() const
Gets the event handle (e.g.
Definition Synchronization.hpp:271
void Set()
Sets the event to signaled state.
Definition Synchronization.hpp:276
Event(const Event &)=delete
Event & operator=(Event &&rhs)
Definition Synchronization.hpp:250
Event(bool manualReset=false, bool initialState=false)
Constructor.
Definition Synchronization.hpp:238
Semaphore(int initialCount=0, int maximumCount=INT_MAX)
Constructor.
Definition Synchronization.hpp:303
Semaphore(const Semaphore &)=delete
bool Release(int releaseCount=1, int *prevCount=nullptr)
Releases N counts of the semaphore.
Definition Synchronization.hpp:347
Semaphore & operator=(const Semaphore &)=delete
Semaphore(Semaphore &&rhs)
Definition Synchronization.hpp:314
~Semaphore()
Definition Synchronization.hpp:305
WPI_SemaphoreHandle GetHandle() const
Gets the semaphore handle (e.g.
Definition Synchronization.hpp:336
Semaphore & operator=(Semaphore &&rhs)
Definition Synchronization.hpp:315
SignalObject(T handle=0, bool manualReset=false, bool initialState=false)
Constructor.
Definition Synchronization.hpp:371
SignalObject & operator=(SignalObject &&rhs)
Definition Synchronization.hpp:388
SignalObject & operator=(const SignalObject &)=delete
void Set()
Sets the handle to signaled state.
Definition Synchronization.hpp:414
SignalObject(SignalObject &&rhs)
Definition Synchronization.hpp:385
~SignalObject()
Definition Synchronization.hpp:376
T GetHandle() const
Gets the handle (e.g.
Definition Synchronization.hpp:409
SignalObject(const SignalObject &)=delete
void Reset()
Sets the handle to non-signaled state.
Definition Synchronization.hpp:419
Definition raw_os_ostream.hpp:19
void CreateSignalObject(WPI_Handle handle, bool manualReset=false, bool initialState=false)
Sets up signaling for an arbitrary handle.
void ResetSignalObject(WPI_Handle handle)
Sets a handle to non-signaled state.
constexpr int HANDLE_TYPE_SEMAPHORE
Definition Synchronization.hpp:23
bool WaitForObject(WPI_Handle handle)
Waits for an handle to be signaled.
void SetSignalObject(WPI_Handle handle)
Sets a handle to signaled state.
void DestroySemaphore(WPI_SemaphoreHandle handle)
Destroys a semaphore.
void SetEvent(WPI_EventHandle handle)
Sets an event to signaled state.
constexpr int HANDLE_TYPE_USER_BASE
Definition Synchronization.hpp:27
WPI_SemaphoreHandle MakeSemaphore(int initialCount=0, int maximumCount=INT_MAX)
Creates a semaphore.
constexpr int HANDLE_TYPE_HAL_BASE
Definition Synchronization.hpp:26
void DestroySignalObject(WPI_Handle handle)
Cleans up signaling for a handle.
void DestroyEvent(WPI_EventHandle handle)
Destroys an event.
WPI_EventHandle MakeEvent(bool manualReset=false, bool initialState=false)
Creates an event.
bool ReleaseSemaphore(WPI_SemaphoreHandle handle, int releaseCount=1, int *prevCount=nullptr)
Releases N counts of a semaphore.
constexpr unsigned int INVALID_HANDLE
Constant representing an invalid handle.
Definition Synchronization.hpp:16
std::span< WPI_Handle > WaitForObjects(std::span< const WPI_Handle > handles, std::span< WPI_Handle > signaled)
Waits for one or more handles to be signaled.
constexpr int HANDLE_TYPE_NT_BASE
Definition Synchronization.hpp:25
constexpr int HANDLE_TYPE_CS_BASE
Definition Synchronization.hpp:24
void ResetEvent(WPI_EventHandle handle)
Sets an event to non-signaled state.
constexpr int HANDLE_TYPE_EVENT
Standard types for handles.
Definition Synchronization.hpp:22