diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/LuaTask.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/LuaTask.cc b/lib/LuaTask.cc index 4608fa1..ac3df8d 100644 --- a/lib/LuaTask.cc +++ b/lib/LuaTask.cc @@ -6,13 +6,24 @@ LuaTask * LuaTask::top = 0; -LuaTask::LuaTask(Lua * _L, const String & _cmd) : L(_L), cmd(_cmd), c(0), b(0) { +LuaTask::LuaTask(Lua * _L, const String & _cmd) : L(_L), cmd(_cmd), nargs(0), c(0), b(0) { if (top) { WaitFor(top); } else { SetBurst(); } top = this; + stacktop = L->gettop() + 1; +} + +LuaTask::LuaTask(Lua * _L, int _nargs) : L(_L), cmd(""), nargs(_nargs), c(0), b(0) { + if (top) { + WaitFor(top); + } else { + SetBurst(); + } + top = this; + stacktop = L->gettop() - nargs; } LuaTask::~LuaTask() { @@ -29,16 +40,22 @@ int LuaTask::Do() throw (GeneralException) { switch (current) { case 0: current = 1; - L->resume(cmd); + if (cmd != "") { + L->resume(cmd); + } else { + L->resume(nargs); + } case 1: if (c) { int nargs = 0; +#ifndef LUATASK_OMIT_HTTPCLIENT if (task == "HttpClient") { LuaBuffer o(b); o.pushdestruct(L); nargs = 1; } +#endif delete c; c = 0; |