12 for(vector<SlotProxy>::iterator i=slots.begin(); i!=slots.end(); ++i)
16 Timer::Slot &Timer::add(const TimeDelta &td)
18 Slot *s = new Slot(td);
21 push_heap(slots.begin(), slots.end());
27 Timer::Slot &Timer::add(const TimeStamp &ts)
29 Slot *s = new Slot(ts);
33 push_heap(slots.begin(), slots.end());
39 void Timer::cancel(Slot &slot)
42 for(vector<SlotProxy>::iterator i=slots.begin(); i!=slots.end(); ++i)
47 make_heap(slots.begin(), slots.end());
52 void Timer::tick(bool block)
67 next = slots.begin()->slot;
68 const TimeStamp &stamp = next->get_timeout();
69 const TimeStamp t = now();
78 pop_heap(slots.begin(), slots.end());
84 if(next->signal_timeout.emit() && next->increment())
87 slots.push_back(next);
88 push_heap(slots.begin(), slots.end());
100 TimeStamp Timer::get_next_timeout() const
104 return slots.begin()->slot->get_timeout();
108 Timer::Slot::Slot(const TimeDelta &td):
110 timeout(now()+interval)
113 Timer::Slot::Slot(const TimeStamp &ts):
117 bool Timer::Slot::increment()
126 Timer::SlotProxy::SlotProxy(Slot *s):
130 bool Timer::SlotProxy::operator<(const SlotProxy &sp) const
132 return slot->get_timeout()>sp.slot->get_timeout();