unliftio-messagebox-2.0.0: Fast and robust message queues for concurrent processes
Safe HaskellNone
LanguageHaskell2010

UnliftIO.MessageBox.Util.Fresh

Description

Threadsafe, shared, atomic counters

This is based on Data.Atomics.Counter.

Synopsis

Documentation

fresh :: forall a env m. (MonadReader env m, MonadIO m, HasCounterVar a env, Coercible a Int) => m a Source #

A threadsafe atomic a

Atomically increment and get the value of the Counter for type a that must be present in the env.

incrementAndGet :: forall a m. (MonadIO m, Coercible a Int) => CounterVar a -> m a Source #

Atomically increment and get the value of the Counter for type a that must be present in the env.

newCounterVar :: forall a m. MonadIO m => m (CounterVar a) Source #

Create a new CounterVar starting at 0.

class HasCounterVar a env | env -> a where Source #

A type class for MonadReader based applications.

Methods

getCounterVar :: env -> CounterVar a Source #

Instances

Instances details
HasCounterVar (t :: k) (CounterVar t) Source # 
Instance details

Defined in UnliftIO.MessageBox.Util.Fresh