-/* $Id$
-
-This file is part of libmspcore
-Copyright © 2006, 2009 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#include <algorithm>
#include "timer.h"
#include "utils.h"
Timer::Slot &Timer::add(const TimeDelta &td)
{
- Slot *s=new Slot(td);
+ Slot *s = new Slot(td);
mutex.lock();
slots.push_back(s);
push_heap(slots.begin(), slots.end());
Timer::Slot &Timer::add(const TimeStamp &ts)
{
- Slot *s=new Slot(ts);
+ Slot *s = new Slot(ts);
{
MutexLock l(mutex);
slots.push_back(s);
void Timer::tick(bool block)
{
- Slot *next=0;
+ Slot *next = 0;
{
MutexLock l(mutex);
while(1)
return;
}
- next=slots.begin()->slot;
- const TimeStamp &stamp=next->get_timeout();
- const TimeStamp t=now();
+ next = slots.begin()->slot;
+ const TimeStamp &stamp = next->get_timeout();
+ const TimeStamp t = now();
if(stamp<=t)
break;
else if(block)
{
if(!interval)
return false;
- timeout+=interval;
+ timeout += interval;
return true;
}