[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A note on automatic resource management
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 6 Apr 2010 09:31:27 +0200
On Sun, Apr 4, 2010 at 5:26 PM, Florian Weimer <firstname.lastname@example.org> wrote:
> One way to deal with this is to run the stack-based destructors when a
> coroutine is finalized. However, this brings us back to the initial
> observation: this would allow programmers to write finalizers in Lua,
> and as we've seen, there is currently no safe way to do that.
That would be logical; before it is finalized, a coroutine is by
definition still alive and kicking, just sleeping.
I'm trying to understand the problem here. Presumably the destructors
are called in the current state, and execution pauses until they are
finished. What 'gotcha' can burn us here?
Another approach is that the core creates a coroutine which is called
when any user-finalization has to happen. This is generally considered
OK in other contexts, e.g. event-driven callbacks.
In other words, is there not a safe way to run finalizers without the
full pre-emptive mechanism found in C# or Java?