From c6518eb6e1caa68cdf0dc242d52cfc172b96efdc Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Fri, 2 Aug 2013 18:36:38 -0700 Subject: Lua's dumpvars is now properly yielding if needed. --- src/BLua.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/BLua.cc') diff --git a/src/BLua.cc b/src/BLua.cc index 29f4a58..7eda510 100644 --- a/src/BLua.cc +++ b/src/BLua.cc @@ -3,6 +3,7 @@ #include "Printer.h" #include "Input.h" #include "Buffer.h" +#include "HelperTasks.h" extern "C" { #include @@ -90,7 +91,26 @@ int Balau::LuaStatics::dumpvars(lua_State * __L) { IO h(L.recast()); - L.dumpvars(h, prefix); + if (h.isA()) { + L.dumpvars(h, prefix); + } else { + IO s(new Buffer()); + L.dumpvars(h, prefix); + Task * t = new CopyTask(s, h); + Events::TaskEvent * evt = new Events::TaskEvent(t); + L.yield(Future([evt, s]() mutable { + for (;;) { + if (evt->gotSignal()) { + evt->ack(); + delete evt; + s->close(); + } else { + Task::operationYield(evt, Task::INTERRUPTIBLE); + } + } + return 0; + })); + } return 0; } -- cgit v1.2.3