Open Lighting Architecture  0.9.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Attributes | List of all members
ola::io::TimeoutManager Class Reference

Detailed Description

Manages timer events.

The TimeoutManager allows Callbacks to trigger at some point in the future. Callbacks can be invoked once, or periodically.

Classes

class  Event
struct  ltevent
class  RepeatingEvent
class  SingleEvent

Public Member Functions

 TimeoutManager (ola::ExportMap *export_map, Clock *clock)
 Create a new TimeoutManager.
ola::thread::timeout_id RegisterRepeatingTimeout (const ola::TimeInterval &interval, ola::Callback0< bool > *closure)
 Register a repeating timeout. Returning false from the Callback will cancel this timer.
ola::thread::timeout_id RegisterSingleTimeout (const ola::TimeInterval &interval, ola::SingleUseCallback0< void > *closure)
 Register a single use timeout function.
void CancelTimeout (ola::thread::timeout_id id)
 Cancel a timeout.
bool EventsPending () const
 Check if there are any events in the queue. Events remain in the queue even if they have been cancelled.
TimeInterval ExecuteTimeouts (TimeStamp *now)
 Execute any expired timeouts.

Static Public Attributes

static const char K_TIMER_VAR [] = "ss-timers"

Constructor & Destructor Documentation

ola::io::TimeoutManager::TimeoutManager ( ola::ExportMap export_map,
Clock clock 
)

Create a new TimeoutManager.

Parameters
export_mapan ExportMap to update
clockthe Clock to use.

Member Function Documentation

void ola::io::TimeoutManager::CancelTimeout ( ola::thread::timeout_id  id)

Cancel a timeout.

Parameters
idthe id of the timeout
bool ola::io::TimeoutManager::EventsPending ( ) const
inline

Check if there are any events in the queue. Events remain in the queue even if they have been cancelled.

Returns
true if there are events pending, false otherwise.
TimeInterval ola::io::TimeoutManager::ExecuteTimeouts ( TimeStamp now)

Execute any expired timeouts.

Parameters
[in,out]nowthe current time, set to the last time events were checked.
Returns
the time until the next event.
timeout_id ola::io::TimeoutManager::RegisterRepeatingTimeout ( const ola::TimeInterval interval,
ola::Callback0< bool > *  closure 
)

Register a repeating timeout. Returning false from the Callback will cancel this timer.

Parameters
intervalthe delay before the closure will be run.
closurethe closure to invoke when the event triggers. Ownership is given up to the select server - make sure nothing else uses this Callback.
Returns
the identifier for this timeout, this can be used to remove it later.
timeout_id ola::io::TimeoutManager::RegisterSingleTimeout ( const ola::TimeInterval interval,
ola::SingleUseCallback0< void > *  closure 
)

Register a single use timeout function.

Parameters
intervalthe delay between function calls
closurethe Callback to invoke when the event triggers
Returns
the identifier for this timeout, this can be used to remove it later.

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