[Haskell-cafe] FFI woes!
sebastian.sylvan at gmail.com
Thu Dec 16 06:26:53 EST 2004
On Thu, 16 Dec 2004 08:46:58 +0000, Ben Rudiak-Gould
<Benjamin.Rudiak-Gould at cl.cam.ac.uk> wrote:
> Sebastian Sylvan wrote:
> >If there was a way to simply defer GC (like you attatch a function to
> >an object which can simply deny the GC the right to remove it
> >depending on its state) then I wouldn't have to do anything
> >significant in the finalizer.
> Why not spawn a thread which starts the playback, waits for it to
> finish, and then exits, and wrap the whole thread in a call to
> withForeignPtr? Then your finalizer won't be called prematurely.
Well I could do this, but for one it would be cumbersome to stop
playback. I could, of course, return some sort of Playback datatype
which contains a Chan that can be written to with some commands, and
then have the playback-loop (spawned with a forkIO) check this
periodically and apply the commands to the "real" playback channel.
However I'd need a pretty tight polling-loop to get these commands
responsive, and that just seems like a waste of processing power.
More information about the Haskell-Cafe