17 for(vector<SlotProxy>::iterator i=slots.begin(); i!=slots.end(); ++i)
21 Timer::Slot &Timer::add(const TimeDelta &td)
23 Slot *s = new Slot(td);
26 push_heap(slots.begin(), slots.end());
32 Timer::Slot &Timer::add(const TimeStamp &ts)
34 Slot *s = new Slot(ts);
37 push_heap(slots.begin(), slots.end());
43 void Timer::cancel(Slot &slot)
46 for(vector<SlotProxy>::iterator i=slots.begin(); i!=slots.end(); ++i)
51 make_heap(slots.begin(), slots.end());
56 void Timer::tick(bool block)
76 next = slots.begin()->slot;
77 const TimeStamp &stamp = next->get_timeout();
78 const TimeStamp t = now();
92 pop_heap(slots.begin(), slots.end());
98 if(next->signal_timeout.emit() && next->increment())
101 slots.push_back(next);
102 push_heap(slots.begin(), slots.end());
114 TimeStamp Timer::get_next_timeout() const
118 return slots.begin()->slot->get_timeout();
122 Timer::Slot::Slot(const TimeDelta &td):
124 timeout(now()+interval)
127 Timer::Slot::Slot(const TimeStamp &ts):
131 bool Timer::Slot::increment()
140 Timer::SlotProxy::SlotProxy(Slot *s):
144 bool Timer::SlotProxy::operator<(const SlotProxy &sp) const
146 return slot->get_timeout()>sp.slot->get_timeout();