]> git.tdb.fi Git - libs/core.git/blobdiff - source/time/timer.cpp
Add move semantics to Variant
[libs/core.git] / source / time / timer.cpp
index 9411facc5d08bf667d73373e03eba43d0acd350c..eda782e0d92c5bf82c00418584e12917d03fa673 100644 (file)
@@ -9,8 +9,7 @@ namespace Msp {
 namespace Time {
 
 Timer::Timer():
-       sem(1),
-       blocking(false)
+       sem(1)
 { }
 
 Timer::~Timer()
@@ -23,7 +22,7 @@ Timer::Slot &Timer::add(const TimeDelta &td)
 {
        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();
@@ -34,7 +33,7 @@ Timer::Slot &Timer::add(const TimeStamp &ts)
 {
        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();
@@ -72,7 +71,7 @@ void Timer::do_tick(const TimeDelta &timeout)
        if(timeout>=zero)
                deadline = now()+timeout;
 
-       Slot *next = 0;
+       Slot *next = nullptr;
        {
                MutexLock l(mutex);
                while(1)
@@ -114,7 +113,7 @@ void Timer::do_tick(const TimeDelta &timeout)
                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
@@ -153,10 +152,6 @@ bool Timer::Slot::increment()
 }
 
 
-Timer::SlotProxy::SlotProxy(Slot *s):
-       slot(s)
-{ }
-
 bool Timer::SlotProxy::operator<(const SlotProxy &sp) const
 {
        return slot->get_timeout()>sp.slot->get_timeout();