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. I presume that you really do want to play the song asynchronously, rather than just returning when the song is over? > Sadly the C library doesn't seem to provide a callback for when the > song has finished playing which would be ideal. Indeed. -- David Roundy http://www.darcs.net _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
