diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-25 17:05:28 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-25 17:05:28 -0300 |
| commit | 96e15b8501e5d8fc40c475cbac573f910ab5853b (patch) | |
| tree | 2c8efededa6849704f0db3075d0cbe0efaa40b2d /lapi.c | |
| parent | 0fd91b1b087b478fffa36f96bc0f608d86627a4b (diff) | |
| download | lua-96e15b8501e5d8fc40c475cbac573f910ab5853b.tar.gz lua-96e15b8501e5d8fc40c475cbac573f910ab5853b.tar.bz2 lua-96e15b8501e5d8fc40c475cbac573f910ab5853b.zip | |
threads now are real Lua objects, subject to garbage collection
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 20 |
1 files changed, 19 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.212 2002/08/30 19:09:21 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.213 2002/09/20 17:01:24 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -115,6 +115,18 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { | |||
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | 117 | ||
| 118 | LUA_API lua_State *lua_newthread (lua_State *L) { | ||
| 119 | lua_State *L1; | ||
| 120 | lua_lock(L); | ||
| 121 | L1 = luaE_newthread(L); | ||
| 122 | setthvalue(L->top, L1); | ||
| 123 | api_incr_top(L); | ||
| 124 | lua_unlock(L); | ||
| 125 | lua_userstateopen(L1); | ||
| 126 | return L1; | ||
| 127 | } | ||
| 128 | |||
| 129 | |||
| 118 | /* | 130 | /* |
| 119 | ** basic stack manipulation | 131 | ** basic stack manipulation |
| 120 | */ | 132 | */ |
| @@ -322,6 +334,12 @@ LUA_API void *lua_touserdata (lua_State *L, int index) { | |||
| 322 | } | 334 | } |
| 323 | 335 | ||
| 324 | 336 | ||
| 337 | LUA_API lua_State *lua_tothread (lua_State *L, int index) { | ||
| 338 | StkId o = luaA_indexAcceptable(L, index); | ||
| 339 | return (o == NULL || !ttisthread(o)) ? NULL : thvalue(o); | ||
| 340 | } | ||
| 341 | |||
| 342 | |||
| 325 | LUA_API const void *lua_topointer (lua_State *L, int index) { | 343 | LUA_API const void *lua_topointer (lua_State *L, int index) { |
| 326 | StkId o = luaA_indexAcceptable(L, index); | 344 | StkId o = luaA_indexAcceptable(L, index); |
| 327 | if (o == NULL) return NULL; | 345 | if (o == NULL) return NULL; |
