Safe Haskell | None |
---|
- parForM :: Int -> [a] -> (OutputStream c -> a -> IO b) -> IO ([InputStream c], IO [b])
Helpers for parallel scripting, i.e. prepping input to hydraPrint
parForM :: Int -> [a] -> (OutputStream c -> a -> IO b) -> IO ([InputStream c], IO [b])Source
A helper for parallel scripting. Run work items in parallel on N worker threads (a thread pool), creating only ONE output stream per worker, not one per parallel task. Specifically, each invocation of the user's function is given an OutputStream that it holds a lock on -- it is the only thread accessing that output stream.
This function returns immediately with
(1) a list of input streams that will carry results on the fly, as they are produced, and
(2) a barrier action that waits for all parallel work to be finished and yields the final results.
The first list is numWorkers
long, and the second is numTasks
.
Additional contracts: