From 7df563d41c9e76c0946aa6de0f542e33d9586946 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Thu, 18 May 2017 15:12:36 +0200 Subject: Fixed issue 132 --- src/uscxml/interpreter/BasicEventQueue.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/uscxml/interpreter/BasicEventQueue.cpp b/src/uscxml/interpreter/BasicEventQueue.cpp index 5b3e9f8..32c6d0a 100644 --- a/src/uscxml/interpreter/BasicEventQueue.cpp +++ b/src/uscxml/interpreter/BasicEventQueue.cpp @@ -34,7 +34,13 @@ BasicEventQueue::~BasicEventQueue() { Event BasicEventQueue::dequeue(size_t blockMs) { std::lock_guard lock(_mutex); - if (blockMs > 0) { + if (blockMs == std::numeric_limits::max()) { + // handle "forever" explicitly, see comments below + while (_queue.empty()) { + _cond.wait(_mutex); + } + + } else if (blockMs > 0) { using namespace std::chrono; // TODO: do read http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm @@ -43,6 +49,15 @@ Event BasicEventQueue::dequeue(size_t blockMs) { // now + milliseconds(blockMs) may not have fitted into a duration type - limit to maximum duration if (blockMs > (size_t)(system_clock::duration::max().count() - duration_cast(now.time_since_epoch()).count())) { + /** + * Some compilers do not like to wait_until system_clock::time_point::max(): + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58931 + * http://stackoverflow.com/questions/39041450/stdcondition-variable-wait-until-surprising-behaviour + * + * See also: + * https://github.com/tklab-tud/uscxml/issues/101 + * https://github.com/tklab-tud/uscxml/issues/132 + */ endTime = system_clock::time_point::max(); } -- cgit v0.12