X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Foreign%2FMarshal%2FPool.hs;h=f15d048a9518b13a2cdb2f0f82d311a993e47f5a;hb=4c29f6f110d23b890567b8696a964bb212eba52e;hp=3f7e2d50da487594b19e591fca5652096bfb24ee;hpb=c01a362a8cf718ff2ed317846022a3e8fa26c420;p=ghc-base.git diff --git a/Foreign/Marshal/Pool.hs b/Foreign/Marshal/Pool.hs index 3f7e2d5..f15d048 100644 --- a/Foreign/Marshal/Pool.hs +++ b/Foreign/Marshal/Pool.hs @@ -1,4 +1,4 @@ -{-# OPTIONS_GHC -fno-implicit-prelude #-} +{-# OPTIONS_GHC -XNoImplicitPrelude #-} -------------------------------------------------------------------------------- -- | -- Module : Foreign.Marshal.Pool @@ -45,10 +45,11 @@ module Foreign.Marshal.Pool ( ) where #ifdef __GLASGOW_HASKELL__ -import GHC.Base ( Int, Monad(..), IsString(..), (.), not ) +import GHC.Base ( Int, Monad(..), (.), not ) import GHC.Err ( undefined ) -import GHC.Exception ( block, unblock, throw, catchException ) -import GHC.IOBase ( IO, IORef, newIORef, readIORef, writeIORef, ) +import GHC.Exception ( throw ) +import GHC.IO ( IO, mask, catchAny ) +import GHC.IORef ( IORef, newIORef, readIORef, writeIORef ) import GHC.List ( elem, length ) import GHC.Num ( Num(..) ) #else @@ -56,7 +57,7 @@ import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) #if defined(__NHC__) import IO ( bracket ) #else -import Control.Exception ( bracket ) +import Control.Exception.Base ( bracket ) #endif #endif @@ -96,10 +97,10 @@ freePool (Pool pool) = readIORef pool >>= freeAll withPool :: (Pool -> IO b) -> IO b #ifdef __GLASGOW_HASKELL__ withPool act = -- ATTENTION: cut-n-paste from Control.Exception below! - block (do + mask (\restore -> do pool <- newPool - val <- catchException - (unblock (act pool)) + val <- catchAny + (restore (act pool)) (\e -> do freePool pool; throw e) freePool pool return val) @@ -142,7 +143,7 @@ pooledRealloc = pr undefined pooledReallocBytes :: Pool -> Ptr a -> Int -> IO (Ptr a) pooledReallocBytes (Pool pool) ptr size = do let cPtr = castPtr ptr - throwIf (not . (cPtr `elem`)) (\_ -> "pointer not in pool") (readIORef pool) + _ <- throwIf (not . (cPtr `elem`)) (\_ -> "pointer not in pool") (readIORef pool) newPtr <- reallocBytes cPtr size ptrs <- readIORef pool writeIORef pool (newPtr : delete cPtr ptrs)