diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-07-15 07:42:18 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-07-15 07:42:18 (GMT) |
commit | 0930cd940963be0edfe7c80b4925babca0e01443 (patch) | |
tree | b2a57761bfdf1a14ea75ea1a9871c70d85ff8024 /Swiften/Network/Timer.cpp | |
parent | d2625df30861a4caa984031a6990d19dfebc3367 (diff) | |
download | swift-contrib-0930cd940963be0edfe7c80b4925babca0e01443.zip swift-contrib-0930cd940963be0edfe7c80b4925babca0e01443.tar.bz2 |
Use shared_ptr for EventLoop owners.
Diffstat (limited to 'Swiften/Network/Timer.cpp')
-rw-r--r-- | Swiften/Network/Timer.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Swiften/Network/Timer.cpp b/Swiften/Network/Timer.cpp index 8b2b57f..bab41e4 100644 --- a/Swiften/Network/Timer.cpp +++ b/Swiften/Network/Timer.cpp @@ -12,7 +12,7 @@ Timer::Timer(int milliseconds) : } Timer::~Timer() { - MainEventLoop::removeEventsFromOwner(this); + MainEventLoop::removeEventsFromOwner(shared_from_this()); ioService_->stop(); thread_->join(); delete timer_; @@ -21,20 +21,20 @@ Timer::~Timer() { } void Timer::start() { - thread_ = new boost::thread(boost::bind(&Timer::doStart, this)); + thread_ = new boost::thread(boost::bind(&Timer::doStart, shared_from_this())); } void Timer::doStart() { timer_ = new boost::asio::deadline_timer(*ioService_); timer_->expires_from_now(boost::posix_time::milliseconds(timeout_)); - timer_->async_wait(boost::bind(&Timer::handleTimerTick, this)); + timer_->async_wait(boost::bind(&Timer::handleTimerTick, shared_from_this())); ioService_->run(); } void Timer::handleTimerTick() { - MainEventLoop::postEvent(boost::bind(boost::ref(onTick)), this); + 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, this)); + timer_->async_wait(boost::bind(&Timer::handleTimerTick, shared_from_this())); } } |