diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-04-18 09:54:40 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-04-18 09:54:40 (GMT) |
commit | 228c809a34fc270527c39522c7a361004197a786 (patch) | |
tree | 9025ff36c6c73a3b994e48bd30f240dcf2f794d7 /src/uscxml/interpreter/InterpreterDraft6.cpp | |
parent | 7c76e603c874009346208c61ad7a3386997b58d1 (diff) | |
download | uscxml-228c809a34fc270527c39522c7a361004197a786.zip uscxml-228c809a34fc270527c39522c7a361004197a786.tar.gz uscxml-228c809a34fc270527c39522c7a361004197a786.tar.bz2 |
Protect parts of interpreter with mutexes
Diffstat (limited to 'src/uscxml/interpreter/InterpreterDraft6.cpp')
-rw-r--r-- | src/uscxml/interpreter/InterpreterDraft6.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp index a15e9a4..97223f8 100644 --- a/src/uscxml/interpreter/InterpreterDraft6.cpp +++ b/src/uscxml/interpreter/InterpreterDraft6.cpp @@ -9,12 +9,13 @@ using namespace Arabica::DOM; // see: http://www.w3.org/TR/scxml/#AlgorithmforSCXMLInterpretation void InterpreterDraft6::interpret() { - _mutex.lock(); +// _mutex.lock(); + tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); if (!_isInitialized) init(); if (!_scxml) { - _mutex.unlock(); +// _mutex.unlock(); return; } // dump(); @@ -101,18 +102,11 @@ void InterpreterDraft6::interpret() { assert(initialTransitions.size() > 0); enterStates(initialTransitions); - _mutex.unlock(); +// _mutex.unlock(); // assert(hasLegalConfiguration()); mainEventLoop(); -// if (_parentQueue) { -// // send one final event to unblock eventual listeners -// Event quit; -// quit.name = "done.state.scxml"; -// _parentQueue->push(quit); -// } - // set datamodel to null from this thread if(_dataModel) _dataModel = DataModel(); @@ -210,6 +204,7 @@ void InterpreterDraft6::mainEventLoop() { } // } + _mutex.unlock(); // whenever we have a stable configuration, run the mainThread hooks with 200fps while(_externalQueue.isEmpty() && _thread == NULL) { runOnMainThread(200); @@ -223,6 +218,8 @@ void InterpreterDraft6::mainEventLoop() { if (!_running) goto EXIT_INTERPRETER; + _mutex.lock(); + if (_dataModel && boost::iequals(_currEvent.name, "cancel.invoke." + _sessionId)) break; |