polysemy-conc-0.13.0.0: Polysemy effects for concurrency
Safe HaskellSafe-Inferred
LanguageGHC2021

Polysemy.Conc.Sync

Description

 
Synopsis

Documentation

clear :: forall a r. Member (Sync a) r => Sem r () Source #

Remove the content of the Sync variable if it is present.

modify :: forall a b r. Members [Sync a, Mask, Resource] r => (a -> Sem r (a, b)) -> Sem r b Source #

Modify a Sync variable with async exceptions masked for the Sync operations, but not the action. Allows a value to be returned. Equivalent to modifyMVar.

withSync :: forall d r. Member (ScopedSync d) r => InterpreterFor (Sync d) r Source #

Run an action with a locally scoped Sync variable.

This avoids a dependency on Embed IO in application logic while still allowing the variable to be scoped.

lock :: forall l r a. Members [Sync l, Resource] r => l -> Sem r a -> Sem r a Source #

Run the action ma with an exclusive lock (mutex). When multiple threads call the action concurrently, only one is allowed to execute it at a time. The value l is used to disambiguate the Sync from other uses of the combinator. You can pass in something like Proxy "db-write"@.

Note: The Sync must be interpreted with an initially full MVar, e.g. using interpretSyncAs.

whileEmpty :: forall a r. Member (Sync a) r => Sem r () -> Sem r () Source #

Run an action repeatedly until the Sync variable is available.

use :: forall a b r. Members [Sync a, Mask, Resource] r => (a -> Sem r b) -> Sem r b Source #

Run an action with the current value of the Sync variable with async exceptions masked for the Sync operations, but not the action. Equivalent to withMVar.

whileEmptyInterval :: forall a u t d r. TimeUnit u => Members [Time t d, Sync a] r => u -> Sem r () -> Sem r () Source #

Run an action repeatedly until the Sync variable is available, waiting for the specified time between executions.

modify_ :: forall a r. Members [Sync a, Mask, Resource] r => (a -> Sem r a) -> Sem r () Source #

Modify a Sync variable with async exceptions masked for the Sync operations, but not the action. Does not allow a value to be returned. Equivalent to modifyMVar_.

modifyMasked :: forall a b r. Members [Sync a, Mask, Resource] r => (a -> Sem r (a, b)) -> Sem r b Source #

Modify a Sync variable with async exceptions masked for the entire procedure. Allows a value to be returned. Equivalent to modifyMVarMasked.

modifyMasked_ :: forall a r. Members [Sync a, Mask, Resource] r => (a -> Sem r a) -> Sem r () Source #

Modify a Sync variable with async exceptions masked for the entire procedure. Does not allow a value to be returned. Equivalent to modifyMVarMasked_.

useMasked :: forall a b r. Members [Sync a, Mask, Resource] r => (a -> Sem r b) -> Sem r b Source #

Run an action with the current value of the Sync variable with async exceptions masked for the entire procedure. Equivalent to withMVarMasked.