Deadline timer proxy. More...
#include <senf/Scheduler/TimerEventProxy.hh>
Public Types | |
typedef boost::function< void(ClockService::clock_type const &, IdType const &)> | Callback |
typedef boost::function< void(IdType const &id, senf::ClockService::clock_type const &duration, StatisticsData const &durationsStats)> | DurationExceededCallback |
Public Member Functions | |
TimerEventProxy (std::string const &description="", senf::ClockService::clock_type const &callbackDurationWarningThreshold=senf::ClockService::clock_type(0), DurationExceededCallback _decb=0) | |
Instantiate a TimerEventProxy. More... | |
void | add (ClockService::clock_type const &timeout, IdType const &id, Callback cb) |
Add new deadline timer. More... | |
bool | remove (IdType const &id) |
Remove timer by given id. More... | |
std::vector< std::pair< ClockService::clock_type, IdType > > | list () const |
Returns a vector of all active timers with timeout and id. More... | |
ClockService::clock_type | timeout (IdType const &id) const |
Returns timeout for given id. More... | |
unsigned | numEvents () const |
Returns the number of pending timer events. More... | |
void | clear () |
Clears all pending timer events. More... | |
StatisticsData | callbackDurationStats () |
Returns and clears the timeInCallback statistics. More... | |
Deadline timer proxy.
The TimerEventProxy is meant to host long term deadline timers to reduce the load of the Scheduler with a huge count of TimerEvent items. It registers deadline timer callbacks which will be called when the timer expires.
The functionality is based on one TimerEvent instance per TimerEventProxy instance and could host a big count of timers.
Definition at line 42 of file TimerEventProxy.hh.
typedef boost::function<void(ClockService::clock_type const &, IdType const &)> senf::scheduler::TimerEventProxy< IdType >::Callback |
Definition at line 45 of file TimerEventProxy.hh.
typedef boost::function<void(IdType const & id, senf::ClockService::clock_type const & duration, StatisticsData const & durationsStats)> senf::scheduler::TimerEventProxy< IdType >::DurationExceededCallback |
Definition at line 46 of file TimerEventProxy.hh.
senf::scheduler::TimerEventProxy< IdType >::TimerEventProxy | ( | std::string const & | description = "" , |
senf::ClockService::clock_type const & | callbackDurationWarningThreshold = senf::ClockService::clock_type(0) , |
||
DurationExceededCallback | _decb = 0 |
||
) |
Instantiate a TimerEventProxy.
[in] | description | Descriptive name (purely informational) |
[in] | If | !=0, the max. time a callback may take for execuion before a warning is generated |
void senf::scheduler::TimerEventProxy< IdType >::add | ( | ClockService::clock_type const & | timeout, |
IdType const & | id, | ||
Callback | cb | ||
) |
Add new deadline timer.
StatisticsData senf::scheduler::TimerEventProxy< IdType >::callbackDurationStats | ( | ) |
Returns and clears the timeInCallback statistics.
void senf::scheduler::TimerEventProxy< IdType >::clear | ( | ) |
Clears all pending timer events.
std::vector<std::pair<ClockService::clock_type, IdType> > senf::scheduler::TimerEventProxy< IdType >::list | ( | ) | const |
Returns a vector of all active timers with timeout and id.
unsigned senf::scheduler::TimerEventProxy< IdType >::numEvents | ( | ) | const |
Returns the number of pending timer events.
bool senf::scheduler::TimerEventProxy< IdType >::remove | ( | IdType const & | id | ) |
Remove timer by given id.
ClockService::clock_type senf::scheduler::TimerEventProxy< IdType >::timeout | ( | IdType const & | id | ) | const |
Returns timeout for given id.
if no timer for this id is registered 0 is returned.