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

Polysemy.Conc.Data.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 => a -> u -> m b -> Race m (Either a b)

Return the fallback value if the given program doesn't finish within the specified interval.

Instances

Instances details
type DefiningModule Race Source # 
Instance details

Defined in Polysemy.Conc.Data.Race

type DefiningModule Race = "Polysemy.Conc.Data.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 => a -> u -> Sem r b -> Sem r (Either a b) Source #

Return the fallback value if the given program doesn't finish within the specified interval.