addForeignPtrFinalizer

Simon Marlow simonmar at microsoft.com
Fri Sep 27 10:27:20 EDT 2002


> On Fri, Sep 27, 2002 at 12:25:31PM +0100, Simon Marlow wrote:
> > Then I'll reformulate my question as a patch.  Enclosed is a
> > proof-of-concept patch that implements Haskell finalizers 
> in Hugs, which
> > works on some simple tests that I've run.  There's nothing 
> particularly
> > clever going on - I'm just suspending execution of the 
> finalizers until
> > the next call to eval().
> 
> It seems to have problems if more than one finalizer is 
> pending, probably
> because runIO() calls eval():
> 
> t = do
>         sequence_ (map f [1..30]) 
>         performGC
>   where f n = do
>           p <- mallocBytes 64
>           newForeignPtr p $ do
>                 free p
>                 putStrLn ("finalize " ++ show n) 

Looks like I missed out a pop() - the enclosed patch works with your
example.  (I'm not very familiar with the internals of Hugs).

Cheers,
	Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch
Type: application/octet-stream
Size: 9506 bytes
Desc: patch
Url : http://www.haskell.org//pipermail/ffi/attachments/20020927/81f618de/patch.obj


More information about the FFI mailing list