X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FIORef.hs;h=6a27487460e13f13dfdf9e3d9611af0384ce23f0;hb=88f389fc1807aac92b4b026c2b09b2ec6266d05b;hp=f8857510e45109cbd42efe99189bef553a90562b;hpb=8afc9fecd586d3c4f7ef9c69fb1686a79e5f441d;p=ghc-base.git diff --git a/Data/IORef.hs b/Data/IORef.hs index f885751..6a27487 100644 --- a/Data/IORef.hs +++ b/Data/IORef.hs @@ -1,4 +1,5 @@ -{-# OPTIONS_GHC -XNoImplicitPrelude #-} +{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, UnboxedTuples #-} + ----------------------------------------------------------------------------- -- | -- Module : Data.IORef @@ -54,7 +55,8 @@ import NHC.IOExtras #endif #if defined(__GLASGOW_HASKELL__) && !defined(__PARALLEL_HASKELL__) --- |Make a 'Weak' pointer to an 'IORef' +-- |Make a 'Weak' pointer to an 'IORef', using the second argument as a finalizer +-- to run when 'IORef' is garbage-collected mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a)) mkWeakIORef r@(IORef (STRef r#)) f = IO $ \s -> case mkWeak# r# r f s of (# s1, w #) -> (# s1, Weak w #)