diff options
-rw-r--r-- | includes/LuaTask.h | 1 | ||||
-rw-r--r-- | src/LuaTask.cc | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/includes/LuaTask.h b/includes/LuaTask.h index 85ce1f8..2ed0156 100644 --- a/includes/LuaTask.h +++ b/includes/LuaTask.h @@ -69,6 +69,7 @@ class LuaMainTask : public StacklessTask { ~LuaMainTask(); void stop(); virtual const char * getName() const { return "LuaMainTask"; } + static LuaMainTask * getMainTask(Lua &); private: void exec(LuaExecCell * cell); virtual void Do(); diff --git a/src/LuaTask.cc b/src/LuaTask.cc index 5c03521..e7d78ff 100644 --- a/src/LuaTask.cc +++ b/src/LuaTask.cc @@ -25,6 +25,9 @@ Balau::LuaMainTask::LuaMainTask() { L.open_bit(); L.open_jit(); L.open_ffi(); + L.push("LuaMainTask"); + L.push((void *) this); + L.settable(LUA_REGISTRYINDEX); } Balau::LuaMainTask::~LuaMainTask() { @@ -61,6 +64,14 @@ void Balau::LuaMainTask::Do() { } } +Balau::LuaMainTask * Balau::LuaMainTask::getMainTask(Lua & L) { + L.push("LuaMainTask"); + L.gettable(LUA_REGISTRYINDEX); + LuaMainTask * r = (LuaMainTask *) L.touserdata(); + L.pop(); + return r; +} + void Balau::LuaTask::Do() { while(true) { try { |