ConcurrentUtils-0.4.2.0: Concurrent utilities

Safe HaskellNone
LanguageHaskell98

Control.CUtils.Conc

Description

A module of concurrent higher order functions.

Synopsis

Documentation

data ExceptionList Source

For exceptions caused by caller code.

data ConcException Source

For internal errors. If a procedure throws this, some threads it created may still be running. It is thrown separately from ExceptionList.

Constructors

ConcException 

assocFold :: forall a b. (b -> b -> IO b) -> (a -> b) -> b -> Array Int a -> IO b Source

Runs an associative folding function on the given array. Note: this function only spawns enough threads to make effective use of the capabilities. Any two list elements may be processed sequentially or concurrently. To get parallelism, you have to set the numCapabilities value, e.g. using GHC's +RTS -N flag.

concF_ :: (?seq :: Bool) => Int -> (Int -> IO ()) -> IO () Source

conc_ :: (?seq :: Bool) -> Array Int (IO ()) -> IO () Source

concF :: (?seq :: Bool) => Int -> (Int -> IO e) -> IO (Array Int e) Source

The next two functions take an implicit parameter ?seq. Set it to True if you want to only spawn threads for the capabilities (same as assocFold, good for speed). If you need all the actions to be executed concurrently, set it to False.

n is the number of computations which are indexed from 0 to n - 1.

conc :: (?seq :: Bool) => Array Int (IO e) -> IO (Array Int e) Source

Runs several computations concurrently, and returns their results as an array. Waits for all threads to end before returning.

concP :: IO t -> IO t1 -> IO (t, t1) Source

Version of concF specialized for two computations.

oneOfF :: Int -> (Int -> IO a) -> IO a Source

oneOf :: Array Int (IO a) -> IO a Source

Runs several computations in parallel, and returns one of their results (terminating the other computations).