More Finaliser Trouble

Daan Leijen daanleijen at xs4all.nl
Sun Jul 13 08:15:40 EDT 2003


Hi Ashley,

You can use the newForeignPtr the is exported from the Concurrent
module (in ghc 6.0), this function has the same signature as the
old haskell function.  When switching to ghc 6.0 I changed:

import Foreign.ForeignPtr

to:

import Foreign.ForeignPtr hiding (newForeignPtr,addForeignPtrFinalizer)
import Foreign.Concurrent

And everything kept working fine :-)


Hope this helps, (allthough it doesn't answer the question of why these
things have
changed or how to add parameters to the new newForeignPtr function,)

  -- Daan


> -----Original Message-----
> From: ffi-admin at haskell.org [mailto:ffi-admin at haskell.org] On 
> Behalf Of Ashley Yakeley
> Sent: zondag 13 juli 2003 10:15
> To: Ffi at haskell.org
> Subject: More Finaliser Trouble
> 
> 
> How do I pass a parameter to a finaliser? The pointer itself does not 
> have enough information to run the finaliser, I need an extra 
> parameter 
> available at the time the pointer is created.
> 
> This was easy to do when I could write finalisers in Haskell, 
> of course, 
> since I could just apply the parameter to my finaliser 
> function to get a 
> finaliser that had the correct type. This is what it looked like:
> 
>   foreign import ccall "JVMBridge.h JVMBridge_DeleteGlobalRefGC"
>     rawDeleteGlobalRefGC :: JavaVM -> RawGlobalRef -> IO ();
> 
> 
>   vm <- rawGetJavaVM ?jvmenv;
>   gref <- newForeignPtr rgref (rawDeleteGlobalRefGC vm
>    (MkRawGlobalRef rgref));
>   return (MkVMRef gref);
> 
> But with the new FFI I can't do this so easily. How would I pass the 
> 'vm' parameter to a finaliser which is only allowed to look at the 
> 'rgref' pointer?
> 
> -- 
> Ashley Yakeley, Seattle WA
> 
> _______________________________________________
> FFI mailing list
> FFI at haskell.org
> http://www.haskell.org/mailman/listinfo/ffi
> 
> 





More information about the FFI mailing list