Safe Haskell | None |
---|---|
Language | Haskell98 |
A module of concurrent higher order functions.
- data ExceptionList = ExceptionList [SomeException]
- data ConcException = ConcException
- assocFold :: forall a. (a -> a -> IO a) -> Array Int a -> IO a
- concF_ :: (?seq :: Bool) => Int -> (Int -> IO ()) -> IO ()
- conc_ :: (?seq :: Bool) -> Array Int (IO ()) -> IO ()
- concF :: (?seq :: Bool) => Int -> (Int -> IO e) -> IO (Array Int e)
- conc :: (?seq :: Bool) => Array Int (IO e) -> IO (Array Int e)
- concP :: (?seq :: Bool) => IO t -> IO t1 -> IO (t, t1)
- oneOfF :: Int -> (Int -> IO a) -> IO a
- oneOf :: Array Int (IO a) -> IO a
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.
assocFold :: forall a. (a -> a -> IO a) -> Array Int a -> IO a Source
Runs an associative folding function on the given list. 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 e) -> IO (Array Int e) Source
The next three 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.
These functions promise O(m f(n)/c) time, provided:
- unsafeFreeze does a pointer cast (which it doesn't)
- green threads are created on the same OS thread as the creating thread where possible
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.