From a96b108a9b74baaa63cb84da212d725808b91d88 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 21 Oct 2007 15:13:19 +0000 Subject: Initial commit --- src/server/timer.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/server/timer.h (limited to 'src/server/timer.h') diff --git a/src/server/timer.h b/src/server/timer.h new file mode 100644 index 0000000..63957ee --- /dev/null +++ b/src/server/timer.h @@ -0,0 +1,40 @@ +#ifndef __INCLUDED_TIMER_H__ +#define __INCLUDED_TIMER_H__ + +#include + + +/// a timer measures that intervals in seconds +/*! A timer class measures the time elapsed +* between the last two calls to its mark() function. +*/ +class Timer { +public: + /// Constructor + Timer(); + /// Destructor + ~Timer(); + + /// mark the current time as zero + /*! Reset the timer, all subsequent calls too elapsed() will + * use now as a reference + * that must be timed. + */ + void mark(); + + /*! return the time elapsed since the last mark + * @see mark() + */ + float elapsed(); + + /// suspend calling process for a number of seconds + void sleep(float seconds); + +private: + float timer_elapsed; + struct timezone timer_tz; + struct timeval timer_tick; +}; // class Timer + + +#endif // __INCLUDED_TIMER_H__ -- cgit v1.2.3