parallel-io-0.2.1: Combinators for executing IO actions in parallel on a thread pool.

Control.Concurrent.ParallelIO.Global

Description

Parallelism combinators with an implicit global thread-pool.

The most basic example of usage is:

 main = parallel_ [putStrLn "Echo", putStrLn " in parallel"] >> stopGlobalPool

Make sure that you compile with -threaded and supply +RTS -N2 -RTS to the generated Haskell executable, or you won't get any parallelism.

The Control.Concurrent.ParallelIO.Local module provides a more general interface which allows explicit passing of pools and control of their size. This module is implemented on top of that one by maintaining a shared global thread pool with one thread per capability.

Synopsis

Documentation

stopGlobalPool :: IO ()Source

In order to reliably make use of the global parallelism combinators, you must invoke this function after all calls to those combinators have finished. A good choice might be at the end of main.

See also stopPool.

extraWorkerWhileBlocked :: IO () -> IO ()Source

Wrap any IO action used from your worker threads that may block with this method: it temporarily spawns another worker thread to make up for the loss of the old blocked worker.

See also extraWorkerWhileBlocked.

spawnPoolWorker :: IO ()Source

Internal method for adding extra unblocked threads to a pool if one is going to be temporarily blocked.

See also spawnPoolWorkerFor.

killPoolWorker :: IO ()Source

Internal method for removing threads from a pool after we become unblocked.

See also killPoolWorkerFor.

parallel_ :: [IO a] -> IO ()Source

Execute the given actions in parallel on the global thread pool.

See also parallel_.

parallel :: [IO a] -> IO [a]Source

Execute the given actions in parallel on the global thread pool, returning the results in the same order as the corresponding actions.

See also parallel.

parallelInterleaved :: [IO a] -> IO [a]Source

Execute the given actions in parallel on the global thread pool, returning the results in the approximate order of completion.

See also parallelInterleaved.