8#include <initializer_list>
43 bool initialState =
false);
78 int maximumCount = INT_MAX);
98 int* prevCount =
nullptr);
133 std::span<WPI_Handle> signaled);
147 std::initializer_list<WPI_Handle> handles, std::span<WPI_Handle> signaled) {
148 return WaitForObjects(std::span{handles.begin(), handles.size()}, signaled);
166 std::span<WPI_Handle> signaled,
167 double timeout,
bool* timedOut);
183 std::initializer_list<WPI_Handle> handles, std::span<WPI_Handle> signaled,
184 double timeout,
bool* timedOut) {
185 return WaitForObjects(std::span{handles.begin(), handles.size()}, signaled,
198 bool initialState =
false);
239 explicit Event(
bool manualReset =
false,
bool initialState =
false)
240 : m_handle{
CreateEvent(manualReset, initialState)} {}
250 Event(
Event&& rhs) : m_handle{rhs.m_handle} { rhs.m_handle = 0; }
255 m_handle = rhs.m_handle;
304 explicit Semaphore(
int initialCount = 0,
int maximumCount = INT_MAX)
320 m_handle = rhs.m_handle;
348 bool Release(
int releaseCount = 1,
int* prevCount =
nullptr) {
373 bool initialState =
false)
393 m_handle = rhs.m_handle;
403 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:241
Event(Event &&rhs)
Definition Synchronization.hpp:250
void Reset()
Sets the event to non-signaled state.
Definition Synchronization.hpp:282
Event & operator=(const Event &)=delete
WPI_EventHandle GetHandle() const
Gets the event handle (e.g.
Definition Synchronization.hpp:272
void Set()
Sets the event to signaled state.
Definition Synchronization.hpp:277
Event(const Event &)=delete
Event & operator=(Event &&rhs)
Definition Synchronization.hpp:251
Event(bool manualReset=false, bool initialState=false)
Constructor.
Definition Synchronization.hpp:239
Semaphore(int initialCount=0, int maximumCount=INT_MAX)
Constructor.
Definition Synchronization.hpp:304
Semaphore(const Semaphore &)=delete
bool Release(int releaseCount=1, int *prevCount=nullptr)
Releases N counts of the semaphore.
Definition Synchronization.hpp:348
Semaphore & operator=(const Semaphore &)=delete
Semaphore(Semaphore &&rhs)
Definition Synchronization.hpp:315
~Semaphore()
Definition Synchronization.hpp:306
WPI_SemaphoreHandle GetHandle() const
Gets the semaphore handle (e.g.
Definition Synchronization.hpp:337
Semaphore & operator=(Semaphore &&rhs)
Definition Synchronization.hpp:316
SignalObject(T handle=0, bool manualReset=false, bool initialState=false)
Constructor.
Definition Synchronization.hpp:372
SignalObject & operator=(SignalObject &&rhs)
Definition Synchronization.hpp:389
SignalObject & operator=(const SignalObject &)=delete
void Set()
Sets the handle to signaled state.
Definition Synchronization.hpp:415
SignalObject(SignalObject &&rhs)
Definition Synchronization.hpp:386
~SignalObject()
Definition Synchronization.hpp:377
T GetHandle() const
Gets the handle (e.g.
Definition Synchronization.hpp:410
SignalObject(const SignalObject &)=delete
void Reset()
Sets the handle to non-signaled state.
Definition Synchronization.hpp:420
Definition raw_os_ostream.hpp:19
void CreateSignalObject(WPI_Handle handle, bool manualReset=false, bool initialState=false)
Sets up signaling for an arbitrary handle.
constexpr int kHandleTypeNTBase
Definition Synchronization.hpp:25
void ResetSignalObject(WPI_Handle handle)
Sets a handle to non-signaled state.
bool WaitForObject(WPI_Handle handle)
Waits for an handle to be signaled.
void SetSignalObject(WPI_Handle handle)
Sets a handle to signaled state.
WPI_SemaphoreHandle CreateSemaphore(int initialCount=0, int maximumCount=INT_MAX)
Creates a semaphore.
constexpr unsigned int kInvalidHandle
Constant representing an invalid handle.
Definition Synchronization.hpp:16
void DestroySemaphore(WPI_SemaphoreHandle handle)
Destroys a semaphore.
void SetEvent(WPI_EventHandle handle)
Sets an event to signaled state.
void DestroySignalObject(WPI_Handle handle)
Cleans up signaling for a handle.
void DestroyEvent(WPI_EventHandle handle)
Destroys an event.
bool ReleaseSemaphore(WPI_SemaphoreHandle handle, int releaseCount=1, int *prevCount=nullptr)
Releases N counts of a semaphore.
constexpr int kHandleTypeSemaphore
Definition Synchronization.hpp:23
constexpr int kHandleTypeCSBase
Definition Synchronization.hpp:24
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 kHandleTypeUserBase
Definition Synchronization.hpp:27
constexpr int kHandleTypeHALBase
Definition Synchronization.hpp:26
constexpr int kHandleTypeEvent
Standard types for handles.
Definition Synchronization.hpp:22
WPI_EventHandle CreateEvent(bool manualReset=false, bool initialState=false)
Creates an event.
void ResetEvent(WPI_EventHandle handle)
Sets an event to non-signaled state.