Control.Concurrent.Pool
- class (Monad m, MonadIO m) => Task m a r where
- data Task m a r => Pool m a r
- newPool :: Task m a r => Int -> Bool -> m (Pool m a r)
- newPoolIO :: Task m a r => Int -> Bool -> IO (Pool m a r)
- isPoolWaiting :: Task m a r => Pool m a r -> IO Bool
- queue :: Task m a r => Pool m a r -> m r -> a -> m Integer
- noMoreTasks :: Task m a r => Pool m a r -> m ()
- noMoreTasksIO :: Task m a r => Pool m a r -> IO ()
- readResult :: Task m a r => Pool m a r -> m (Integer, r)
- resultsReader :: Task m a r => Pool m a r -> (Integer -> r -> IO b) -> IO ()
- waitFor :: Task m a r => Pool m a r -> m ()
- waitForIO :: Task m a r => Pool m a r -> IO ()
- waitForTasks :: Task m a r => Pool m a r -> [Integer] -> m ()
- terminatePool :: Task m a r => Pool m a r -> m ()
- terminatePoolIO :: Task m a r => Pool m a r -> IO ()
Documentation
class (Monad m, MonadIO m) => Task m a r whereSource
Any monadic computation that can be turned to IO
Arguments
:: Task m a r | |
=> Int | Number of threads in the pool |
-> Bool | Should pool return tasks' results? |
-> m (Pool m a r) |
Create new threads pool
Arguments
:: Task m a r | |
=> Int | Number of threads in the pool |
-> Bool | Should pool return tasks' results? |
-> IO (Pool m a r) |
Create new threads pool in IO monad
Check if pool is waiting for new tasks
Arguments
:: Task m a r | |
=> Pool m a r | Pool of threads |
-> m r | Task (monadic computation) |
-> a | Argument for that computation |
-> m Integer | Returns a number of task in the pool |
Put the new task into queue
noMoreTasks :: Task m a r => Pool m a r -> m ()Source
Tell to the pool that there will no new tasks
noMoreTasksIO :: Task m a r => Pool m a r -> IO ()Source
Tell to the pool that there will no new tasks, in IO monad
Read next result from the pool. This makes sense only if for pool which returns results.
resultsReader :: Task m a r => Pool m a r -> (Integer -> r -> IO b) -> IO ()Source
Read all results from pool and run given computation with each. Probably you will run this in the separate thread (using forkIO). This makes sense only if for pool which returns results.
terminatePool :: Task m a r => Pool m a r -> m ()Source
Terminate all threads in the pool