polysemy-conc-0.12.0.0: Polysemy effects for concurrency
Safe HaskellSafe-Inferred
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 first action if the second action doesn't finish within the specified interval.

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.