io-classes-0.2.0.0: Type classes for concurrency with STM, ST and timing
Safe Haskell None
Language Haskell2010

Control.Monad.Class.MonadAsync

Synopsis

Documentation

class ( MonadSTM m, MonadThread m) => MonadAsync m where Source #

Associated Types

type Async m = (async :: Type -> Type ) | async -> m Source #

An asynchronous action

Methods

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

asyncThreadId :: Async m a -> ThreadId m Source #

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

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

waitSTM :: Async m a -> STM m a Source #

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Note, IO-based implementations should override the default implementation. See the async package implementation and comments. http://hackage.haskell.org/package/async-2.2.1/docs/src/Control.Concurrent.Async.html#waitEitherCatch

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

waitEitherCatchCancel :: Async m a -> Async m b -> m ( Either ( Either SomeException a) ( Either SomeException b)) Source #

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

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

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

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

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

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

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

Instances

Instances details
MonadAsync IO Source #
Instance details

Defined in Control.Monad.Class.MonadAsync

Associated Types

type Async IO = (async :: Type -> Type ) Source #

Methods

async :: IO a -> IO ( Async IO a) Source #

asyncThreadId :: Async IO a -> ThreadId IO Source #

withAsync :: IO a -> ( Async IO a -> IO b) -> IO b Source #

waitSTM :: Async IO a -> STM IO a Source #

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

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

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

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

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

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

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

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

wait :: Async IO a -> IO a Source #

poll :: Async IO a -> IO ( Maybe ( Either SomeException a)) Source #

waitCatch :: Async IO a -> IO ( Either SomeException a) Source #

cancel :: Async IO a -> IO () Source #

cancelWith :: Exception e => Async IO a -> e -> IO () Source #

uninterruptibleCancel :: Async IO a -> IO () Source #

waitAny :: [ Async IO a] -> IO ( Async IO a, a) Source #

waitAnyCatch :: [ Async IO a] -> IO ( Async IO a, Either SomeException a) Source #

waitAnyCancel :: [ Async IO a] -> IO ( Async IO a, a) Source #

waitAnyCatchCancel :: [ Async IO a] -> IO ( Async IO a, Either SomeException a) Source #

waitEither :: Async IO a -> Async IO b -> IO ( Either a b) Source #

waitEitherCatch :: Async IO a -> Async IO b -> IO ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitEitherCancel :: Async IO a -> Async IO b -> IO ( Either a b) Source #

waitEitherCatchCancel :: Async IO a -> Async IO b -> IO ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitEither_ :: Async IO a -> Async IO b -> IO () Source #

waitBoth :: Async IO a -> Async IO b -> IO (a, b) Source #

race :: IO a -> IO b -> IO ( Either a b) Source #

race_ :: IO a -> IO b -> IO () Source #

concurrently :: IO a -> IO b -> IO (a, b) Source #

concurrently_ :: IO a -> IO b -> IO () Source #

asyncWithUnmask :: (( forall b. IO b -> IO b) -> IO a) -> IO ( Async IO a) Source #

( MonadAsync m, MonadCatch ( STM m)) => MonadAsync ( ReaderT r m) Source #
Instance details

Defined in Control.Monad.Class.MonadAsync

Associated Types

type Async ( ReaderT r m) = (async :: Type -> Type ) Source #

Methods

async :: ReaderT r m a -> ReaderT r m ( Async ( ReaderT r m) a) Source #

asyncThreadId :: Async ( ReaderT r m) a -> ThreadId ( ReaderT r m) Source #

withAsync :: ReaderT r m a -> ( Async ( ReaderT r m) a -> ReaderT r m b) -> ReaderT r m b Source #

waitSTM :: Async ( ReaderT r m) a -> STM ( ReaderT r m) a Source #

pollSTM :: Async ( ReaderT r m) a -> STM ( ReaderT r m) ( Maybe ( Either SomeException a)) Source #

