summaryrefslogtreecommitdiffstats
path: root/src/uscxml
diff options
context:
space:
mode:
authorMatthias Gabriel <matthias.gabriel@etit.tu-chemnitz.de>2016-12-16 15:41:23 (GMT)
committerMatthias Gabriel <matthias.gabriel@etit.tu-chemnitz.de>2016-12-16 15:41:23 (GMT)
commitef0bc44e3c598cd1cd463c3971428b89e6f951d1 (patch)
treef3ef1a6a6ed44ed4ddf73cb3c05ad9c356c9bb73 /src/uscxml
parent24f634572a73741a522053cdb9372f8ec320b679 (diff)
parent75fc3b465fb3d61d36874cf7a29ddbb8256e3817 (diff)
downloaduscxml-ef0bc44e3c598cd1cd463c3971428b89e6f951d1.zip
uscxml-ef0bc44e3c598cd1cd463c3971428b89e6f951d1.tar.gz
uscxml-ef0bc44e3c598cd1cd463c3971428b89e6f951d1.tar.bz2
Merge branch 'master' of https://github.com/tklab-tud/uscxml into FixDataWithNode
Diffstat (limited to 'src/uscxml')
-rw-r--r--src/uscxml/interpreter/BasicEventQueue.cpp20
-rw-r--r--src/uscxml/interpreter/InterpreterImpl.h3
2 files changed, 12 insertions, 11 deletions
diff --git a/src/uscxml/interpreter/BasicEventQueue.cpp b/src/uscxml/interpreter/BasicEventQueue.cpp
index 104c9fa..2f8bd48 100644
--- a/src/uscxml/interpreter/BasicEventQueue.cpp
+++ b/src/uscxml/interpreter/BasicEventQueue.cpp
@@ -22,8 +22,6 @@
#include <event2/thread.h>
#include <assert.h>
-//#include <iostream>
-
#include "uscxml/interpreter/Logging.h"
namespace uscxml {
@@ -37,19 +35,21 @@ Event BasicEventQueue::dequeue(size_t blockMs) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
if (blockMs > 0) {
+ using namespace std::chrono;
- // 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;
+ // TODO: do read http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm
+ system_clock::time_point now = system_clock::now();
+ system_clock::time_point endTime = now + milliseconds(blockMs);
+ // now + milliseconds(blockMs) may not have fitted into a duration type - limit to maximum duration
+ if (blockMs > system_clock::duration::max().count() - duration_cast<milliseconds>(now.time_since_epoch()).count()) {
+ endTime = system_clock::time_point::max();
+ }
+
+ // block for given milliseconds or until queue is non-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) {
diff --git a/src/uscxml/interpreter/InterpreterImpl.h b/src/uscxml/interpreter/InterpreterImpl.h
index f4fe93e..1243f7c 100644
--- a/src/uscxml/interpreter/InterpreterImpl.h
+++ b/src/uscxml/interpreter/InterpreterImpl.h
@@ -25,6 +25,7 @@
#include <list>
#include <map>
#include <string>
+#include <limits>
#include "uscxml/Common.h"
#include "uscxml/util/URL.h"
@@ -107,7 +108,7 @@ public:
MicrostepCallbacks
*/
virtual Event dequeueInternal() {
- _currEvent = _internalQueue.dequeue(false);
+ _currEvent = _internalQueue.dequeue(0);
if (_currEvent)
_dataModel.setEvent(_currEvent);
return _currEvent;