Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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__