simple-pool-0.1.0.0: a simple resource pool library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Pool

Description

A simple resource pool implementation.

Use newPool to construct a resource Pool of a certain size and use withResource to acquire and release resources.

Synopsis

A simple resource pool and its configuration

data Pool a Source #

a simple resource pool

Use newPool to construct a Pool

Constructors

UnsafeMkPool 

Fields

data PoolConfig a Source #

a simple resource pool config

Constructors

MkPoolConfig 

Fields

creating a pool

defaultPoolConfig Source #

Arguments

:: IO a

the action that creates a resource of type a

-> (a -> IO ())

the action that destroys a resource of type a

-> Int

the maximum amount of used resources. It needs to be at lest 0

-> PoolConfig a 

constructing a default PoolConfig

newPool :: MonadIO m => PoolConfig a -> m (Pool a) Source #

given a PoolConfig, create a new Pool

using a resource from a pool

withResource :: MonadUnliftIO m => Pool a -> (a -> m r) -> m r Source #

acquire a resource from a pool and run an action on it