Commit 58a05f60 authored by simonmar's avatar simonmar
Browse files

[project @ 2004-03-24 16:59:51 by simonmar]

Add caveat about finalizers (don't refer to Handles from finalizers).
parent 0dd193b7
......@@ -145,6 +145,12 @@ addForeignPtrConcFinalizer :: ForeignPtr a -> IO () -> IO ()
-- is an arbitrary @IO@ action. When it is invoked, the finalizer
-- will run in a new thread.
--
-- NB. Be very careful with these finalizers. One common trap is that
-- if a finalizer references another finalized value, it does not
-- prevent that value from being finalized. In particular, 'Handle's
-- are finalized objects, so a finalizer should not refer to a 'Handle'
-- (including @stdout@, @stdin@ or @stderr@).
--
addForeignPtrConcFinalizer f@(ForeignPtr fo r) finalizer = do
fs <- readIORef r
writeIORef r (finalizer : fs)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment