Safe Haskell | None |
---|---|
Language | Haskell98 |
This module exposes the internals of the Par
monad so that you
can build your own scheduler or other extensions. Do not use this
module for purposes other than extending the Par
monad with new
functionality.
Synopsis
- data Trace
- data Sched = Sched {}
- newtype Par a = Par {}
- newtype IVar a = IVar (IORef (IVarContents a))
- data IVarContents a
- sched :: Bool -> Sched -> Trace -> IO ()
- runPar :: Par a -> a
- runParIO :: Par a -> IO a
- runParAsync :: Par a -> a
- new :: Par (IVar a)
- newFull :: NFData a => a -> Par (IVar a)
- newFull_ :: a -> Par (IVar a)
- get :: IVar a -> Par a
- put_ :: IVar a -> a -> Par ()
- put :: NFData a => IVar a -> a -> Par ()
- pollIVar :: IVar a -> IO (Maybe a)
- yield :: Par ()
- fixPar :: (a -> Par a) -> Par a
- data FixParException = FixParException
Documentation
IVar (IORef (IVarContents a)) |
Run a parallel, deterministic computation and return its result.
Note: you must NOT return an IVar in the output of the parallel
computation. This is unfortunately not enforced, as it is with
runST
or with newer libraries that export a Par monad, such as
lvish
.
runParIO :: Par a -> IO a Source #
A version that avoids an internal unsafePerformIO
for calling
contexts that are already in the IO
monad.
Returning any value containing IVar is still disallowed, as it can compromise type safety.
runParAsync :: Par a -> a Source #
An asynchronous version in which the main thread of control in a Par computation can return while forked computations still run in the background.
get :: IVar a -> Par a Source #
Read the value in an IVar
. The get
operation can only return when the
value has been written by a prior or parallel put
to the same
IVar
.
put :: NFData a => IVar a -> a -> Par () Source #
Put a value into an IVar
. Multiple put
s to the same IVar
are not allowed, and result in a runtime error.
put
fully evaluates its argument, which therefore must be an
instance of NFData
. The idea is that this forces the work to
happen when we expect it, rather than being passed to the consumer
of the IVar
and performed later, which often results in less
parallelism than expected.
Sometimes partial strictness is more appropriate: see put_
.
Allows other parallel computations to progress. (should not be necessary in most cases).
fixPar :: (a -> Par a) -> Par a Source #
Take the monadic fixpoint of a Par
computation. This is
the definition of mfix
for Par
. Throws FixParException
if the result is demanded strictly within the computation.
data FixParException Source #
Instances
Show FixParException Source # | |
Defined in Control.Monad.Par.Scheds.TraceInternal showsPrec :: Int -> FixParException -> ShowS # show :: FixParException -> String # showList :: [FixParException] -> ShowS # | |
Exception FixParException Source # | |