[Haskell-cafe] ForeignPtrs with liveness dependencies
Einar Karttunen
ekarttun at cs.helsinki.fi
Mon Jul 25 09:43:37 EDT 2005
Hello
What is the correct way to express liveness dependencies for
ForeignPtrs? I am wrapping a C library and need a way to keep
ForeignPtrs alive until the finalizer for an another ForeignPtr
has been executed.
Basically I have two types, ForeignPtr A and ForeignPtr B and a function
associate :: ForeignPtr A -> ForeignPtr B -> IO (). I want to keep all
of the ForeignPtr Bs associated with a given ForeignPtr A alive until its
finalizer has been run. The relationship is M:N - each ForeignPtr A may
be associated with multiple ForeignPtr B and each ForeignPtr B may be
associated with multiple ForeignPtr A.
GHC documentation tells that touchForeignPtr is not enough as it makes
no guarantees about when the finalizers are run. If it helps the
finalizers are C functions which neither block nor perform callbacks
into Haskell.
- Einar Karttunen
More information about the Haskell-Cafe
mailing list