Fork me on GitHub

parallel-io

Haskell combinators for executing IO actions in parallel on a thread pool.

Description

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:

Example

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

Documentation

Download

Install with Cabal:

$ cabal install parallel-io

Download this project in either zip or tar formats.

Clone the project with Git:

$ git clone git://github.com/batterseapower/parallel-io

Alternatively, browse the source on GitHub

Authors

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.

Contact

All enquiries can be directed to the maintainer (Max Bolingbroke) via email.