Bug in touchForeignPtr?
Duncan Coutts
duncan.coutts at worc.ox.ac.uk
Tue Nov 23 20:57:58 EST 2004
On Tue, 2004-11-23 at 18:01 +0100, Peter Simons wrote:
> Simon Marlow writes:
>
> >>> Note that the GC only starts the finaliser thread. The
> >>> program can still terminate before this thread has run
> >>> to completion [...]
>
> > If you want anything else, you can implement it.
>
> How do I implement that particular feature? I don't see how
> I could write a 'main' function that waits for the finalizer
> thread having terminated.
For all normal threads you can wait for them by making them write to an
MVar when they finish and the main thread waits to read from the MVar
before finishing itself.
Of course for the finalizer thread you cannot do this since you did not
start it. However the fact that finalizers are run in a dedicated thread
is itself an implementation detail that you have no control over anyway.
Obviously from what Simon has said, you cannot solve the finalisers
problem just by running the finaliser thread to completion (or it'd be
done that way already!)
Duncan
More information about the Glasgow-haskell-users
mailing list