lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I have Lua embedded in an application in which events resume lua_States. Some resources (userdata and Lua thread states) are shared between Lua and C++; these resources may need to be persistent even when no reference in Lua exists.

So far, I've been using the registry and/or library environment tables to keep active, hidden Lua references to these items. But I wondered if there was a more efficient method to add/remove references. In particular, what would be a good method to have reference counting (C++ references) to Lua userdata/threads? I guess I could store a reference count integer against the state/thread, but it seems long-winded...

I wondered if there is a lower-level way to interact with Lua's reference/gc system.

Thanks