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

Polysemy.Conc.Effect.Race

Description

 
Synopsis

Documentation

data Race :: Effect 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 :: m a -> m b -> Race m (Either a b)

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

Timeout :: TimeUnit u => m a -> u -> m b -> Race m (Either a b)

Run the fallback action if the given program doesn't finish within the specified interval.

Instances

Instances details
type DefiningModule Race Source # 
Instance details

Defined in Polysemy.Conc.Effect.Race

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

race :: forall a b r. 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. TimeUnit u => Member Race r => Sem r a -> u -> Sem r b -> Sem r (Either a b) Source #

Run the fallback action if the given program doesn't finish within the specified interval.