#include <vector>
#include <sigc++/sigc++.h>
#include <msp/core/mutex.h>
+#include <msp/core/noncopyable.h>
#include <msp/core/semaphore.h>
#include "timedelta.h"
#include "timestamp.h"
This class is thread-safe, to allow running timers in a separate thread.
*/
-class Timer
+class Timer: private NonCopyable
{
public:
class Slot
private:
struct SlotProxy
{
- Slot *slot;
+ Slot *slot = 0;
SlotProxy(Slot *);
bool operator<(const SlotProxy &) const;
std::vector<SlotProxy> slots;
Semaphore sem;
Mutex mutex;
- bool blocking;
+ bool blocking = false;
public:
Timer();
/** Cancels a previously added timer. */
void cancel(Slot &);
- /** Deprecated. Use one of the other overloads. */
- void tick(bool block);
-
/** Waits until a timer expires, then executes it. If no timers have been
set, blocks until one is added from another thread. */
void tick();