Hoogle Search
Within LTS Haskell 24.40 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
addForeignPtrFinalizerEnv :: FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()base GHC.ForeignPtr Like addForeignPtrFinalizer but the finalizer is passed an additional environment parameter.
castForeignPtr :: ForeignPtr a -> ForeignPtr bbase GHC.ForeignPtr This function casts a ForeignPtr parameterised by one type into another type.
finalizeForeignPtr :: ForeignPtr a -> IO ()base GHC.ForeignPtr Causes the finalizers associated with a foreign pointer to be run immediately. The foreign pointer must not be used again after this function is called. If the foreign pointer does not support finalizers, this is a no-op.
mallocForeignPtr :: Storable a => IO (ForeignPtr a)base GHC.ForeignPtr Allocate some memory and return a ForeignPtr to it. The memory will be released automatically when the ForeignPtr is discarded. mallocForeignPtr is equivalent to
do { p <- malloc; newForeignPtr finalizerFree p }although it may be implemented differently internally: you may not assume that the memory returned by mallocForeignPtr has been allocated with malloc. GHC notes: mallocForeignPtr has a heavily optimised implementation in GHC. It uses pinned memory in the garbage collected heap, so the ForeignPtr does not require a finalizer to free the memory. Use of mallocForeignPtr and associated functions is strongly recommended in preference to newForeignPtr with a finalizer.mallocForeignPtrAlignedBytes :: Int -> Int -> IO (ForeignPtr a)base GHC.ForeignPtr This function is similar to mallocForeignPtrBytes, except that the size and alignment of the memory required is given explicitly as numbers of bytes.
mallocForeignPtrBytes :: Int -> IO (ForeignPtr a)base GHC.ForeignPtr This function is similar to mallocForeignPtr, except that the size of the memory required is given explicitly as a number of bytes.
mallocPlainForeignPtr :: Storable a => IO (ForeignPtr a)base GHC.ForeignPtr Allocate some memory and return a ForeignPtr to it. The memory will be released automatically when the ForeignPtr is discarded. GHC notes: mallocPlainForeignPtr has a heavily optimised implementation in GHC. It uses pinned memory in the garbage collected heap, as for mallocForeignPtr. Unlike mallocForeignPtr, a ForeignPtr created with mallocPlainForeignPtr carries no finalizers. It is not possible to add a finalizer to a ForeignPtr created with mallocPlainForeignPtr. This is useful for ForeignPtrs that will live only inside Haskell (such as those created for packed strings). Attempts to add a finalizer to a ForeignPtr created this way, or to finalize such a pointer, will throw an exception.
mallocPlainForeignPtrAlignedBytes :: Int -> Int -> IO (ForeignPtr a)base GHC.ForeignPtr This function is similar to mallocForeignPtrAlignedBytes, except that the internally an optimised ForeignPtr representation with no finalizer is used. Attempts to add a finalizer will cause an exception to be thrown.
mallocPlainForeignPtrBytes :: Int -> IO (ForeignPtr a)base GHC.ForeignPtr This function is similar to mallocForeignPtrBytes, except that the internally an optimised ForeignPtr representation with no finalizer is used. Attempts to add a finalizer will cause an exception to be thrown.
newConcForeignPtr :: Ptr a -> IO () -> IO (ForeignPtr a)base GHC.ForeignPtr Turns a plain memory reference into a foreign object by associating a finalizer - given by the monadic operation - with the reference. When finalization is triggered by GC, the storage manager will start the finalizer, in a separate thread, some time after the last reference to the ForeignPtr is dropped. There is no guarantee of promptness, and in fact there is no guarantee that the finalizer will eventually run at all for GC-triggered finalization. When finalization is triggered by explicitly calling finalizeForeignPtr, the finalizer will run immediately on the current Haskell thread. Note that references from a finalizer do not necessarily prevent another object from being finalized. If A's finalizer refers to B (perhaps using touchForeignPtr, then the only guarantee is that B's finalizer will never be started before A's. If both A and B are unreachable, then both finalizers will start together. See touchForeignPtr for more on finalizer ordering.