Safe Haskell | Trustworthy |
---|---|
Language | Haskell98 |
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 monad-par
and
meta-par
packages and papers:
Unlike the IVar
type provided by monad-par
, the IVar
type
provided in this module permits repeated put
s of the same value, in
keeping with the lattice-based semantics of LVars in which a put
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 ()
Documentation
LVarWBottom IVar | |
LVarData1 IVar | An |
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) | |
type LVContents IVar a = () | |
type FrzType (IVar s a) = IVar Frzn (FrzType a) |
Basic IVar operations, same as in monad-par
get :: IVar s a -> Par d s a Source
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
IVar.
put_ :: Eq a => IVar s a -> a -> Par d s () Source
Put a value into an IVar. Multiple put
s 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
spawn :: (Eq a, NFData a) => Par d s a -> Par d s (IVar s a) Source
A simple future represented as an IVar. The result is fully evaluated before the child computation returns.
LVar-style operations
freezeIVar :: IVar s a -> Par QuasiDet s (Maybe a) Source
A specialized freezing operation for IVars that leaves the result in a handy format (Maybe
).