MEL
Microthread & Execution library
mel::core::Event Class Reference

#include <Event.h>

Public Types

enum  EWaitCode { EVENT_WAIT_OK , EVENT_WAIT_TIMEOUT , EVENT_WAIT_ERROR }
 Wait result codes. More...
 

Public Member Functions

 Event (bool autoRelease=true, bool signaled=false)
 
void set ()
 
EWaitCode wait (unsigned int msecs=EVENT_WAIT_INFINITE) const
 
void reset ()
 

Detailed Description

Platform-independent Event implementation. Can be used in multi-threaded scenarios to create simple semaphore-like locks on which clients can wait and notify in order to synchronize execution flows.

Member Enumeration Documentation

◆ EWaitCode

Wait result codes.

Enumerator
EVENT_WAIT_OK 

wait was ok

EVENT_WAIT_TIMEOUT 

time out while waiting

EVENT_WAIT_ERROR 

unknown error

Constructor & Destructor Documentation

◆ Event()

mel::core::Event::Event ( bool  autoRelease = true,
bool  signaled = false 
)

Creates a new event.

Parameters
autoReleaseflag indicating if the new vent should be auto-reset whenever a wait operation terminates (the default value is true)
signaledflag indicating the initial status of the event. If set to true, the event will be created as "signaled" meaning the next wait operation will return immediately.

Member Function Documentation

◆ reset()

void mel::core::Event::reset ( )

Resets the event, so any further calls to Event::wait will force a lock on the calling thread.

See also
wait, set

◆ set()

void mel::core::Event::set ( )

Sets the event. If there were more than one thread locked on an Event::wait call, only one of them will be unlocked. If there were no threads waiting, then the next one calling Event:wait won't be locked.

See also
wait

◆ wait()

EWaitCode mel::core::Event::wait ( unsigned int  msecs = EVENT_WAIT_INFINITE) const

Wait for event. If the event was not yet set, the calling thread will be locked until the event is set.

Parameters
[in]msecsmilliseconds to wait for.
Returns
return code.
See also
set

The documentation for this class was generated from the following file: