Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2007-10-21 15:13:19 +0000
committerStijn Buys <ingar@osirion.org>2007-10-21 15:13:19 +0000
commita96b108a9b74baaa63cb84da212d725808b91d88 (patch)
tree82b9adc7ab326f1eb8cccf79be6c871da988604f /src/server/timer.h
parentf7f66525dcf08015af4f5c1b0eb9d3cec94d886d (diff)
Initial commit
Diffstat (limited to 'src/server/timer.h')
-rw-r--r--src/server/timer.h40
1 files changed, 40 insertions, 0 deletions
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 <sys/time.h>
+
+
+/// 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__