-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Another fork of resource-pool, with a MonadIO and MonadCatch constraint
--
-- A fork of 'resource-pool' using MonadIO and exceptions.
--
-- The library also contains a number of fixes and enhancements which are
-- not yet included in a Hackage release of the original library. Apart
-- from that, this library is a drop-in replacement for 'resource-pool',
-- useful in cases where a more general monadic type is desirable.
@package ex-pool
@version 0.2
-- | 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
module Data.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 ()
-- | Destroys all resources currently not in use and removes them from the
-- pool.
--
-- Note that resources are automatically released when the Pool is
-- garbage-collected. This function is however useful in situations where
-- a Pool is explicitly discarded and resources should be freed
-- immediately.
purgePool :: Pool a -> IO ()
putResource :: MonadIO m => LocalPool a -> a -> m ()
takeResource :: MonadIO m => Pool a -> m (a, LocalPool a)
-- | A non-blocking version of takeResource. The
-- tryTakeResource function returns immediately, with
-- Nothing if the pool is exhausted, or Just (a,
-- LocalPool a) if a resource could be borrowed from the pool
-- successfully.
tryTakeResource :: MonadIO m => Pool a -> m (Maybe (a, LocalPool a))
-- | 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.
tryWithResource :: (MonadIO m, MonadMask m) => Pool a -> (a -> m b) -> m (Maybe b)
withResource :: (MonadIO m, MonadMask m) => Pool a -> (a -> m b) -> m b
instance Show (Pool a)