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 (time_t timeout)
 Create event handler and timer set to trigger a timeout.
 TimedEvent (timeout_t timeout)
 Create event handler and timer set to trigger a timeout.
 TimedEvent (void)
 Create event handler and timer for timing of events.
void wait (void)
 A simple wait until triggered.
bool wait (timeout_t timeout)
 Wait to be signalled or until timer expires.
 ~TimedEvent ()
 Destroy timer and release pending events.

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.

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@gnutelephony.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:
timeout in milliseconds.
ucommon::TimedEvent::TimedEvent ( time_t  timeout  ) 

Create event handler and timer set to trigger a timeout.

Parameters:
timeout in 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.

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.

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:
timeout to wait from last reset.
Returns:
true if signaled, false if timeout.

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

Generated on 30 Jul 2013 for UCommon by  doxygen 1.6.1