namespace Time {
Timer::Timer():
- sem(1),
- blocking(false)
+ sem(1)
{ }
Timer::~Timer()
{
Slot *s = new Slot(td);
MutexLock l(mutex);
- slots.push_back(s);
+ slots.push_back({ s });
push_heap(slots.begin(), slots.end());
if(blocking)
sem.signal();
{
Slot *s = new Slot(ts);
MutexLock l(mutex);
- slots.push_back(s);
+ slots.push_back({ s });
push_heap(slots.begin(), slots.end());
if(blocking)
sem.signal();
if(timeout>=zero)
deadline = now()+timeout;
- Slot *next = 0;
+ Slot *next = nullptr;
{
MutexLock l(mutex);
while(1)
if(next->signal_timeout.emit() && next->increment())
{
MutexLock l(mutex);
- slots.push_back(next);
+ slots.push_back({ next });
push_heap(slots.begin(), slots.end());
}
else
}
-Timer::SlotProxy::SlotProxy(Slot *s):
- slot(s)
-{ }
-
bool Timer::SlotProxy::operator<(const SlotProxy &sp) const
{
return slot->get_timeout()>sp.slot->get_timeout();