polysemy-conc-0.14.1.1: Polysemy effects for concurrency
Safe HaskellNone
LanguageGHC2021

Polysemy.Conc.Effect.Race

Description

 
Synopsis

Documentation

data Race (a :: Type -> Type) b where Source #

Abstract the concept of running two programs concurrently, aborting the other when one terminates. Timeout is a simpler variant, where one thread just sleeps for a given interval.

Constructors

Race :: forall (a :: Type -> Type) a1 b1. a a1 -> a b1 -> Race a (Either a1 b1)

Run both programs concurrently, returning the result of the faster one.

Timeout :: forall u (a :: Type -> Type) a1 b1. TimeUnit u => a a1 -> u -> a b1 -> Race a (Either a1 b1)

Run the first action if the second action doesn't finish within the specified interval.

race :: forall a b (r :: EffectRow). Member Race r => Sem r a -> Sem r b -> Sem r (Either a b) Source #

Run both programs concurrently, returning the result of the faster one.

timeout :: forall a b u (r :: EffectRow). (TimeUnit u, Member Race r) => Sem r a -> u -> Sem r b -> Sem r (Either a b) Source #

Run the first action if the second action doesn't finish within the specified interval.