Programming Reference:OSEvent Class

From BCI2000 Wiki
Jump to: navigation, search

Location

BCI2000/src/shared/utils

Synopsis

The OSEvent class provides a wrapper for OS-dependent synchronization functionality. The underlying functionality corresponds to a manual-reset event in Windows; on Unix systems, equivalent behavior is achieved using a POSIX threads condition variable.

Methods

OSEvent()

Events are created in non-signaled state.

~OSEvent()

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([number 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:OSThread Class, Programming Reference:OSMutex Class