waitCatchSTM :: Async ( ReaderT r m) a -> STM ( ReaderT r m) ( Either SomeException a) Source #

waitAnySTM :: [ Async ( ReaderT r m) a] -> STM ( ReaderT r m) ( Async ( ReaderT r m) a, a) Source #

waitAnyCatchSTM :: [ Async ( ReaderT r m) a] -> STM ( ReaderT r m) ( Async ( ReaderT r m) a, Either SomeException a) Source #

waitEitherSTM :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> STM ( ReaderT r m) ( Either a b) Source #

waitEitherSTM_ :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> STM ( ReaderT r m) () Source #

waitEitherCatchSTM :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> STM ( ReaderT r m) ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitBothSTM :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> STM ( ReaderT r m) (a, b) Source #

wait :: Async ( ReaderT r m) a -> ReaderT r m a Source #

poll :: Async ( ReaderT r m) a -> ReaderT r m ( Maybe ( Either SomeException a)) Source #

waitCatch :: Async ( ReaderT r m) a -> ReaderT r m ( Either SomeException a) Source #

cancel :: Async ( ReaderT r m) a -> ReaderT r m () Source #

cancelWith :: Exception e => Async ( ReaderT r m) a -> e -> ReaderT r m () Source #

uninterruptibleCancel :: Async ( ReaderT r m) a -> ReaderT r m () Source #

waitAny :: [ Async ( ReaderT r m) a] -> ReaderT r m ( Async ( ReaderT r m) a, a) Source #

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

waitAnyCancel :: [ Async ( ReaderT r m) a] -> ReaderT r m ( Async ( ReaderT r m) a, a) Source #

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

waitEither :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m ( Either a b) Source #

waitEitherCatch :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitEitherCancel :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m ( Either a b) Source #

waitEitherCatchCancel :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitEither_ :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m () Source #

waitBoth :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m (a, b) Source #

race :: ReaderT r m a -> ReaderT r m b -> ReaderT r m ( Either a b) Source #

race_ :: ReaderT r m a -> ReaderT r m b -> ReaderT r m () Source #

concurrently :: ReaderT r m a -> ReaderT r m b -> ReaderT r m (a, b) Source #

concurrently_ :: ReaderT r m a -> ReaderT r m b -> ReaderT r m () Source #

asyncWithUnmask :: (( forall b. ReaderT r m b -> ReaderT r m b) -> ReaderT r m a) -> ReaderT r m ( Async ( ReaderT r m) a) Source #

data ExceptionInLinkedThread Source #

Exception from child thread re-raised in parent thread

We record the thread ID of the child thread as a String . This avoids an m parameter in the type, which is important: ExceptionInLinkedThread must be an instance of Exception , requiring it to be Typeable ; if m appeared in the type, we would require m to be Typeable , which does not work with with the simulator, as it would require a Typeable constraint on the s parameter of IOSim .

linkTo :: ( MonadAsync m, MonadFork m, MonadMask m) => ThreadId m -> Async m a -> m () Source #

Generalizion of link that links an async to an arbitrary thread.

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

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

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

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

newtype Concurrently m a Source #

Similar to Concurrently but which works for any MonadAsync instance.

Constructors

Concurrently

Fields

Instances

Instances details
Functor m => Functor ( Concurrently m) Source #
Instance details

Defined in Control.Monad.Class.MonadAsync

MonadAsync m => Applicative ( Concurrently m) Source #
Instance details

Defined in Control.Monad.Class.MonadAsync

( MonadAsync m, MonadTimer m) => Alternative ( Concurrently m) Source #
Instance details

Defined in Control.Monad.Class.MonadAsync

( Semigroup a, MonadAsync m) => Semigroup ( Concurrently m a) Source #
Instance details

Defined in Control.Monad.Class.MonadAsync

( Monoid a, MonadAsync m) => Monoid ( Concurrently m a) Source #
Instance details

Defined in Control.Monad.Class.MonadAsync