[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: when a lua thread created from c can be release?
- From: 吕游 <lvyou@...>
- Date: Mon, 13 Aug 2007 14:36:06 +0800
When i use lua_newthread to create a lua thread,i will got a lua_State pointer.
from manual, it is said:"There is no explicit function to close or to destroy a thread. Threads are subject to garbage collection, like any Lua object".
Problem is:I kept a lua_State pointer (for the newly created thread) outside the VM,and I have no way to tell VM when i don't need it.if the thread been sweeped as garbage,does the pointer i kept still valid? in other word,both my code and VM doesn't know when this thread will become really useless.
I just want to know how does the lua VM deal with this problem.
here is my test code just for reference:
lua_State* L = luaL_newstate();
lua_State* T = lua_newthread(L);
after invoke lua_gc, this new thread pointer T still valid, and test.lua executed successfully.
使用下一代的 MSN Messenger。 立即尝试！