summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/uscxml/Interpreter.cpp1
-rw-r--r--src/uscxml/Interpreter.h2
-rw-r--r--src/uscxml/interpreter/InterpreterDraft6.cpp18
3 files changed, 2 insertions, 19 deletions
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index b2e61fd..c951999 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -190,6 +190,7 @@ void InterpreterImpl::setName(const std::string& name) {
}
InterpreterImpl::~InterpreterImpl() {
+ tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
if (_thread) {
_running = false;
// unblock event queue
diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h
index 1075a1c..f28eb69 100644
--- a/src/uscxml/Interpreter.h
+++ b/src/uscxml/Interpreter.h
@@ -142,12 +142,10 @@ 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) {
diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp
index f73051e..a15e9a4 100644
--- a/src/uscxml/interpreter/InterpreterDraft6.cpp
+++ b/src/uscxml/interpreter/InterpreterDraft6.cpp
@@ -101,6 +101,7 @@ void InterpreterDraft6::interpret() {
assert(initialTransitions.size() > 0);
enterStates(initialTransitions);
+ _mutex.unlock();
// assert(hasLegalConfiguration());
mainEventLoop();
@@ -136,7 +137,6 @@ void InterpreterDraft6::mainEventLoop() {
}
std::cout << std::endl;
#endif
- _mutex.unlock();
monIter = _monitors.begin();
while(monIter != _monitors.end()) {
try {
@@ -148,7 +148,6 @@ void InterpreterDraft6::mainEventLoop() {
}
monIter++;
}
- _mutex.lock();
enabledTransitions = selectEventlessTransitions();
if (enabledTransitions.size() == 0) {
@@ -166,7 +165,6 @@ void InterpreterDraft6::mainEventLoop() {
}
}
if (!enabledTransitions.empty()) {
- _mutex.unlock();
monIter = _monitors.begin();
while(monIter != _monitors.end()) {
try {
@@ -178,8 +176,6 @@ void InterpreterDraft6::mainEventLoop() {
}
monIter++;
}
- _mutex.lock();
-
// test 403b
enabledTransitions.to_document_order();
microstep(enabledTransitions);
@@ -200,8 +196,6 @@ void InterpreterDraft6::mainEventLoop() {
// assume that we have a legal configuration as soon as the internal queue is empty
assert(hasLegalConfiguration());
- _mutex.unlock();
-
monIter = _monitors.begin();
// if (!_sendQueue || _sendQueue->isEmpty()) {
while(monIter != _monitors.end()) {
@@ -229,8 +223,6 @@ void InterpreterDraft6::mainEventLoop() {
if (!_running)
goto EXIT_INTERPRETER;
- _mutex.lock();
-
if (_dataModel && boost::iequals(_currEvent.name, "cancel.invoke." + _sessionId))
break;
@@ -652,7 +644,6 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& e
std::cout << std::endl;
#endif
- _mutex.unlock();
monIter = _monitors.begin();
while(monIter != _monitors.end()) {
try {
@@ -664,7 +655,6 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& e
}
monIter++;
}
- _mutex.lock();
for (int i = 0; i < statesToExit.size(); i++) {
NodeSet<std::string> histories = filterChildElements(_xmlNSPrefix + "history", statesToExit[i]);
@@ -715,7 +705,6 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& e
_configuration.insert(_configuration.end(), tmp.begin(), tmp.end());
}
- _mutex.unlock();
monIter = _monitors.begin();
while(monIter != _monitors.end()) {
try {
@@ -727,7 +716,6 @@ void InterpreterDraft6::exitStates(const Arabica::XPath::NodeSet<std::string>& e
}
monIter++;
}
- _mutex.lock();
}
@@ -834,7 +822,6 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>&
}
statesToEnter.to_document_order();
- _mutex.unlock();
monIter = _monitors.begin();
while(monIter != _monitors.end()) {
try {
@@ -846,7 +833,6 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>&
}
monIter++;
}
- _mutex.lock();
for (int i = 0; i < statesToEnter.size(); i++) {
Element<std::string> stateElem = (Element<std::string>)statesToEnter[i];
@@ -904,7 +890,6 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>&
}
}
- _mutex.unlock();
monIter = _monitors.begin();
while(monIter != _monitors.end()) {
try {
@@ -916,7 +901,6 @@ void InterpreterDraft6::enterStates(const Arabica::XPath::NodeSet<std::string>&
}
monIter++;
}
- _mutex.lock();
}