ForeignPtr and -threaded
PHO
phonohawk at ps.sakura.ne.jp
Sun Jul 22 09:36:27 EDT 2007
Hi,
I have encountered a weird behavior of ForeignPtr. I want to know how
to work around this. I am using GHC 6.6.1 on Darwin.
[1] Foreign.Concurrent
The following code prints "called" when it is linked with -threaded
RTS, but it prints nothing when it isn't.
import Foreign.Marshal.Alloc
import qualified Foreign.Concurrent as Conc
main = do mem <- mallocBytes 10
Conc.newForeignPtr mem $ print "called"
[2] Foreign.ForeignPtr
The following code prints nothing when it isn't linked with -threaded
RTS, but when it is, it *sometimes* prints "called" but not always.
import Foreign.Marshal.Alloc
import Foreign.Ptr
import Foreign.ForeignPtr
foreign import ccall "wrapper"
mkFinalizer :: (Ptr () -> IO ()) -> IO (FunPtr (Ptr () -> IO ()))
main = do mem <- mallocBytes 10
fin <- mkFinalizer $ \ _ -> print "called"
newForeignPtr fin mem
_______________________________________________________
- PHO - http://ccm.sherry.jp/
OpenPGP public key: 1024D/1A86EF72
Fpr: 5F3E 5B5F 535C CE27 8254 4D1A 14E7 9CA7 1A86 EF72
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20070722/86f8c434/attachment.bin
More information about the Glasgow-haskell-users
mailing list