pooled-io-0.0.0.1: Run jobs on a limited number of threads and support data dependencies

Safe HaskellSafe

Control.Concurrent.PooledIO.Final

Description

This module implements something similar to Control.Concurrent.PooledIO.InOrder, but since it is restricted to an Applicative interface we can implement it without unsafeInterleaveIO.

Synopsis

Documentation

data T a Source

Instances

run :: T a -> IO aSource

runLimited with a maximum of numCapabilites threads.

runLimited :: Int -> T a -> IO aSource

runLimited n runs several actions in a pool with at most n threads.

fork :: NFData a => IO a -> T aSource

This runs an action parallelly to the starting thread. Since it is an Applicative Functor and not a Monad, there are no data dependencies between the actions and thus all actions in a T can be run parallelly. Only the IO actions are parallelised but not the combining function passed to liftA2 et.al. That is, the main work must be done in the IO actions in order to benefit from parallelisation.