summaryrefslogtreecommitdiff
path: root/src/LuaTask.cc
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2012-04-03 16:05:07 -0700
committerPixel <pixel@nobis-crew.org>2012-04-03 16:05:07 -0700
commitb7c281e1d7c26d4414706d529862407d07e385c2 (patch)
tree5462876ddcd86787068753a8c6a40ca017cf88fa /src/LuaTask.cc
parent532f3e7bae955f8da4c2028bc462134ed10ff414 (diff)
Having a slightly better mechanism for stopping the LuaMainTask, as well as some debugging messages.
Diffstat (limited to 'src/LuaTask.cc')
-rw-r--r--src/LuaTask.cc24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/LuaTask.cc b/src/LuaTask.cc
index 80a56f6..e1c722d 100644
--- a/src/LuaTask.cc
+++ b/src/LuaTask.cc
@@ -1,12 +1,18 @@
#include "LuaTask.h"
#include "Main.h"
#include "TaskMan.h"
+#include "Printer.h"
-class LuaTaskDummy : public Balau::LuaExecCell {
+class LuaTaskStopper : public Balau::LuaExecCell {
virtual void run(Balau::Lua &) { }
};
-Balau::LuaMainTask::LuaMainTask() : m_stopping(false) {
+Balau::LuaExecCell::LuaExecCell() : m_detached(false) {
+ Printer::elog(E_TASK, "LuaExecCell created at %p", this);
+}
+
+Balau::LuaMainTask::LuaMainTask() {
+ Printer::elog(E_TASK, "LuaMainTask created at %p", this);
L.open_base();
L.open_table();
L.open_string();
@@ -21,21 +27,25 @@ Balau::LuaMainTask::~LuaMainTask() {
}
void Balau::LuaMainTask::exec(LuaExecCell * cell) {
+ Printer::elog(E_TASK, "LuaMainTask at %p is asked to queue Cell %p", this, cell);
m_queue.push(cell);
}
void Balau::LuaMainTask::stop() {
- Atomic::CmpXChgVal(&m_stopping, true, false);
- exec(new LuaTaskDummy());
+ Printer::elog(E_TASK, "LuaMainTask at %p asked to stop", this);
+ exec(new LuaTaskStopper());
}
void Balau::LuaMainTask::Do() {
- while (!m_stopping) {
+ for (;;) {
LuaExecCell * cell;
+ Printer::elog(E_TASK, "LuaMainTask at %p tries to pop an ExecCell", this);
while ((cell = m_queue.pop())) {
- if (dynamic_cast<LuaTaskDummy *>(cell)) {
+ Printer::elog(E_TASK, "LuaMainTask at %p popped %p", this, cell);
+ if (dynamic_cast<LuaTaskStopper *>(cell)) {
+ Printer::elog(E_TASK, "LuaMainTask at %p is stopping", this);
delete cell;
- break;
+ return;
}
TaskMan::createTask(new LuaTask(L.thread(), cell), this);
}