Safe Haskell | None |
---|---|
Language | Haskell2010 |
STM TMergeVar mini-abstraction
Synopsis
- data TMergeVar (m :: Type -> Type) a
- newTMergeVar :: forall (m :: Type -> Type) a. MonadSTM m => STM m (TMergeVar m a)
- writeTMergeVar :: forall (m :: Type -> Type) a. (MonadSTM m, Semigroup a) => TMergeVar m a -> a -> STM m a
- takeTMergeVar :: forall (m :: Type -> Type) a. MonadSTM m => TMergeVar m a -> STM m a
- tryReadTMergeVar :: forall (m :: Type -> Type) a. MonadSTM m => TMergeVar m a -> STM m (Maybe a)
Documentation
data TMergeVar (m :: Type -> Type) a Source #
The TMergeVar
is like a TMVar
in that we take it, leaving it empty.
Unlike an ordinary TMVar
with a blocking 'put' operation, it has a
non-blocking combining write operation: if a value is already present then
the values are combined using the Semigroup
operator.
This is used much like a TMVar
as a one-place queue between threads but
with the property that we can "improve" the current value (if any).