summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/BLua.cc7
-rw-r--r--src/LuaHandle.cc2
2 files changed, 4 insertions, 5 deletions
diff --git a/src/BLua.cc b/src/BLua.cc
index e8c5ab6..73995c0 100644
--- a/src/BLua.cc
+++ b/src/BLua.cc
@@ -270,8 +270,7 @@ int Balau::LuaStatics::callwrap(lua_State * __L, lua_CFunction func) {
int Balau::LuaStatics::collector(lua_State * __L) {
Lua L(__L);
LuaObjectBase * o = (LuaObjectBase *) L.touserdata();
- o->destroy();
- return 0;
+ return L.yield(Future<int>([o]() { o->destroy(); return 0; }));
}
int Balau::LuaStatics::destructor(lua_State * __L) {
@@ -279,12 +278,12 @@ int Balau::LuaStatics::destructor(lua_State * __L) {
L.push("__obj");
L.copy();
L.gettable(-3, true);
- collector(__L);
+ LuaObjectBase * o = (LuaObjectBase *) L.touserdata();
L.pop();
L.push();
L.settable(-3, true);
L.pop();
- return 0;
+ return L.yield(Future<int>([o]() { o->destroy(); return 0; }));
}
void Balau::Lua::setCallWrap(lua_CallWrapper wrapper) {
diff --git a/src/LuaHandle.cc b/src/LuaHandle.cc
index 7607665..a1dd93d 100644
--- a/src/LuaHandle.cc
+++ b/src/LuaHandle.cc
@@ -22,7 +22,7 @@ int sLua_IOHandle::IOHandle_proceed(Balau::Lua & L, int n, Balau::IOHandle * obj
switch (caller) {
case IOHANDLE_CLOSE:
- h->close();
+ return L.yield(Balau::Future<int>([h]() mutable { h->close(); return 0; }));
break;
}