projects
/
ghc-base.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New asynchronous exception control API (base parts)
[ghc-base.git]
/
Foreign
/
Marshal
/
Pool.hs
diff --git
a/Foreign/Marshal/Pool.hs
b/Foreign/Marshal/Pool.hs
index
e7d2d8e
..
f15d048
100644
(file)
--- a/
Foreign/Marshal/Pool.hs
+++ b/
Foreign/Marshal/Pool.hs
@@
-48,8
+48,8
@@
module Foreign.Marshal.Pool (
import GHC.Base ( Int, Monad(..), (.), not )
import GHC.Err ( undefined )
import GHC.Exception ( throw )
import GHC.Base ( Int, Monad(..), (.), not )
import GHC.Err ( undefined )
import GHC.Exception ( throw )
-import GHC.IOBase ( IO, IORef, newIORef, readIORef, writeIORef,
- block, unblock, catchAny )
+import GHC.IO ( IO, mask, catchAny )
+import GHC.IORef ( IORef, newIORef, readIORef, writeIORef )
import GHC.List ( elem, length )
import GHC.Num ( Num(..) )
#else
import GHC.List ( elem, length )
import GHC.Num ( Num(..) )
#else
@@
-57,7
+57,7
@@
import Data.IORef ( IORef, newIORef, readIORef, writeIORef )
#if defined(__NHC__)
import IO ( bracket )
#else
#if defined(__NHC__)
import IO ( bracket )
#else
-import Control.Exception ( bracket )
+import Control.Exception.Base ( bracket )
#endif
#endif
#endif
#endif
@@
-97,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!
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 <- catchAny
pool <- newPool
val <- catchAny
- (unblock (act pool))
+ (restore (act pool))
(\e -> do freePool pool; throw e)
freePool pool
return val)
(\e -> do freePool pool; throw e)
freePool pool
return val)
@@
-143,7
+143,7
@@
pooledRealloc = pr undefined
pooledReallocBytes :: Pool -> Ptr a -> Int -> IO (Ptr a)
pooledReallocBytes (Pool pool) ptr size = do
let cPtr = castPtr ptr
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)
newPtr <- reallocBytes cPtr size
ptrs <- readIORef pool
writeIORef pool (newPtr : delete cPtr ptrs)