lvar-0.2.0.0: TMVar that can be listened to
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.LVar

Description

LVar is like Control.Concurrent.STM.TMVar but with a capability for listening to its changes.

Synopsis

Types

data LVar a Source #

Creating a LVar

new :: forall a m. MonadIO m => a -> m (LVar a) Source #

Create a new LVar with the given initial value

empty :: MonadIO m => m (LVar a) Source #

Like new, but there is no initial value. A get will block until an initial value is set using set or modify

Modifying a LVar

get :: MonadIO m => LVar a -> m a Source #

Get the value of the LVar

set :: MonadIO m => LVar a -> a -> m () Source #

Set the LVar value; active listeners are automatically notifed.

modify :: MonadIO m => LVar a -> (a -> a) -> m () Source #

Modify the LVar value; active listeners are automatically notified.

Listening to a LVar

listenNext :: MonadIO m => LVar a -> m a Source #

Listen for the next value update (since the last listenNext or addListener).