unliftio-0.2.8.1: The MonadUnliftIO typeclass for unlifting monads to IO (batteries included)

Safe HaskellNone
LanguageHaskell2010

UnliftIO.Async

Contents

Description

Unlifted Control.Concurrent.Async.

Since: unliftio-0.1.0.0

Synopsis

Asynchronous actions

data Async a #

An asynchronous action spawned by async or withAsync. Asynchronous actions are executed in a separate thread, and operations are provided for waiting for asynchronous actions to complete and obtaining their results (see e.g. wait).

Instances
Functor Async 
Instance details

Defined in Control.Concurrent.Async

Methods

fmap :: (a -> b) -> Async a -> Async b #

(<$) :: a -> Async b -> Async a #

Eq (Async a) 
Instance details

Defined in Control.Concurrent.Async

Methods

(==) :: Async a -> Async a -> Bool #

(/=) :: Async a -> Async a -> Bool #

Ord (Async a) 
Instance details

Defined in Control.Concurrent.Async

Methods

compare :: Async a -> Async a -> Ordering #

(<) :: Async a -> Async a -> Bool #

(<=) :: Async a -> Async a -> Bool #

(>) :: Async a -> Async a -> Bool #

(>=) :: Async a -> Async a -> Bool #

max :: Async a -> Async a -> Async a #

min :: Async a -> Async a -> Async a #

Hashable (Async a) 
Instance details

Defined in Control.Concurrent.Async

Methods

hashWithSalt :: Int -> Async a -> Int #

hash :: Async a -> Int #

Spawning

async :: MonadUnliftIO m => m a -> m (Async a) Source #

Unlifted async.

Since: unliftio-0.1.0.0

asyncBound :: MonadUnliftIO m => m a -> m (Async a) Source #

Unlifted asyncBound.

Since: unliftio-0.1.0.0

asyncOn :: MonadUnliftIO m => Int -> m a -> m (Async a) Source #

Unlifted asyncOn.

Since: unliftio-0.1.0.0

asyncWithUnmask :: MonadUnliftIO m => ((forall b. m b -> m b) -> m a) -> m (Async a) Source #

Unlifted asyncWithUnmask.

Since: unliftio-0.1.0.0

asyncOnWithUnmask :: MonadUnliftIO m => Int -> ((forall b. m b -> m b) -> m a) -> m (Async a) Source #

Unlifted asyncOnWithUnmask.

Since: unliftio-0.1.0.0

Spawning with automatic cancelation

withAsync :: MonadUnliftIO m => m a -> (Async a -> m b) -> m b Source #

Unlifted withAsync.

Since: unliftio-0.1.0.0

withAsyncBound :: MonadUnliftIO m => m a -> (Async a -> m b) -> m b Source #

Unlifted withAsyncBound.

Since: unliftio-0.1.0.0

withAsyncOn :: MonadUnliftIO m => Int -> m a -> (Async a -> m b) -> m b Source #

Unlifted withAsyncOn.

Since: unliftio-0.1.0.0

withAsyncWithUnmask :: MonadUnliftIO m => ((forall c. m c -> m c) -> m a) -> (Async a -> m b) -> m b Source #

Unlifted withAsyncWithUnmask.

Since: unliftio-0.1.0.0

withAsyncOnWithUnmask :: MonadUnliftIO m => Int -> ((forall c. m c -> m c) -> m a) -> (Async a -> m b) -> m b Source #

Unlifted withAsyncOnWithMask.

Since: unliftio-0.1.0.0

Querying Asyncs

wait :: MonadIO m => Async a -> m a Source #

Lifted wait.

Since: unliftio-0.1.0.0

poll :: MonadIO m => Async a -> m (Maybe (Either SomeException a)) Source #

Lifted poll.

Since: unliftio-0.1.0.0

waitCatch :: MonadIO m => Async a -> m (Either SomeException a) Source #

Lifted waitCatch.

Since: unliftio-0.1.0.0

cancel :: MonadIO m => Async a -> m () Source #

Lifted cancel.

Since: unliftio-0.1.0.0

uninterruptibleCancel :: MonadIO m => Async a -> m () Source #

Lifted uninterruptibleCancel.

Since: unliftio-0.1.0.0

cancelWith :: (Exception e, MonadIO m) => Async a -> e -> m () Source #

Lifted cancelWith. Additionally uses toAsyncException to ensure async exception safety.

Since: unliftio-0.1.0.0

asyncThreadId :: Async a -> ThreadId #

Returns the ThreadId of the thread running the given Async.

STM operations

waitSTM :: Async a -> STM a #

A version of wait that can be used inside an STM transaction.

pollSTM :: Async a -> STM (Maybe (Either SomeException a)) #

A version of poll that can be used inside an STM transaction.

waitCatchSTM :: Async a -> STM (Either SomeException a) #

A version of waitCatch that can be used inside an STM transaction.

Waiting for multiple Asyncs

waitAny :: MonadIO m => [Async a] -> m (Async a, a) Source #

Lifted waitAny.

Since: unliftio-0.1.0.0

waitAnyCatch :: MonadIO m => [Async a] -> m (Async a, Either SomeException a) Source #

Lifted waitAnyCatch.

Since: unliftio-0.1.0.0

waitAnyCancel :: MonadIO m => [Async a] -> m (Async a, a) Source #

Lifted waitAnyCancel.

Since: unliftio-0.1.0.0

waitAnyCatchCancel :: MonadIO m => [Async a] -> m (Async a, Either SomeException a) Source #

Lifted waitAnyCatchCancel.

Since: unliftio-0.1.0.0

waitEither :: MonadIO m => Async a -> Async b -> m (Either a b) Source #

Lifted waitEither.

Since: unliftio-0.1.0.0

