[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Efficiently marking a Lua userdata or thread to prevent __gc?
- From: Graham Wakefield <lists@...>
- Date: Thu, 24 Jan 2008 12:44:11 -0800
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