Re: Finalizers and FFI

2004-06-10 Thread Gracjan Polak
Arjan van IJzendoorn wrote: I couldn't get finalisers to work either with the newForeignPtr from this module. I didn't know how to create a proper FunPtr. In Foreign.Concurrent there is a newForeignPtr that is easier to use: [deleted] So here is the new code: {-# OPTIONS -fglasgow-exts #-}

Re: Finalizers and FFI

2004-06-10 Thread Alastair Reid
[program deleted] So, this basically means that my finalizer did not get run :( [...] It should run, in separate thread or not, it doesn't matter here. Any ideas why doesn't it work? Hopefully the GHC folk will correct me if I'm wrong but I think what happens is: - you allocate object

Re: Finalizers and FFI

2004-06-10 Thread Gracjan Polak
Alastair Reid wrote: You could give the finalizer thread a chance to run by calling Control.Concurrent.yield before exiting: Thanks, it worked. This is ok for me, because my finalizer only closes some handles. Those are closed at program end anyway, so in this case I can live with it. BUT:

Re: Finalizers and FFI

2004-06-10 Thread MR K P SCHUPKE
I don't see why GHC can't have a 'callAllOutstandingFinalizers' call as part of _exit() or something... Keean. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Re: GMP

2004-06-10 Thread Serge D. Mechveliani
On Wed, Jun 09, 2004 at 05:14:45PM -0700, John Meacham wrote: I was curious what the best way would be to access the various useful GMP functions which are not exported for Integers. I was thinking of making my own (strict) Integer type, but it would be much easier if I can just use the FFI to

Re: Finalizers and FFI

2004-06-10 Thread Gracjan Polak
Alastair Reid wrote: import Foreign.ForeignPtr I couldn't get finalisers to work either with the newForeignPtr from this module. I didn't know how to create a proper FunPtr. You create a FunPtr using foreign import: foreign import ccall malloc.h free free_ptr :: FunPtr (Ptr a - IO ()) foreign

Re: Finalizers and FFI

2004-06-10 Thread Alastair Reid
BUT: This can make some people unhappy. Isn't there a more deterministic way to schedule finalizers? I wrote the Hugs version which does try to be more deterministic so I'm probably not the best qualified to write about what's wrong with GHC :-) But, I think part of the problem is that GHC

Re: Finalizers and FFI

2004-06-10 Thread Alastair Reid
On Thursday 10 June 2004 12:07, MR K P SCHUPKE wrote: I don't see why GHC can't have a 'callAllOutstandingFinalizers' call as part of _exit() or something... You can do that if your finalizers are written in C (and don't call back into Haskell) but if they are written in Haskell then you