]>
Dogcows Code - chaz/openbox/blob - otk/timer.hh
610a02e6c8a10d24a0ab98b662aa8cf040b97093
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
6 #ifdef TIME_WITH_SYS_TIME
9 #else // !TIME_WITH_SYS_TIME
10 # ifdef HAVE_SYS_TIME_H
11 # include <sys/time.h>
12 # else // !HAVE_SYS_TIME_H
14 # endif // HAVE_SYS_TIME_H
15 #endif // TIME_WITH_SYS_TIME
20 class OBTimerQueueManager
;
22 //! The data passed to the OBTimeoutHandler function.
24 Note: this is a very useful place to put an object instance, and set the
25 event handler to a static function in the same class.
27 typedef void *OBTimeoutData
;
28 //! The type of function which can be set as the callback for an OBTimer firing
29 typedef void (*OBTimeoutHandler
)(OBTimeoutData
);
33 OBTimerQueueManager
*manager
;
34 OBTimeoutHandler handler
;
38 timeval _start
, _timeout
;
40 OBTimer(const OBTimer
&);
41 OBTimer
& operator=(const OBTimer
&);
44 OBTimer(OBTimerQueueManager
*m
, OBTimeoutHandler h
, OBTimeoutData d
);
49 inline bool isTiming() const { return timing
; }
50 inline bool isRecurring() const { return recur
; }
52 inline const timeval
&getTimeout() const { return _timeout
; }
53 inline const timeval
&getStartTime() const { return _start
; }
55 timeval
timeRemaining(const timeval
&tm
) const;
56 bool shouldFire(const timeval
&tm
) const;
57 timeval
endpoint() const;
59 inline void recurring(bool b
) { recur
= b
; }
61 void setTimeout(long t
);
62 void setTimeout(const timeval
&t
);
64 void start(); // manager acquires timer
65 void stop(); // manager releases timer
66 void halt(); // halts the timer
68 bool operator<(const OBTimer
& other
) const
69 { return shouldFire(other
.endpoint()); }
This page took 0.034021 seconds and 4 git commands to generate.