ConcurrentUtils-0.4.4.0: Concurrent utilities

Safe HaskellTrustworthy
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 :: Concurrent (Kleisli m) => (b -> b -> m b) -> (c -> b) -> (b, Array Int c) -> m b Source

class Concurrent a where Source

A type class of arrows that support some form of concurrency.

Methods

arr_assocFold :: a (b, b) b -> (c -> b) -> a (b, Array Int c) 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.

arr_concF_ :: (?seq :: Bool) => a (t, Int) () -> a (t, Int) () Source

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

arr_concF :: (?seq :: Bool) => a (u, Int) t -> a (u, Int) (Array Int t) Source

arr_oneOfF :: a (u, Int) b -> a (u, Int) b Source

concF_ :: (?seq :: Bool, Concurrent (Kleisli m)) => Int -> (Int -> m ()) -> m () Source

concF :: (?seq :: Bool, Concurrent (Kleisli m)) => Int -> (Int -> m t) -> m (Array Int t) Source

conc_ :: (?seq :: Bool, Concurrent (Kleisli m)) => Array Int (m ()) -> m () Source

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

The next function takes 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.

concP :: (Monad m, Concurrent (Kleisli m)) => m t -> m t1 -> m (t, t1) Source

Version of concF specialized for two computations.

progressConcF :: (?seq :: Bool) => Int -> (Int -> IO t) -> IO (Array Int t) Source

oneOfF :: Concurrent (Kleisli m) => Int -> (Int -> m b) -> m b Source

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

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