summaryrefslogtreecommitdiffstats
path: root/src/uscxml
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml')
-rw-r--r--src/uscxml/Interpreter.cpp19
-rw-r--r--src/uscxml/Interpreter.h4
-rw-r--r--src/uscxml/interpreter/InterpreterDraft6.cpp17
3 files changed, 19 insertions, 21 deletions
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index c951999..87eae11 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -232,19 +232,18 @@ bool InterpreterImpl::runOnMainThread(int fps, bool blocking) {
_lastRunOnMainThread = tthread::timeStamp();
{
- tthread::lock_guard<tthread::recursive_mutex> lock(_ioProcMutex);
+ tthread::lock_guard<tthread::recursive_mutex> lock(_pluginMutex);
std::map<std::string, IOProcessor>::iterator ioProcessorIter = _ioProcessors.begin();
while(ioProcessorIter != _ioProcessors.end()) {
ioProcessorIter->second.runOnMainThread();
ioProcessorIter++;
}
+ std::map<std::string, Invoker>::iterator invokerIter = _invokers.begin();
+ while(invokerIter != _invokers.end()) {
+ invokerIter->second.runOnMainThread();
+ invokerIter++;
+ }
}
- std::map<std::string, Invoker>::iterator invokerIter = _invokers.begin();
- while(invokerIter != _invokers.end()) {
- invokerIter->second.runOnMainThread();
- invokerIter++;
- }
-
return (_thread != NULL);
}
@@ -826,7 +825,7 @@ void InterpreterImpl::invoke(const Arabica::DOM::Node<std::string>& element) {
Invoker invoker(Factory::createInvoker(invokeReq.type, this));
if (invoker) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ tthread::lock_guard<tthread::recursive_mutex> lock(_pluginMutex);
try {
invoker.setInvokeId(invokeReq.invokeid);
invoker.setType(invokeReq.type);
@@ -1620,7 +1619,7 @@ bool InterpreterImpl::isCompound(const Arabica::DOM::Node<std::string>& state) {
}
void InterpreterImpl::setupIOProcessors() {
- tthread::lock_guard<tthread::recursive_mutex> lock(_ioProcMutex);
+ tthread::lock_guard<tthread::recursive_mutex> lock(_pluginMutex);
std::map<std::string, IOProcessorImpl*>::iterator ioProcIter = Factory::getInstance()->_ioProcessors.begin();
while(ioProcIter != Factory::getInstance()->_ioProcessors.end()) {
if (boost::iequals(ioProcIter->first, "basichttp") && !(_capabilities & CAN_BASIC_HTTP)) {
@@ -1665,7 +1664,7 @@ void InterpreterImpl::setupIOProcessors() {
}
IOProcessor InterpreterImpl::getIOProcessor(const std::string& type) {
- tthread::lock_guard<tthread::recursive_mutex> lock(_ioProcMutex);
+ tthread::lock_guard<tthread::recursive_mutex> lock(_pluginMutex);
if (_ioProcessors.find(type) == _ioProcessors.end()) {
LOG(ERROR) << "No ioProcessor known for type " << type;
return IOProcessor();
diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h
index f28eb69..1394d59 100644
--- a/src/uscxml/Interpreter.h
+++ b/src/uscxml/Interpreter.h
@@ -142,10 +142,12 @@ public:
void receive(const Event& event, bool toFront = false);
Event getCurrentEvent() {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
return _currEvent;
}
Arabica::XPath::NodeSet<std::string> getConfiguration() {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
return _configuration;
}
void setConfiguration(const std::vector<std::string>& states) {
@@ -228,7 +230,7 @@ protected:
bool _stable;
tthread::thread* _thread;
tthread::recursive_mutex _mutex;
- tthread::recursive_mutex _ioProcMutex;
+ tthread::recursive_mutex _pluginMutex;
URL _baseURI;
Arabica::DOM::Document<std::string> _document;
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;