diff options
Diffstat (limited to 'src/uscxml/concurrency/Timer.h')
-rw-r--r-- | src/uscxml/concurrency/Timer.h | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/uscxml/concurrency/Timer.h b/src/uscxml/concurrency/Timer.h index 217f68f..1ecfeb2 100644 --- a/src/uscxml/concurrency/Timer.h +++ b/src/uscxml/concurrency/Timer.h @@ -18,56 +18,56 @@ namespace uscxml { class USCXML_API Timer { public: - - static double monotonic_seconds(); - - Timer() { - invocations = 0; - elapsed = 0; - } - - void start() { - if (invocations == 0) { - started = monotonic_seconds(); - } - invocations++; - } - - void reset() { - elapsed = 0; + + static double monotonic_seconds(); + + Timer() { + invocations = 0; + elapsed = 0; + } + + void start() { + if (invocations == 0) { + started = monotonic_seconds(); } - - void stop() { - if (invocations == 0) - return; - - invocations--; - if (invocations == 0) { - elapsed += monotonic_seconds() - started; - } - } - - ~Timer() { - } - double elapsed; + invocations++; + } + + void reset() { + elapsed = 0; + } + + void stop() { + if (invocations == 0) + return; + + invocations--; + if (invocations == 0) { + elapsed += monotonic_seconds() - started; + } + } + + ~Timer() { + } + double elapsed; protected: - size_t invocations; - double started; + size_t invocations; + double started; }; - + class USCXML_API Measurement { public: - Measurement(Timer* timer) : timer(timer) { - timer->start(); - } + Measurement(Timer* timer) : timer(timer) { + timer->start(); + } - ~Measurement() { - timer->stop(); - } + ~Measurement() { + timer->stop(); + } protected: - Timer* timer; + Timer* timer; }; } |