2 The software in this package is distributed under the GNU General
3 Public License version 2 (with a special exception described below).
5 A copy of GNU General Public License (GPL) is included in this distribution,
6 in the file COPYING.GPL.
8 As a special exception, if other files instantiate templates or use macros
9 or inline functions from this file, or you compile this file and link it
10 with other works to produce a work based on this file, this file
11 does not by itself cause the resulting work to be covered
12 by the GNU General Public License.
14 However the source code for this file must still be made available
15 in accordance with section (3) of the GNU General Public License.
17 This exception does not invalidate any other reasons why a work based
18 on this file might be covered by the GNU General Public License.
22 * (c) Copyright 2007 by Intra2net AG
28 #include "async_timer.hpp"
34 #define DOUT(msg) std::cout << msg << std::endl
35 #define FODOUT(obj,msg) std::cout << typeid(*obj).name() << "[" << obj << "]:" << msg << std::endl
36 #define ODOUT(msg) std::cout << typeid(*this).name() << "[" << this << "]:" << msg << std::endl
38 #define DOUT(msg) do {} while (0)
39 #define FODOUT(obj,msg) do {} while (0)
40 #define ODOUT(msg) do {} while (0)
49 * Implementation of SimpleTimer
52 SimpleTimer::SimpleTimer()
54 } // eo SimpleTimer::SimpleTimer()
57 SimpleTimer::SimpleTimer(const MilliTime& delta, const TimerSignal::slot_function_type& action)
61 } // eo SimpleTimer::SimpleTimer(const MilliTime&, const TimerSignal::slot_type&)
64 SimpleTimer::SimpleTimer(long milli_seonds_delta, const TimerSignal::slot_function_type& action)
67 startTimerMS(milli_seonds_delta);
68 } // eo SimpleTimer::SimpleTimer(long, const TimerSignal::slot_type&)
71 void SimpleTimer::execute()
75 m_timer_signal_p(this);
76 } // eo SimpleTimer::execute
79 void SimpleTimer::addAction( const TimerSignal::slot_function_type& action )
81 m_timer_signal.connect(action);
82 } // eo SimpleTimer::addAction(const TimerSignal::slot_type&)
85 void SimpleTimer::addActionP( const TimerSignalP::slot_function_type& action )
87 m_timer_signal_p.connect(action);
88 } // eo SimpleTimer::addAction(const TimerSignalP::slot_type&)
91 void SimpleTimer::startTimer( const MilliTime& delta )
94 setDeltaWhenTime( delta );
98 get_current_time(now);
102 ODOUT(" now: sec="<< now.mt_sec << ", msec="<<now.mt_msec);
103 ODOUT(" t: sec="<< t.mt_sec << ", msec="<<t.mt_msec);
104 ODOUT(" dt: sec="<< dt.mt_sec << ", msec="<<dt.mt_msec);
106 } // eo SimpleTimer::startTimer(const MilliTime&)
109 void SimpleTimer::startTimerMS( long milli_seconds )
111 startTimer( MilliTime(0,milli_seconds) );
112 } // eo SimpleTimer::stratTimerMS(long)
115 void SimpleTimer::stopTimer()
118 } // eo SimpleTimer::stopTimer
121 } // eo namespace AsyncIo