Portability | portable |
---|---|
Stability | experimental |
Maintainer | Kim Altintop <[email protected]> |
Safe Haskell | None |
Data.Pool
Description
A high-performance striped pooling abstraction for managing flexibly-sized collections of resources such as database connections.
This module is based on resource-pool
. For more comprehensive
documentation, please refer to the original package:
http://hackage.haskell.org/package/resource-pool
- data Pool a
- data LocalPool a
- createPool :: IO a -> (a -> IO ()) -> Word32 -> NominalDiffTime -> Word32 -> IO (Pool a)
- destroyResource :: MonadIO m => Pool a -> LocalPool a -> a -> m ()
- purgePool :: Pool a -> IO ()
- putResource :: MonadIO m => LocalPool a -> a -> m ()
- takeResource :: MonadIO m => Pool a -> m (a, LocalPool a)
- tryTakeResource :: MonadIO m => Pool a -> m (Maybe (a, LocalPool a))
- tryWithResource :: (MonadIO m, MonadCatch m) => Pool a -> (a -> m b) -> m (Maybe b)
- withResource :: (MonadIO m, MonadCatch m) => Pool a -> (a -> m b) -> m b
Documentation
destroyResource :: MonadIO m => Pool a -> LocalPool a -> a -> m ()Source
putResource :: MonadIO m => LocalPool a -> a -> m ()Source
takeResource :: MonadIO m => Pool a -> m (a, LocalPool a)Source
tryTakeResource :: MonadIO m => Pool a -> m (Maybe (a, LocalPool a))Source
A non-blocking version of takeResource
. The tryTakeResource
function
returns immediately, with Nothing
if the pool is exhausted, or
if a resource could be borrowed from the pool successfully.
Just
(a,
LocalPool
a)
tryWithResource :: (MonadIO m, MonadCatch m) => Pool a -> (a -> m b) -> m (Maybe b)Source
Similar to withResource
, but only performs the action if a resource could
be taken from the pool without blocking. Otherwise, tryWithResource
returns immediately with Nothing
(ie. the action function is not called).
Conversely, if a resource can be borrowed from the pool without blocking, the
action is performed and it's result is returned, wrapped in a Just
.
withResource :: (MonadIO m, MonadCatch m) => Pool a -> (a -> m b) -> m bSource