Data.Pool
Contents
- data Pool a
- createPool :: (MonadBaseControl IO m, MonadIO m) => IO a -> (a -> IO ()) -> Int -> (Pool a -> m b) -> m b
- createPoolCheckAlive :: (MonadBaseControl IO m, MonadIO m) => IO a -> (a -> IO ()) -> Int -> (Pool a -> m b) -> (a -> IO Bool) -> m b
- withPool :: (MonadIO m, MonadBaseControl IO m) => Pool a -> (a -> m b) -> m (Maybe b)
- withPool' :: (MonadBaseControl IO m, MonadIO m) => Pool a -> (a -> m b) -> m b
- withPoolAllocate :: (MonadIO m, MonadBaseControl IO m) => Pool a -> (a -> m b) -> m b
- data PoolStats = PoolStats {}
- poolStats :: Pool a -> IO PoolStats
Creation
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => IO a | new resource creator |
| -> (a -> IO ()) | resource deallocator |
| -> Int | maximum number of resources to allow in pool |
| -> (Pool a -> m b) | inner function to run with the pool |
| -> m b |
Create a new pool without any resource alive checking.
Arguments
| :: (MonadBaseControl IO m, MonadIO m) | |
| => IO a | new resource creator |
| -> (a -> IO ()) | resource deallocator |
| -> Int | maximum number of resource to allow in pool |
| -> (Pool a -> m b) | inner function to run with the pool |
| -> (a -> IO Bool) | is the resource alive? |
| -> m b |
Create a new pool, including a function to check if a resource is still alive. Stale resources will automatically be removed from the pool.
Usage
withPool' :: (MonadBaseControl IO m, MonadIO m) => Pool a -> (a -> m b) -> m bSource
This function throws a PoolExhaustedException when no resources are
available. See withPoolAllocate to avoid this.
withPoolAllocate :: (MonadIO m, MonadBaseControl IO m) => Pool a -> (a -> m b) -> m bSource
Same as withPool', but instead of throwing a PoolExhaustedException
when there the maximum number of resources are created and allocated, it
allocates a new resource, passes it to the subprocess and then frees it.
Diagnostics
Constructors
| PoolStats | |
Fields
| |