summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-05 19:19:51 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-05 19:19:51 +0200
commit911858d8d7cab0108f1c14abd676ad37ccb9c95a (patch)
tree9a28cadbcf7a2fd133cfcba32ebce5864f680938
parente6e2b7afcc92cf0baecd83188e859af7a510da09 (diff)
Adding a helper to LuaExecCell to find the LuaMainTask, and making the exec() call interruptible.
-rw-r--r--includes/LuaTask.h2
-rw-r--r--src/LuaTask.cc9
2 files changed, 10 insertions, 1 deletions
diff --git a/includes/LuaTask.h b/includes/LuaTask.h
index 2ed0156..a12f89f 100644
--- a/includes/LuaTask.h
+++ b/includes/LuaTask.h
@@ -16,6 +16,7 @@ class LuaExecCell {
LuaExecCell();
virtual ~LuaExecCell() { if (m_exception) delete m_exception; }
void detach() { m_detached = true; }
+ void exec(Lua & L);
void exec(LuaMainTask * mainTask);
bool gotError() { return m_gotError || m_exception; }
void throwError() throw (GeneralException);
@@ -27,6 +28,7 @@ class LuaExecCell {
Events::Async m_event;
bool m_detached = false;
bool m_gotError = false;
+ bool m_running = false;
GeneralException * m_exception = NULL;
friend class LuaTask;
diff --git a/src/LuaTask.cc b/src/LuaTask.cc
index a549563..cc0bb60 100644
--- a/src/LuaTask.cc
+++ b/src/LuaTask.cc
@@ -101,11 +101,18 @@ void Balau::LuaTask::Do() {
}
void Balau::LuaExecCell::exec(LuaMainTask * mainTask) {
+ if (m_running)
+ return;
+ m_running = true;
if (!m_detached)
Task::prepare(&m_event);
mainTask->exec(this);
if (!m_detached)
- Task::operationYield(&m_event);
+ Task::operationYield(&m_event, Task::INTERRUPTIBLE);
+}
+
+void Balau::LuaExecCell::exec(Lua & L) {
+ exec(LuaMainTask::getMainTask(L));
}
void Balau::LuaExecCell::throwError() throw (GeneralException) {