polysemy-conc-0.5.0.0: Polysemy Effects for Concurrency
Safe HaskellNone
LanguageHaskell2010

Polysemy.Conc.Sync

Description

 
Synopsis

Documentation

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

Run an action repeatedly until the Sync variable is available.

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.

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

Run an action with a locally scoped Sync variable.

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.

data Sync d :: Effect Source #

Abstracts an MVar.

For documentation on the constructors, see the module Polysemy.Conc.Effect.Sync.

import Polysemy.Conc (Sync)
import qualified Polysemy.Conc.Effect.Sync as Sync

prog :: Member (Sync Int) r => Sem r Int
prog = do
  Sync.putTry 5
  Sync.takeBlock

Instances

Instances details
type DefiningModule Sync Source # 
Instance details

Defined in Polysemy.Conc.Effect.Sync

type DefiningModule Sync = "Polysemy.Conc.Effect.Sync"

type ScopedSync res a = Scoped (SyncResources res) (Sync a) Source #

Convenience alias.