UCommon
Public Member Functions | Static Public Member Functions | Protected Member Functions
ucommon::TimedEvent Class Reference

Event notification to manage scheduled realtime threads. More...

#include <thread.h>

Inheritance diagram for ucommon::TimedEvent:
Inheritance graph
[legend]
Collaboration diagram for ucommon::TimedEvent:
Collaboration graph
[legend]

Public Member Functions

void reset (void)
 Reset triggered conditional.
void signal (void)
 Signal pending event.
 TimedEvent (void)
 Create event handler and timer for timing of events.
 TimedEvent (timeout_t timeout)
 Create event handler and timer set to trigger a timeout.
 TimedEvent (time_t timeout)
 Create event handler and timer set to trigger a timeout.
bool wait (timeout_t timeout)
 Wait to be signalled or until timer expires.
void wait (void)
 A simple wait until triggered.
 ~TimedEvent ()
 Destroy timer and release pending events.
- Public Member Functions inherited from ucommon::Timer
void clear (void)
 Clear pending timer, has no value.
timeout_t get (void)
 Get remaining time until the timer expires.
bool isExpired (void)
 Check if timer expired.
bool isUpdated (void)
 Check if timer has been updated since last check.
 operator bool ()
 Check if timer expired for is() expression.
bool operator! ()
 Check if timer has expired.
bool operator!= (Timer &timer)
 Compare timers if not same timeout.
timeout_t operator* ()
 Get remaining time until timer expires by reference.
Timeroperator+= (time_t expire)
 Adjust timer expiration.
Timeroperator+= (timeout_t expire)
 Adjust timer expiration.
timeout_t operator- (Timer &timer)
 Compute difference between two timers.
Timeroperator-= (time_t expire)
 Adjust timer expiration.
Timeroperator-= (timeout_t expire)
 Adjust timer expiration.
bool operator< (Timer &timer)
 Compare timers if earlier timeout than another timer.
bool operator<= (Timer &timer)
 Compare timers if earlier than or equal to another timer.
Timeroperator= (time_t expire)
 Set timer expiration.
Timeroperator= (timeout_t expire)
 Set timer expiration.
bool operator== (Timer &timer)
 Compare timers if same timeout.
bool operator> (Timer &timer)
 Compare timers if later timeout than another timer.
bool operator>= (Timer &timer)
 Compare timers if later than or equal to another timer.
void set (timeout_t expire)
 Set the timer to expire.
void set (time_t expire)
 Set the timer to expire.
void set (void)
 Set (update) the timer with current time.
 Timer ()
 Construct an untriggered timer set to the time of creation.
 Timer (timeout_t offset)
 Construct a triggered timer that expires at specified offset.
 Timer (time_t offset)
 Construct a triggered timer that expires at specified offset.
 Timer (Timer &copy)
 Construct a timer from a copy of another timer.

Static Public Member Functions

static void reset (TimedEvent &timed)
 Event function to reset timer for external type.
static void signal (TimedEvent &timed)
 Event function for external type.
static bool wait (TimedEvent &timed, timeout_t timeout)
 Event function for external type for waiting.
- Static Public Member Functions inherited from ucommon::Timer
static void sync (Timer &timer)
 Sleep current thread until the specified timer expires.
static tick_t ticks (void)
 Get timer ticks since uuid epoch.

Protected Member Functions

void lock (void)
 Lock the object for wait or to manipulate derived data.
void release (void)
 Release the object lock after waiting.
bool sync (void)
 Wait while locked.

Additional Inherited Members

- Public Types inherited from ucommon::Timer
typedef uint64_t tick_t
- Static Public Attributes inherited from ucommon::Timer
static timeout_t inf
 A value to use for infinite time.
static time_t reset
 A value to use when resetting.

Detailed Description

Event notification to manage scheduled realtime threads.

The timer is advanced to sleep threads which then wakeup either when the timer has expired or they are notified through the signal handler. This can be used to schedule and signal one-time completion handlers or for time synchronized events signaled by an asychrononous I/O or event source.

Author:
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 365 of file thread.h.


Constructor & Destructor Documentation

ucommon::TimedEvent::TimedEvent ( timeout_t  timeout)

Create event handler and timer set to trigger a timeout.

Parameters:
timeoutin milliseconds.
ucommon::TimedEvent::TimedEvent ( time_t  timeout)

Create event handler and timer set to trigger a timeout.

Parameters:
timeoutin seconds.

Member Function Documentation

void ucommon::TimedEvent::lock ( void  )
protected

Lock the object for wait or to manipulate derived data.

This is relevant to manipulations in a derived class.

void ucommon::TimedEvent::release ( void  )
protected

Release the object lock after waiting.

This is relevent to manipulations in a derived class.

static void ucommon::TimedEvent::reset ( TimedEvent timed)
inlinestatic

Event function to reset timer for external type.

Parameters:
timedevent object to reset.

Definition at line 457 of file thread.h.

Here is the call graph for this function:

void ucommon::TimedEvent::signal ( void  )

Signal pending event.

Object may be locked or unlocked. The signalling thread may choose to lock and check a condition in a derived class before signalling.

static void ucommon::TimedEvent::signal ( TimedEvent timed)
inlinestatic

Event function for external type.

Parameters:
timedevent object to signal.

Definition at line 450 of file thread.h.

Here is the call graph for this function:

bool ucommon::TimedEvent::sync ( void  )
protected

Wait while locked.

This can be used in more complex derived objects where we are concerned with synchronized access between the signaling and event thread. This can be used in place of wait, but lock and release methods must be used around it.

Returns:
true if time expired.
bool ucommon::TimedEvent::wait ( timeout_t  timeout)

Wait to be signalled or until timer expires.

This is a wrapper for expire for simple completion events.

Parameters:
timeoutto wait from last reset.
Returns:
true if signaled, false if timeout.
static bool ucommon::TimedEvent::wait ( TimedEvent timed,
timeout_t  timeout 
)
inlinestatic

Event function for external type for waiting.

Parameters:
timedevent object to wait on.
timeoutto wait from last reset.
Returns:
true if signalled, false if timeout.

Definition at line 466 of file thread.h.

Here is the call graph for this function:


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