Programming Reference:WaitableEvent Class: Difference between revisions
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
==Location== | ==Location== | ||
<tt>BCI2000/src/shared/utils</tt> | <tt>BCI2000/src/shared/utils/Lib</tt> | ||
==Synopsis== | ==Synopsis== | ||
| Line 14: | Line 14: | ||
Resets the event to non-signaled state. Call <tt>Reset()</tt> immediately after <tt>Wait()</tt> to emulate the behavior of a Windows auto-reset event. Returns true when successful, false otherwise. | Resets the event to non-signaled state. Call <tt>Reset()</tt> immediately after <tt>Wait()</tt> to emulate the behavior of a Windows auto-reset event. Returns true when successful, false otherwise. | ||
===bool Wait([TimeInterval timeout])=== | ===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 | Waits for the event to become signaled. Does nothing when the event is currently in signaled state. When a timeout is specified, waits no longer than the specified amount of time. Returns true when the event is signaled, and false otherwise (error or timeout occurred). | ||
==See also== | ==See also== | ||
[[Programming Reference: | [[Programming Reference:Thread Class]] | ||
[[Category:Framework API]][[Category:Development]] | [[Category:Framework API]][[Category:Development]] | ||
Latest revision as of 15:13, 18 April 2023
Location
BCI2000/src/shared/utils/Lib
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 no longer than the specified amount of time. Returns true when the event is signaled, and false otherwise (error or timeout occurred).