waitEitherCatch :: MonadIO m => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b)) Source #

Lifted waitEitherCatch.

Since: unliftio-0.1.0.0

waitEitherCancel :: MonadIO m => Async a -> Async b -> m (Either a b) Source #

Lifted waitEitherCancel.

Since: unliftio-0.1.0.0

waitEither_ :: MonadIO m => Async a -> Async b -> m () Source #

Lifted waitEither_.

Since: unliftio-0.1.0.0

waitBoth :: MonadIO m => Async a -> Async b -> m (a, b) Source #

Lifted waitBoth.

Since: unliftio-0.1.0.0

Waiting for multiple Asyncs in STM

waitAnySTM :: [Async a] -> STM (Async a, a) #

A version of waitAny that can be used inside an STM transaction.

Since: async-2.1.0

waitAnyCatchSTM :: [Async a] -> STM (Async a, Either SomeException a) #

A version of waitAnyCatch that can be used inside an STM transaction.

Since: async-2.1.0

waitEitherSTM :: Async a -> Async b -> STM (Either a b) #

A version of waitEither that can be used inside an STM transaction.

Since: async-2.1.0

waitEitherCatchSTM :: Async a -> Async b -> STM (Either (Either SomeException a) (Either SomeException b)) #

A version of waitEitherCatch that can be used inside an STM transaction.

Since: async-2.1.0

waitEitherSTM_ :: Async a -> Async b -> STM () #

A version of waitEither_ that can be used inside an STM transaction.

Since: async-2.1.0

waitBothSTM :: Async a -> Async b -> STM (a, b) #

A version of waitBoth that can be used inside an STM transaction.

Since: async-2.1.0

Linking

link :: MonadIO m => Async a -> m () Source #

Lifted link.

Since: unliftio-0.1.0.0

link2 :: MonadIO m => Async a -> Async b -> m () Source #

Lifted link2.

Since: unliftio-0.1.0.0

Convenient utilities

race :: MonadUnliftIO m => m a -> m b -> m (Either a b) Source #

Unlifted race.

Since: unliftio-0.1.0.0

race_ :: MonadUnliftIO m => m a -> m b -> m () Source #

Unlifted race_.

Since: unliftio-0.1.0.0

concurrently :: MonadUnliftIO m => m a -> m b -> m (a, b) Source #

Unlifted concurrently.

Since: unliftio-0.1.0.0

concurrently_ :: MonadUnliftIO m => m a -> m b -> m () Source #

Unlifted concurrently_.

Since: unliftio-0.1.0.0

mapConcurrently :: MonadUnliftIO m => Traversable t => (a -> m b) -> t a -> m (t b) Source #

Unlifted mapConcurrently.

Since: unliftio-0.1.0.0

forConcurrently :: MonadUnliftIO m => Traversable t => t a -> (a -> m b) -> m (t b) Source #

Unlifted forConcurrently.

Since: unliftio-0.1.0.0

mapConcurrently_ :: MonadUnliftIO m => Foldable f => (a -> m b) -> f a -> m () Source #

Unlifted mapConcurrently_.

Since: unliftio-0.1.0.0

forConcurrently_ :: MonadUnliftIO m => Foldable f => f a -> (a -> m b) -> m () Source #

Unlifted forConcurrently_.

Since: unliftio-0.1.0.0

replicateConcurrently :: MonadUnliftIO m => Int -> m a -> m [a] Source #

Unlifted replicateConcurrently.

Since: unliftio-0.1.0.0

replicateConcurrently_ :: MonadUnliftIO m => Int -> m a -> m () Source #

Unlifted replicateConcurrently_.

Since: unliftio-0.1.0.0

newtype Concurrently m a Source #

Unlifted Concurrently.

Since: unliftio-0.1.0.0

Constructors

Concurrently 

Fields

Instances
Monad m => Functor (Concurrently m) Source #

Since: unliftio-0.1.0.0

Instance details

Defined in UnliftIO.Async

Methods

fmap :: (a -> b) -> Concurrently m a -> Concurrently m b #

(<$) :: a -> Concurrently m b -> Concurrently m a #

MonadUnliftIO m => Applicative (Concurrently m) Source #

Since: unliftio-0.1.0.0

Instance details

Defined in UnliftIO.Async

Methods

pure :: a -> Concurrently m a #

(<*>) :: Concurrently m (a -> b) -> Concurrently m a -> Concurrently m b #

liftA2 :: (a -> b -> c) -> Concurrently m a -> Concurrently m b -> Concurrently m c #

(*>) :: Concurrently m a -> Concurrently m b -> Concurrently m b #

(<*) :: Concurrently m a -> Concurrently m b -> Concurrently m a #

MonadUnliftIO m => Alternative (Concurrently m) Source #

Since: unliftio-0.1.0.0

Instance details

Defined in UnliftIO.Async

Methods

empty :: Concurrently m a #

(<|>) :: Concurrently m a -> Concurrently m a -> Concurrently m a #

some :: Concurrently m a -> Concurrently m [a] #

many :: Concurrently m a -> Concurrently m [a] #

(MonadUnliftIO m, Semigroup a) => Semigroup (Concurrently m a) Source #

Only defined by async for base >= 4.9.

Since: unliftio-0.1.0.0

Instance details

Defined in UnliftIO.Async

Methods

(<>) :: Concurrently m a -> Concurrently m a -> Concurrently m a #

sconcat :: NonEmpty (Concurrently m a) -> Concurrently m a #

stimes :: Integral b => b -> Concurrently m a -> Concurrently m a #

(Semigroup a, Monoid a, MonadUnliftIO m) => Monoid (Concurrently m a) Source #

Since: unliftio-0.1.0.0

Instance details

Defined in UnliftIO.Async