ForeignPtr and -threaded

Ian Lynagh igloo at earth.li
Mon Jul 23 04:22:01 EDT 2007


On Mon, Jul 23, 2007 at 11:07:40AM +0900, PHO wrote:
> 
> same. The documentations of both Foreign.ForeignPtr (*1) and
> Foreign.Concurrent (*2) say "The only guarantee is that the finalizer
> runs before the program terminates."

That's a documentation bug. In the HEAD it says:

newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
-- ^Turns a plain memory reference into a foreign pointer, and
-- associates a finaliser with the reference.  The finaliser will be executed
-- after the last reference to the foreign object is dropped.  Note that there
-- is no guarantee on how soon the finaliser is executed after the last
-- reference was dropped; this depends on the details of the Haskell storage
-- manager.  Indeed, there is no guarantee that the finalizer is executed at
-- all; a program may exit with finalizers outstanding.  (This is true
-- of GHC, other implementations may give stronger guarantees).


Thanks
Ian



More information about the Glasgow-haskell-users mailing list