summaryrefslogtreecommitdiff
path: root/src/BLua.cc
diff options
context:
space:
mode:
authorNicolas Noble <pixel@nobis-crew.org>2013-08-02 18:36:38 -0700
committerNicolas Noble <pixel@nobis-crew.org>2013-08-02 18:36:38 -0700
commitc6518eb6e1caa68cdf0dc242d52cfc172b96efdc (patch)
tree9a24206fd050f674179c8f5e82b59fcf0f152d24 /src/BLua.cc
parent903974e7b3ceecb977449ac5ea34808de9501997 (diff)
Lua's dumpvars is now properly yielding if needed.
Diffstat (limited to 'src/BLua.cc')
-rw-r--r--src/BLua.cc22
1 files changed, 21 insertions, 1 deletions
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 <lualib.h>
@@ -90,7 +91,26 @@ int Balau::LuaStatics::dumpvars(lua_State * __L) {
IO<Handle> h(L.recast<Balau::Handle>());
- L.dumpvars(h, prefix);
+ if (h.isA<Buffer>()) {
+ L.dumpvars(h, prefix);
+ } else {
+ IO<Handle> s(new Buffer());
+ L.dumpvars(h, prefix);
+ Task * t = new CopyTask(s, h);
+ Events::TaskEvent * evt = new Events::TaskEvent(t);
+ L.yield(Future<int>([evt, s]() mutable {
+ for (;;) {
+ if (evt->gotSignal()) {
+ evt->ack();
+ delete evt;
+ s->close();
+ } else {
+ Task::operationYield(evt, Task::INTERRUPTIBLE);
+ }
+ }
+ return 0;
+ }));
+ }
return 0;
}