Migrate libasyncio from boost.signal to signals2 (#8756)
[libasyncio] / asyncio / async_timer.hpp
... / ...
CommitLineData
1/*
2The software in this package is distributed under the GNU General
3Public License version 2 (with a special exception described below).
4
5A copy of GNU General Public License (GPL) is included in this distribution,
6in the file COPYING.GPL.
7
8As a special exception, if other files instantiate templates or use macros
9or inline functions from this file, or you compile this file and link it
10with other works to produce a work based on this file, this file
11does not by itself cause the resulting work to be covered
12by the GNU General Public License.
13
14However the source code for this file must still be made available
15in accordance with section (3) of the GNU General Public License.
16
17This exception does not invalidate any other reasons why a work based
18on this file might be covered by the GNU General Public License.
19*/
20/** @file
21 *
22 * provides timer objects based on the TimerBase class
23 *
24 * (c) Copyright 2007 by Intra2net AG
25 */
26
27#ifndef __ASYNC_TIMER_HPP__
28#define __ASYNC_TIMER_HPP__
29
30#include "async_io.hpp"
31
32#include <boost/signals2.hpp>
33
34namespace AsyncIo
35{
36
37
38class SimpleTimer : public TimerBase
39{
40 public:
41
42 typedef boost::signals2::signal<void()> TimerSignal;
43 typedef boost::signals2::signal<void(SimpleTimer*)> TimerSignalP;
44
45 public:
46
47 SimpleTimer();
48
49 // convenience constructors for simple timeouts:
50 SimpleTimer(const MilliTime& delta, const TimerSignal::slot_function_type& action);
51 SimpleTimer(long milli_seonds_delta, const TimerSignal::slot_function_type& action);
52
53 // add actions:
54 void addAction( const TimerSignal::slot_function_type& action );
55 void addActionP( const TimerSignalP::slot_function_type& action );
56
57 // start the timer:
58 void startTimer( const MilliTime& delta );
59 void startTimerMS( long milli_seconds );
60
61 // stop the timer:
62 void stopTimer();
63
64 protected:
65 MilliTime m_delta;
66
67 TimerSignal m_timer_signal;
68 TimerSignalP m_timer_signal_p;
69
70 virtual void execute();
71}; // eo class SimpleTimer
72
73
74} // eo namespace AsyncIo
75
76#endif