|
|
|
| Description |
This module describes an abstract pool of any connections (to DB, cache backend or anything). One will create a pool with
pool <- emptyPool 20
(that opens 20 connections), and then
(idx, pool) <- acquire someConfig connectFunction -- Get open connection or create a new one
doSomethingWith conn
free pool idx conn -- Free a connection, so it may be used again by other threads
|
|
| Synopsis |
|
|
|
| Documentation |
|
| type Pool a = [PoolItem a] |
| Pool itself
|
|
| type MPool a = MVar (Pool a) |
| Mutable pool
|
|
| emptyPool :: Int -> IO (MPool a) |
| Return an empty pool with N items
|
|
| acquire |
| :: | | | => MPool a | Pool
| | -> c | Some data for connect
| | -> c -> IO a | Actual connect function
| | -> IO (Int, a) | (Index in the pool, connection)
| | Get connection from pool
|
|
|
| free |
| :: | | | => MPool a | Pool
| | -> Int | Index in the pool
| | -> a | Connection
| | -> IO () | | | Free connection
|
|
|
| freeAll |
| :: | | | => MPool a | Pool
| | -> a -> IO () | Disconnect function
| | -> IO () | | | Free (actually, disconnect) all connections in the pool
|
|
|
| garbageCollector |
| :: | | | => MPool a | Pool
| | -> a -> IO () | Connection close function
| | -> IO () | | | Run GC thread, which closes unused connections
|
|
|
| Produced by Haddock version 2.4.2 |