]>
Dogcows Code - chaz/yoink/blob - src/Moof/Timer.hh
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
10 **************************************************************************/
12 #ifndef _MOOF_TIMER_HH_
13 #define _MOOF_TIMER_HH_
17 * Functions for measuring time in a friendly unit.
22 #include <boost/bind.hpp>
23 #include <boost/function.hpp>
25 #include <Moof/Math.hh>
43 typedef boost::function
<void(Timer
&,Scalar
)> Function
;
49 Timer(const Function
& function
, Scalar seconds
, Mode mode
= NORMAL
)
51 init(function
, seconds
, mode
);
59 void init(const Function
& function
, Scalar seconds
,
67 Scalar
getSecondsRemaining() const;
68 bool isExpired() const;
69 bool isRepeating() const;
73 * Get the number of seconds since a fixed, arbitrary point in the
78 static Scalar
getTicks();
82 * Put the thread to sleep for a certain period of time. If absolute
83 * is true, then it will sleep until seconds after the fixed time in
84 * the past. If absolute is false, it will sleep for seconds starting
85 * now. Unlike system sleep functions, this one automatically resumes
86 * sleep if sleep was interrupted by a signal. Therefore, calling this
87 * function is guaranteed to sleep for the requested amount of time
91 static void sleep(Scalar seconds
, Mode mode
= NORMAL
);
94 static Scalar
getNextFire()
99 static void fireIfExpired();
100 static void fireIfExpired(Scalar t
);
104 static unsigned getNewID();
105 static Scalar
findNextFire();
113 static Scalar gNextFire
;
114 static std::map
<unsigned,Timer
*> gTimers
;
120 #endif // _MOOF_TIMER_HH_
This page took 0.040757 seconds and 4 git commands to generate.