Re: lua_State and garbage collection
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: lua_State and garbage collection
- From: Ben Sunshine-Hill <sneftel@...>
- Date: 2005年7月15日 19:47:43 -0700
You're just keeping all the threads around in the C stack of the main
thread? That'll work, I suppose, but is not the best way to keep a
reference around. Use luaL_ref to get an integer reference to the
thread, and pop it off the stack. Store the references in your
std::map<float, int>, and access the threads using luaL_getref. When
you're ready to forget about a thread, just use luaL_unref; since it's
the only remaining reference to the thread, the GC will handle the
rest.
Ben