[Haskell-cafe] FFI woes!

Sebastian Sylvan sebastian.sylvan at gmail.com
Wed Dec 15 08:40:11 EST 2004

On Wed, 15 Dec 2004 07:55:42 -0500, David Roundy
<droundy at abridgegame.org> wrote:
> On Wed, Dec 15, 2004 at 01:13:19PM +0100, Sebastian Sylvan wrote:
> > Another problem!
> > When a handle is not being referenced I don't want it to be garbage
> > collected if the isPlaying function returns True (in other words I
> > want the song to finish playing even if it's not being referenced
> > anymore).
> >
> > The current plan of attack is to have the finalizer fork off a thread
> > which does nothing but check the status of the song every 500ms or so
> > and when it's finished, releases it. But since I really only need to
> > check it every time the garbage collector wants to release it maybe
> > there's a better way?
> > So I want to annotate the ForeignPtr with a function which can defer
> > it's release based on the status of the handle. Is there a way to do
> > this?
> If you're going to determine when to release the pointer manually (which is
> probably best anyways), then there's no need to mess with a ForeignPtr.
> Just stick with a Ptr, and spawn your thread to decide when to fall the
> free function. 

If I do that then I might remove the song (after it has played) even
though the handle is still alive.
So I need to start checking if the song is playing after the handle
has been deemed dead by Haskell's GC.

> I presume that you really do want to play the song
> asynchronously, rather than just returning when the song is over?



Sebastian Sylvan
UIN: 44640862

More information about the Haskell-Cafe mailing list