summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-12 19:48:32 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-12 20:41:59 (GMT)
commit8231ecc07c1c7d5e260a2795b0660de157501850 (patch)
tree935baa855914d632086fcac5f26330c2f0261216 /Swiften/Network/Timer.cpp
parent48bb7441f913144d6a20687ff79264e4631156f0 (diff)
downloadswift-contrib-8231ecc07c1c7d5e260a2795b0660de157501850.zip
swift-contrib-8231ecc07c1c7d5e260a2795b0660de157501850.tar.bz2
Created a TimerFactory, and abstracted Timer.
Diffstat (limited to 'Swiften/Network/Timer.cpp')
-rw-r--r--Swiften/Network/Timer.cpp29
1 files changed, 0 insertions, 29 deletions
diff --git a/Swiften/Network/Timer.cpp b/Swiften/Network/Timer.cpp
index d6120e3..a8d17c3 100644
--- a/Swiften/Network/Timer.cpp
+++ b/Swiften/Network/Timer.cpp
@@ -1,37 +1,8 @@
#include "Swiften/Network/Timer.h"
-#include <boost/date_time/posix_time/posix_time.hpp>
-
-#include "Swiften/EventLoop/MainEventLoop.h"
-
namespace Swift {
-Timer::Timer(int milliseconds, boost::asio::io_service* service) :
- timeout(milliseconds), timer(*service) {
-}
-
Timer::~Timer() {
- stop();
-}
-
-void Timer::start() {
- timer.expires_from_now(boost::posix_time::milliseconds(timeout));
- timer.async_wait(boost::bind(&Timer::handleTimerTick, shared_from_this(), boost::asio::placeholders::error));
-}
-
-void Timer::stop() {
- timer.cancel();
-}
-
-void Timer::handleTimerTick(const boost::system::error_code& error) {
- if (error) {
- assert(error == boost::asio::error::operation_aborted);
- }
- else {
- MainEventLoop::postEvent(boost::bind(boost::ref(onTick)), shared_from_this());
- timer.expires_from_now(boost::posix_time::milliseconds(timeout));
- timer.async_wait(boost::bind(&Timer::handleTimerTick, shared_from_this(), boost::asio::placeholders::error));
- }
}
}