diff options
author | Stefan Radomski <github@mintwerk.de> | 2016-12-12 12:58:40 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2016-12-12 12:58:40 (GMT) |
commit | 7b55e48d57c061bd65e7718a41bfddd90084345e (patch) | |
tree | a371c34147528f5ed0a3a8e53bf6c2d52149dcc0 /src/uscxml/interpreter/BasicEventQueue.cpp | |
parent | 277ca19814890939d5d0e4551e3acb651b1c42e6 (diff) | |
download | uscxml-7b55e48d57c061bd65e7718a41bfddd90084345e.zip uscxml-7b55e48d57c061bd65e7718a41bfddd90084345e.tar.gz uscxml-7b55e48d57c061bd65e7718a41bfddd90084345e.tar.bz2 |
Added test / example for pausable eventqueue
Diffstat (limited to 'src/uscxml/interpreter/BasicEventQueue.cpp')
-rw-r--r-- | src/uscxml/interpreter/BasicEventQueue.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/uscxml/interpreter/BasicEventQueue.cpp b/src/uscxml/interpreter/BasicEventQueue.cpp index 3b51117..104c9fa 100644 --- a/src/uscxml/interpreter/BasicEventQueue.cpp +++ b/src/uscxml/interpreter/BasicEventQueue.cpp @@ -22,6 +22,8 @@ #include <event2/thread.h> #include <assert.h> +//#include <iostream> + #include "uscxml/interpreter/Logging.h" namespace uscxml { @@ -36,12 +38,18 @@ Event BasicEventQueue::dequeue(size_t blockMs) { if (blockMs > 0) { - // block for given milliseconds or until queue is filled + // block for given milliseconds or until queue is non-empty auto endTime = std::chrono::system_clock::now() + std::chrono::milliseconds(blockMs); +// std::time_t ttp = std::chrono::system_clock::to_time_t(endTime); +// std::cout << "End: " << ttp << std::endl; +// std::cout << "Now: " << std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()) << std::endl; - while (_queue.empty()) { + while (endTime > std::chrono::system_clock::now() && _queue.empty()) { _cond.wait_until(_mutex, endTime); +// std::cout << "Aft: " << std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()) << std::endl; +// std::cout << blockMs << "."; } + } if (_queue.size() > 0) { @@ -66,7 +74,7 @@ void BasicEventQueue::reset() { } std::shared_ptr<EventQueueImpl> BasicEventQueue::create() { - return std::shared_ptr<EventQueueImpl>(new BasicEventQueue()); + return std::shared_ptr<EventQueueImpl>(new BasicEventQueue()); } } |