summaryrefslogtreecommitdiffstats
blob: de97c13e29bcf82ce355c5d422876476449cab62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

#include <boost/asio.hpp>
#include <boost/signals.hpp>
#include <boost/thread.hpp>
#include <boost/enable_shared_from_this.hpp>

#include "Swiften/EventLoop/EventOwner.h"

namespace Swift {
	class Timer : public EventOwner, public boost::enable_shared_from_this<Timer> {
		public:
			Timer(int milliseconds);
			~Timer();

			void start();

		public:
			boost::signal<void ()> onTick;

		private:
			void doStart();
			void handleTimerTick();

		private:
			int timeout_;
			boost::asio::io_service* ioService_;
			boost::thread* thread_;
			boost::asio::deadline_timer* timer_;
	};
}