summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Network')
-rw-r--r--Swiften/Network/BoostTimer.cpp2
-rw-r--r--Swiften/Network/Timer.h17
2 files changed, 17 insertions, 2 deletions
diff --git a/Swiften/Network/BoostTimer.cpp b/Swiften/Network/BoostTimer.cpp
index 65e7712..ab6fbe0 100644
--- a/Swiften/Network/BoostTimer.cpp
+++ b/Swiften/Network/BoostTimer.cpp
@@ -32,8 +32,6 @@ void BoostTimer::handleTimerTick(const boost::system::error_code& error) {
}
else {
eventLoop->postEvent(boost::bind(boost::ref(onTick)), shared_from_this());
- timer.expires_from_now(boost::posix_time::milliseconds(timeout));
- timer.async_wait(boost::bind(&BoostTimer::handleTimerTick, shared_from_this(), boost::asio::placeholders::error));
}
}
diff --git a/Swiften/Network/Timer.h b/Swiften/Network/Timer.h
index 278a8fb..d44a00d 100644
--- a/Swiften/Network/Timer.h
+++ b/Swiften/Network/Timer.h
@@ -9,15 +9,32 @@
#include "Swiften/Base/boost_bsignals.h"
namespace Swift {
+ /**
+ * A class for triggering an event after a given period.
+ */
class Timer {
public:
typedef boost::shared_ptr<Timer> ref;
virtual ~Timer();
+ /**
+ * Starts the timer.
+ *
+ * After the given period, onTick() will be called.
+ */
virtual void start() = 0;
+
+ /**
+ * Cancels the timer.
+ *
+ * If the timer was started, onTick() will no longer be called.
+ */
virtual void stop() = 0;
+ /**
+ * Emitted when the timer expires.
+ */
boost::signal<void ()> onTick;
};
}