Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
-
class
(
MonadSTM
m,
MonadThread
m) =>
MonadAsync
m
where
- type Async m = (async :: Type -> Type ) | async -> m
- async :: m a -> m ( Async m a)
- asyncThreadId :: Async m a -> ThreadId m
- withAsync :: m a -> ( Async m a -> m b) -> m b
- waitSTM :: Async m a -> STM m a
- pollSTM :: Async m a -> STM m ( Maybe ( Either SomeException a))
- waitCatchSTM :: Async m a -> STM m ( Either SomeException a)
- waitAnySTM :: [ Async m a] -> STM m ( Async m a, a)
- waitAnyCatchSTM :: [ Async m a] -> STM m ( Async m a, Either SomeException a)
- waitEitherSTM :: Async m a -> Async m b -> STM m ( Either a b)
- waitEitherSTM_ :: Async m a -> Async m b -> STM m ()
- waitEitherCatchSTM :: Async m a -> Async m b -> STM m ( Either ( Either SomeException a) ( Either SomeException b))
- waitBothSTM :: Async m a -> Async m b -> STM m (a, b)
- wait :: Async m a -> m a
- poll :: Async m a -> m ( Maybe ( Either SomeException a))
- waitCatch :: Async m a -> m ( Either SomeException a)
- cancel :: Async m a -> m ()
- cancelWith :: Exception e => Async m a -> e -> m ()
- uninterruptibleCancel :: Async m a -> m ()
- waitAny :: [ Async m a] -> m ( Async m a, a)
- waitAnyCatch :: [ Async m a] -> m ( Async m a, Either SomeException a)
- waitAnyCancel :: [ Async m a] -> m ( Async m a, a)
- waitAnyCatchCancel :: [ Async m a] -> m ( Async m a, Either SomeException a)
- waitEither :: Async m a -> Async m b -> m ( Either a b)
- waitEitherCatch :: Async m a -> Async m b -> m ( Either ( Either SomeException a) ( Either SomeException b))
- waitEitherCancel :: Async m a -> Async m b -> m ( Either a b)
- waitEitherCatchCancel :: Async m a -> Async m b -> m ( Either ( Either SomeException a) ( Either SomeException b))
- waitEither_ :: Async m a -> Async m b -> m ()
- waitBoth :: Async m a -> Async m b -> m (a, b)
- race :: m a -> m b -> m ( Either a b)
- race_ :: m a -> m b -> m ()
- concurrently :: m a -> m b -> m (a, b)
- concurrently_ :: m a -> m b -> m ()
- asyncWithUnmask :: (( forall b. m b -> m b) -> m a) -> m ( Async m a)
- data AsyncCancelled = AsyncCancelled
- data ExceptionInLinkedThread = ExceptionInLinkedThread String SomeException
- link :: ( MonadAsync m, MonadFork m, MonadMask m) => Async m a -> m ()
- linkTo :: ( MonadAsync m, MonadFork m, MonadMask m) => ThreadId m -> Async m a -> m ()
- linkOnly :: forall m a. ( MonadAsync m, MonadFork m, MonadMask m) => ( SomeException -> Bool ) -> Async m a -> m ()
- linkToOnly :: forall m a. ( MonadAsync m, MonadFork m, MonadMask m) => ThreadId m -> ( SomeException -> Bool ) -> Async m a -> m ()
- mapConcurrently :: ( Traversable t, MonadAsync m) => (a -> m b) -> t a -> m (t b)
- forConcurrently :: ( Traversable t, MonadAsync m) => t a -> (a -> m b) -> m (t b)
- mapConcurrently_ :: ( Foldable f, MonadAsync m) => (a -> m b) -> f a -> m ()
- forConcurrently_ :: ( Foldable f, MonadAsync m) => f a -> (a -> m b) -> m ()
- replicateConcurrently :: MonadAsync m => Int -> m a -> m [a]
- replicateConcurrently_ :: MonadAsync m => Int -> m a -> m ()
-
newtype
Concurrently
m a =
Concurrently
{
- runConcurrently :: m a
Documentation
class ( MonadSTM m, MonadThread m) => MonadAsync m where Source #
async , asyncThreadId , cancel , cancelWith , asyncWithUnmask , waitCatchSTM , pollSTM
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 #
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 #
default waitAnySTM :: MonadThrow ( STM m) => [ 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 #
default waitEitherSTM :: MonadThrow ( STM m) => Async m a -> Async m b -> STM m ( Either a b) Source #
waitEitherSTM_ :: Async m a -> Async m b -> STM m () Source #
default waitEitherSTM_ :: MonadThrow ( STM m) => 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 #
default waitBothSTM :: MonadThrow ( STM m) => 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 #
default uninterruptibleCancel :: MonadMask m => 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 #
default waitAnyCancel :: MonadThrow m => [ Async m a] -> m ( Async m a, a) Source #
waitAnyCatchCancel :: [ Async m a] -> m ( Async m a, Either SomeException a) Source #
default waitAnyCatchCancel :: MonadThrow m => [ 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 #
default waitEitherCancel :: MonadThrow m => 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 #
default waitEitherCatchCancel :: MonadThrow m => 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
data AsyncCancelled Source #
The exception thrown by
cancel
to terminate a thread.
Instances
Eq AsyncCancelled | |
Defined in Control.Concurrent.Async (==) :: AsyncCancelled -> AsyncCancelled -> Bool Source # (/=) :: AsyncCancelled -> AsyncCancelled -> Bool Source # |
|
Show AsyncCancelled | |
Defined in Control.Concurrent.Async |
|
Exception AsyncCancelled | |
Defined in Control.Concurrent.Async |
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
.
Instances
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.
linkOnly :: forall m a. ( MonadAsync m, MonadFork m, MonadMask m) => ( SomeException -> Bool ) -> Async m a -> m () Source #
linkToOnly :: forall m a. ( MonadAsync m, MonadFork m, MonadMask m) => ThreadId m -> ( SomeException -> Bool ) -> Async m a -> m () Source #
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 #
replicateConcurrently :: MonadAsync m => Int -> m a -> m [a] Source #
replicateConcurrently_ :: MonadAsync m => Int -> m a -> m () Source #
newtype Concurrently m a Source #
Similar to
Concurrently
but which works for any
MonadAsync
instance.
Concurrently | |
|