diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-02-25 12:28:05 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-02-25 12:28:05 (GMT) |
commit | 49c3c43d18c9cce6de305aae77cc8bd839506129 (patch) | |
tree | cfc4ea84416c76e8bbe3e27d2918321115b61e24 /src/uscxml/concurrency | |
parent | 47956a35d11495f2ebf6988c7f9d9dffe0bd3a4b (diff) | |
download | uscxml-49c3c43d18c9cce6de305aae77cc8bd839506129.zip uscxml-49c3c43d18c9cce6de305aae77cc8bd839506129.tar.gz uscxml-49c3c43d18c9cce6de305aae77cc8bd839506129.tar.bz2 |
Introduced postpone element and reorganized http request representation as events
Diffstat (limited to 'src/uscxml/concurrency')
-rw-r--r-- | src/uscxml/concurrency/BlockingQueue.h | 8 | ||||
-rw-r--r-- | src/uscxml/concurrency/tinythread.cpp | 20 | ||||
-rw-r--r-- | src/uscxml/concurrency/tinythread.h | 5 |
3 files changed, 32 insertions, 1 deletions
diff --git a/src/uscxml/concurrency/BlockingQueue.h b/src/uscxml/concurrency/BlockingQueue.h index f318ccf..0f4c965 100644 --- a/src/uscxml/concurrency/BlockingQueue.h +++ b/src/uscxml/concurrency/BlockingQueue.h @@ -14,12 +14,18 @@ public: virtual ~BlockingQueue() { } - virtual void push(T& elem) { + virtual void push(const T& elem) { tthread::lock_guard<tthread::mutex> lock(_mutex); _queue.push_back(elem); _cond.notify_all(); } + virtual void push_front(const T& elem) { + tthread::lock_guard<tthread::mutex> lock(_mutex); + _queue.push_front(elem); + _cond.notify_all(); + } + virtual T pop() { tthread::lock_guard<tthread::mutex> lock(_mutex); while (_queue.empty()) { diff --git a/src/uscxml/concurrency/tinythread.cpp b/src/uscxml/concurrency/tinythread.cpp index 66e73c1..6167545 100644 --- a/src/uscxml/concurrency/tinythread.cpp +++ b/src/uscxml/concurrency/tinythread.cpp @@ -295,4 +295,24 @@ thread::id this_thread::get_id() { #endif } +namespace chrono { +namespace system_clock { +uint64_t now() { + uint64_t time = 0; +#ifdef _WIN32 + FILETIME tv; + GetSystemTimeAsFileTime(&tv); + time = (((uint64_t) tv.dwHighDateTime) << 32) + tv.dwLowDateTime; + time /= 10000; +#else + struct timeval tv; + gettimeofday(&tv, NULL); + time += tv.tv_sec * 1000; + time += tv.tv_usec / 1000; +#endif + return time; +} +} +} + } diff --git a/src/uscxml/concurrency/tinythread.h b/src/uscxml/concurrency/tinythread.h index d824067..9dd2fcb 100644 --- a/src/uscxml/concurrency/tinythread.h +++ b/src/uscxml/concurrency/tinythread.h @@ -646,6 +646,11 @@ typedef duration<__intmax_t, ratio<1, 1000> > milliseconds; ///< Duration w typedef duration<__intmax_t> seconds; ///< Duration with the unit seconds. typedef duration<__intmax_t, ratio<60> > minutes; ///< Duration with the unit minutes. typedef duration<__intmax_t, ratio<3600> > hours; ///< Duration with the unit hours. + +namespace system_clock { +uint64_t now(); +} + } /// The namespace @c this_thread provides methods for dealing with the |