IVars are the very simplest form of LVars. They are either empty or full, and contain at most a single value.
For further information on using IVars in Haskell, see the
meta-par packages and papers:
IVar type provided by
provided in this module permits repeated
puts of the same value, in
keeping with the lattice-based semantics of LVars in which a
takes the least upper bound of the old and new values.
- newtype IVar s a = IVar (LVar s (IORef (Maybe a)) a)
- new :: Par d s (IVar s a)
- get :: IVar s a -> Par d s a
- put :: (Eq a, NFData a) => IVar s a -> a -> Par d s ()
- put_ :: Eq a => IVar s a -> a -> Par d s ()
- spawn :: (Eq a, NFData a) => Par d s a -> Par d s (IVar s a)
- spawn_ :: Eq a => Par d s a -> Par d s (IVar s a)
- spawnP :: (Eq a, NFData a) => a -> Par d s (IVar s a)
- freezeIVar :: IVar s a -> Par QuasiDet s (Maybe a)
- fromIVar :: IVar Frzn a -> Maybe a
- whenFull :: Maybe HandlerPool -> IVar s a -> (a -> Par d s ()) -> Par d s ()
|Foldable (IVar Trvrsbl)|
|Eq (IVar s a)|
Physical equality, just as with
|Show a => Show (IVar Trvrsbl a)|
For convenience only; the user could define this.
|Show a => Show (IVar Frzn a)|
|DeepFrz a => DeepFrz (IVar s a)|
Basic IVar operations, same as in monad-par
Read the value in a IVar. The
get can only return when the
value has been written by a prior or concurrent
put to the same
Put a value into an IVar. Multiple
puts to the same IVar
are not allowed, and result in a runtime error, unless the values put happen to be
This function is always at least strict up to WHNF in the element put.
Derived IVar operations, same as in monad-par
A simple future represented as an IVar. The result is fully evaluated before the child computation returns.
A version of
spawn that uses only WHNF, rather than full
A specialized freezing operation for IVars that leaves the result in a handy format (
Unpack a frozen IVar (as produced by a generic
freeze operation) as a more
palatable data structure.