threads now are real Lua objects, subject to garbage collection
This commit is contained in:
20
lapi.c
20
lapi.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lapi.c,v 1.212 2002/08/30 19:09:21 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 1.213 2002/09/20 17:01:24 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -115,6 +115,18 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
|
||||
}
|
||||
|
||||
|
||||
LUA_API lua_State *lua_newthread (lua_State *L) {
|
||||
lua_State *L1;
|
||||
lua_lock(L);
|
||||
L1 = luaE_newthread(L);
|
||||
setthvalue(L->top, L1);
|
||||
api_incr_top(L);
|
||||
lua_unlock(L);
|
||||
lua_userstateopen(L1);
|
||||
return L1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** basic stack manipulation
|
||||
*/
|
||||
@@ -322,6 +334,12 @@ LUA_API void *lua_touserdata (lua_State *L, int index) {
|
||||
}
|
||||
|
||||
|
||||
LUA_API lua_State *lua_tothread (lua_State *L, int index) {
|
||||
StkId o = luaA_indexAcceptable(L, index);
|
||||
return (o == NULL || !ttisthread(o)) ? NULL : thvalue(o);
|
||||
}
|
||||
|
||||
|
||||
LUA_API const void *lua_topointer (lua_State *L, int index) {
|
||||
StkId o = luaA_indexAcceptable(L, index);
|
||||
if (o == NULL) return NULL;
|
||||
|
||||
Reference in New Issue
Block a user