It is often useful to be able to execute a number of IO
actions in parallel, and then
either gather the results back up, or report completion of the actions. This package is designed to
support this scenario by providing a number of high-level combinators for enabling this parallelism
without any hard work on your part. Features include:
import Control.Concurrent.ParallelIO
import qualified Control.Concurrent.ParallelIO.Local as Local
main = do
-- Example with the global pool. You should call stopGlobalPool
-- after the last use of a global parallelism combinator - the
-- end of the main function is a fine place.
parallel_ [putStrLn "Hello", putStrLn "World"]
stopGlobalPool
-- Example of an explicitly sized and passed pool. Use 2 threads.
Local.withPool 2 $ \pool -> do
Local.parallel_ pool [putStrLn "Goodbype", putStrLn "World"]
We can run this like so to get our parallel goodness:
$ ghc -package parallel-io -threaded Example.hs -o Example $ ./Example +RTS -N2
Haddock documentation is available at Hackage.
Install with Cabal:
$ cabal install parallel-io
This package is heavily inspired by a thread on Haskell-Cafe. Thanks to Neil Mitchell and Bulat Ziganshin for their contributions in that thread - they form the code that this package is based on.
All enquiries can be directed to the maintainer (Max Bolingbroke) via email.