summaryrefslogtreecommitdiffstats
path: root/src/uscxml/Interpreter.cpp
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-01-16 00:31:12 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-01-16 00:31:12 (GMT)
commit57b7b1cb196ea9f51aebaba1a838b9a86a9f83fe (patch)
treed2ae2a83f1357b66c9712b741a2ad048444caa06 /src/uscxml/Interpreter.cpp
parent1088a76a715ef8a2728ad3fa8cde02bde4eec760 (diff)
downloaduscxml-57b7b1cb196ea9f51aebaba1a838b9a86a9f83fe.zip
uscxml-57b7b1cb196ea9f51aebaba1a838b9a86a9f83fe.tar.gz
uscxml-57b7b1cb196ea9f51aebaba1a838b9a86a9f83fe.tar.bz2
More work on Prolog datamodel
Diffstat (limited to 'src/uscxml/Interpreter.cpp')
-rw-r--r--src/uscxml/Interpreter.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index 5449272..9063cef 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -33,6 +33,7 @@ Interpreter::Interpreter() : Arabica::SAX2DOM::Parser<std::string>() {
_thread = NULL;
_sendQueue = NULL;
_running = false;
+ _done = false;
#ifdef _WIN32
WSADATA wsaData;
@@ -172,6 +173,7 @@ Interpreter::~Interpreter() {
}
void Interpreter::start() {
+ _done = false;
_thread = new tthread::thread(Interpreter::run, this);
}
@@ -180,10 +182,12 @@ void Interpreter::run(void* instance) {
}
bool Interpreter::runOnMainThread(int fps, bool blocking) {
+ if (_done)
+ return false;
+
if (fps > 0) {
uint64_t nextRun = _lastRunOnMainThread + (1000 / fps);
if (blocking) {
- tthread::lock_guard<tthread::mutex> lock(_mutex);
while(nextRun > tthread::timeStamp()) {
tthread::this_thread::sleep_for(tthread::chrono::milliseconds(nextRun - tthread::timeStamp()));
}
@@ -194,6 +198,7 @@ bool Interpreter::runOnMainThread(int fps, bool blocking) {
_lastRunOnMainThread = tthread::timeStamp();
+ tthread::lock_guard<tthread::mutex> lock(_mutex);
std::map<std::string, IOProcessor>::iterator ioProcessorIter = _ioProcessors.begin();
while(ioProcessorIter != _ioProcessors.end()) {
ioProcessorIter->second.runOnMainThread();
@@ -1411,8 +1416,10 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet<std::string>& enable
}
for (int i = 0; i < _configuration.size(); i++) {
Arabica::DOM::Element<std::string> stateElem = (Arabica::DOM::Element<std::string>)_configuration[i];
- if (isFinal(stateElem) && parentIsScxmlState(stateElem))
+ if (isFinal(stateElem) && parentIsScxmlState(stateElem)) {
_running = false;
+ _done = true;
+ }
}
}