[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: problem with the garbage collecting.
- From: Javier Guerra Giraldez <javier@...>
- Date: Tue, 13 Oct 2015 03:32:09 -0500
On Tue, Oct 13, 2015 at 3:20 AM, Thierry FOURNIER <email@example.com> wrote:
> I called functions executed in a coroutine. Maybe the developper copy
> the object containig the FD in the global env, or maybe not. It cant
> know this information, so I can't close himself the fd. Only the gc and
> the refcount system (I guess) know the information.
there's no refcount system in Lua.
but you can implement one: on your object initialization you can
register all 'open' objets in a global table, and another table where
you keep those that should stay open. periodically (or at the pcall()
exit) close any object that is still in the 'all objects' table and
not in the 'currently needed' table.