Overhaul of thread handling to support blocking functions other than wait
This commit is contained in:
@@ -76,12 +76,19 @@ int traceback_coroutine(lua_State *L) {
|
||||
}
|
||||
|
||||
|
||||
int traceback_pcall(lua_State *L, int narg, int nret) {
|
||||
eng::string traceback_pcall(lua_State *L, int narg, int nret) {
|
||||
int status;
|
||||
int base = lua_gettop(L) - narg; /* function index */
|
||||
lua_pushcfunction(L, traceback_coroutine); /* push traceback function */
|
||||
lua_insert(L, base); /* put it under chunk and args */
|
||||
status = lua_pcall(L, narg, nret, base);
|
||||
lua_remove(L, base); /* remove traceback function */
|
||||
return status;
|
||||
if (status != LUA_OK) {
|
||||
const char *msg = lua_tostring(L, -1);
|
||||
if ((msg == NULL) || (msg[0] == 0)) {
|
||||
msg = "unknown error";
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user