Jump to content

Programming Reference:WaitableEvent Class: Difference between revisions

From BCI2000 Wiki
Mellinger (talk | contribs)
Mellinger (talk | contribs)
Line 17: Line 17:


==See also==
==See also==
[[Programming Reference:OSThread Class]], [[Programming Reference:OSMutex Class]]
[[Programming Reference:Thread Class]]


[[Category:Framework API]][[Category:Development]]
[[Category:Framework API]][[Category:Development]]

Revision as of 15:11, 18 April 2023

Location

BCI2000/src/shared/utils

Synopsis

The WaitableEvent class provides a mechanism to synchronize threads by waiting for another thread to signal the WaitableEvent. The underlying functionality corresponds to a manual-reset event in Windows.

Methods

WaitableEvent()

Events are created in non-signaled state.

~WaitableEvent()

Releases all resources allocated for the event object.

bool Set()

Sets the event to signaled state. When one or more threads are blocked waiting for the event, they are released in random order. As long as the event is in signaled state, threads calling its Wait() function will not be blocked. Returns true when successful, false otherwise.

bool Reset()

Resets the event to non-signaled state. Call Reset() immediately after Wait() to emulate the behavior of a Windows auto-reset event. Returns true when successful, false otherwise.

bool Wait([TimeInterval timeout])

Waits for the event to become signaled. Does nothing when the event is currently in signaled state. When a timeout is specified, waits for the specified number of milliseconds. Returns true when the event is signaled, and false otherwise (error or timeout occurred).

See also

Programming Reference:Thread Class