17 #ifndef HH_SENF_Scheduler_TimerEventProxy_ 18 #define HH_SENF_Scheduler_TimerEventProxy_ 1 21 #include <boost/multi_index_container.hpp> 22 #include <boost/multi_index/ordered_index.hpp> 23 #include <boost/multi_index/member.hpp> 41 template<
typename IdType>
45 typedef boost::function<void(ClockService::clock_type const &, IdType const &)>
Callback;
46 typedef boost::function<void(IdType const & id, senf::ClockService::clock_type const & duration, StatisticsData const & durationsStats)>
DurationExceededCallback;
50 DurationExceededCallback _decb = 0);
58 bool remove(IdType
const & id);
60 std::vector<std::pair<ClockService::clock_type, IdType> >
list()
const;
81 : timeout(_timeout), id(_id), cb(_cb) { }
83 struct ChangeTimeout {
86 void operator()(Entry & entry);
92 typedef boost::multi_index_container<
94 boost::multi_index::indexed_by<
95 boost::multi_index::ordered_non_unique<
96 boost::multi_index::tag<Timeout>,
97 boost::multi_index::member<Entry, ClockService::clock_type, &Entry::timeout>
99 boost::multi_index::ordered_unique<
100 boost::multi_index::tag<Id>,
101 boost::multi_index::member<Entry, IdType, &Entry::id>
105 typedef typename EntrySet_t::template index<Timeout>::type EntrySetByTimeout_t;
106 typedef typename EntrySet_t::template index<Id>::type EntrySetById_t;
108 EntrySet_t entrySet_;
109 EntrySetById_t & entrySetById_;
110 EntrySetByTimeout_t & entrySetByTimeout_;
115 DurationExceededCallback durationExceededCallback_;
config::time_type clock_type
ClockService timer data type.
TimerDispatcher public header.
boost::function< void(IdType const &id, senf::ClockService::clock_type const &duration, StatisticsData const &durationsStats)> DurationExceededCallback
boost::function< void(ClockService::clock_type const &, IdType const &)> Callback
void clear()
Clears all pending timer events.
StatisticsData callbackDurationStats()
Returns and clears the timeInCallback statistics.
TimerEventProxy(std::string const &description="", senf::ClockService::clock_type const &callbackDurationWarningThreshold=senf::ClockService::clock_type(0), DurationExceededCallback _decb=0)
Instantiate a TimerEventProxy.
std::vector< std::pair< ClockService::clock_type, IdType > > list() const
Returns a vector of all active timers with timeout and id.
ClockService public header.
void add(ClockService::clock_type const &timeout, IdType const &id, Callback cb)
Add new deadline timer.
unsigned numEvents() const
Returns the number of pending timer events.
ClockService::clock_type timeout(IdType const &id) const
Returns timeout for given id.