Contents

Description

Snapshotable STM variables

A SnapVar is like a TVar except that they have a context which can enable a snapshot mode. When in snapshot mode, the current values are not erased by writes. Instead each SnapVar can have 2 values: the value at the time of the snapshot and its current value.

There can be only a single snapshot at a time. When the snapshot mode is exited, the variables only keep the current value alive, not the snapshot one.

Synopsis

# Documentation

data SnapVar a Source #

A snapshot variable

Snapshot context

Create a new snapshot context

Create a new snapshot context

newSnapVarIO :: MonadIO m => SnapContext -> a -> m (SnapVar a) Source #

Create a new SnapVar

newSnapVar :: SnapContext -> a -> STM (SnapVar a) Source #

Create a new SnapVar

writeSnapVar :: SnapVar a -> a -> STM () Source #

Write a SnapVar

writeSnapVarIO :: MonadIO m => SnapVar a -> a -> m () Source #

Write a SnapVar

readSnapVar :: SnapVar a -> STM a Source #

readSnapVarIO :: MonadIO m => SnapVar a -> m a Source #

modifySnapVar :: SnapVar a -> (a -> a) -> STM a Source #

Modify a SnapVar

modifySnapVarIO :: MonadIO m => SnapVar a -> (a -> a) -> m a Source #

Modify a SnapVar

# Snapshot

withSnapshot :: MonadIO m => SnapContext -> m r -> m r Source #

Use a snapshot

Read the snapshot value of the variable.

Must be used in the context of a withSnapshot

readSnapshotIO :: MonadIO m => SnapVar a -> m a Source #

Read the snapshot value of the variable.

Must be used in the context of a withSnapshot