Stability | experimental |
---|---|
Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
Safe Haskell | Trustworthy |
This is a wrapped version of Control.Concurrent.SampleVar with types
generalised from IO
to all monads in MonadBase
.
- data SampleVar a
- newEmptySampleVar :: MonadBase IO m => m (SampleVar a)
- newSampleVar :: MonadBase IO m => a -> m (SampleVar a)
- emptySampleVar :: MonadBase IO m => SampleVar a -> m ()
- readSampleVar :: MonadBase IO m => SampleVar a -> m a
- writeSampleVar :: MonadBase IO m => SampleVar a -> a -> m ()
- isEmptySampleVar :: MonadBase IO m => SampleVar a -> m Bool
Documentation
data SampleVar a
Sample variables are slightly different from a normal MVar
:
- Reading an empty
SampleVar
causes the reader to block. (same astakeMVar
on emptyMVar
) - Reading a filled
SampleVar
empties it and returns value. (same astakeMVar
) - Writing to an empty
SampleVar
fills it with a value, and potentially, wakes up a blocked reader (same as forputMVar
on emptyMVar
). - Writing to a filled
SampleVar
overwrites the current value. (different fromputMVar
on fullMVar
.)
newEmptySampleVar :: MonadBase IO m => m (SampleVar a)Source
Generalized version of newEmptySampleVar
.
newSampleVar :: MonadBase IO m => a -> m (SampleVar a)Source
Generalized version of newSampleVar
.
emptySampleVar :: MonadBase IO m => SampleVar a -> m ()Source
Generalized version of emptySampleVar
.
readSampleVar :: MonadBase IO m => SampleVar a -> m aSource
Generalized version of readSampleVar
.
writeSampleVar :: MonadBase IO m => SampleVar a -> a -> m ()Source
Generalized version of writeSampleVar
.
isEmptySampleVar :: MonadBase IO m => SampleVar a -> m BoolSource
Generalized version of isEmptySampleVar
.