summaryrefslogtreecommitdiff
path: root/include/gras
diff options
context:
space:
mode:
authorJosh Blum2013-03-20 23:02:06 -0700
committerJosh Blum2013-03-20 23:02:06 -0700
commitf954bb2d93b083ff911a014711b1ea079060faf7 (patch)
treea9be6882cff74c3b14434a27c53d6681deb5f781 /include/gras
parent6f16dac3572a81170405fdfe8374356257c0f060 (diff)
downloadsandhi-f954bb2d93b083ff911a014711b1ea079060faf7.tar.gz
sandhi-f954bb2d93b083ff911a014711b1ea079060faf7.tar.bz2
sandhi-f954bb2d93b083ff911a014711b1ea079060faf7.zip
gras: move chrono implementation into detail
Diffstat (limited to 'include/gras')
-rw-r--r--include/gras/CMakeLists.txt1
-rw-r--r--include/gras/chrono.hpp73
-rw-r--r--include/gras/detail/chrono.hpp74
3 files changed, 76 insertions, 72 deletions
diff --git a/include/gras/CMakeLists.txt b/include/gras/CMakeLists.txt
index 462b0ff..8700492 100644
--- a/include/gras/CMakeLists.txt
+++ b/include/gras/CMakeLists.txt
@@ -29,6 +29,7 @@ install(FILES
install(FILES
detail/block.hpp
+ detail/chrono.hpp
detail/property.hpp
detail/sbuffer.hpp
detail/work_buffer.hpp
diff --git a/include/gras/chrono.hpp b/include/gras/chrono.hpp
index 52b926b..8564e72 100644
--- a/include/gras/chrono.hpp
+++ b/include/gras/chrono.hpp
@@ -43,79 +43,8 @@ namespace gras
time_ticks_t start;
bool is_done;
};
-
}
-//--------------------------------------------------------------------//
-//------------------ implementation details below --------------------//
-//--------------------------------------------------------------------//
-
-#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
-
-#include <windows.h>
-
-namespace gras
-{
-
- GRAS_FORCE_INLINE time_ticks_t time_now(void)
- {
- LARGE_INTEGER counts;
- QueryPerformanceCounter(&counts);
- return counts.QuadPart;
- }
-
- GRAS_FORCE_INLINE time_ticks_t time_tps(void)
- {
- LARGE_INTEGER freq;
- QueryPerformanceFrequency(&freq);
- return freq.QuadPart;
- }
-
-} //namespace gras
-
-#else
-
-#include <ctime>
-
-namespace gras
-{
-
- GRAS_FORCE_INLINE time_ticks_t time_now(void)
- {
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return ts.tv_sec*1000000000UL + ts.tv_nsec;
- }
-
- GRAS_FORCE_INLINE time_ticks_t time_tps(void)
- {
- return 1000000000UL;
- }
-
-} //namespace gras
-
-#endif
-
-namespace gras
-{
- GRAS_FORCE_INLINE TimerAccumulate::TimerAccumulate(time_ticks_t &accum):
- accum(accum),
- start(time_now()),
- is_done(false)
- {
- //NOP
- }
-
- GRAS_FORCE_INLINE TimerAccumulate::~TimerAccumulate(void)
- {
- if (not is_done) this->done();
- }
-
- GRAS_FORCE_INLINE void TimerAccumulate::done(void)
- {
- accum += (time_now() - start);
- is_done = true;
- }
-}
+#include <gras/detail/chrono.hpp>
#endif /*INCLUDED_GRAS_CHRONO_HPP*/
diff --git a/include/gras/detail/chrono.hpp b/include/gras/detail/chrono.hpp
new file mode 100644
index 0000000..bd247e5
--- /dev/null
+++ b/include/gras/detail/chrono.hpp
@@ -0,0 +1,74 @@
+// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
+
+#ifndef INCLUDED_GRAS_DETAIL_CHRONO_HPP
+#define INCLUDED_GRAS_DETAIL_CHRONO_HPP
+
+#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+
+#include <windows.h>
+
+namespace gras
+{
+
+ GRAS_FORCE_INLINE time_ticks_t time_now(void)
+ {
+ LARGE_INTEGER counts;
+ QueryPerformanceCounter(&counts);
+ return counts.QuadPart;
+ }
+
+ GRAS_FORCE_INLINE time_ticks_t time_tps(void)
+ {
+ LARGE_INTEGER freq;
+ QueryPerformanceFrequency(&freq);
+ return freq.QuadPart;
+ }
+
+} //namespace gras
+
+#else
+
+#include <ctime>
+
+namespace gras
+{
+
+ GRAS_FORCE_INLINE time_ticks_t time_now(void)
+ {
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return ts.tv_sec*1000000000UL + ts.tv_nsec;
+ }
+
+ GRAS_FORCE_INLINE time_ticks_t time_tps(void)
+ {
+ return 1000000000UL;
+ }
+
+} //namespace gras
+
+#endif
+
+namespace gras
+{
+ GRAS_FORCE_INLINE TimerAccumulate::TimerAccumulate(time_ticks_t &accum):
+ accum(accum),
+ start(time_now()),
+ is_done(false)
+ {
+ //NOP
+ }
+
+ GRAS_FORCE_INLINE TimerAccumulate::~TimerAccumulate(void)
+ {
+ if (not is_done) this->done();
+ }
+
+ GRAS_FORCE_INLINE void TimerAccumulate::done(void)
+ {
+ accum += (time_now() - start);
+ is_done = true;
+ }
+}
+
+#endif /*INCLUDED_GRAS_DETAIL_CHRONO_HPP*/