Copyright | (c) 2017 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- type MonadAsync m = (MonadIO m, MonadBaseControl IO m, MonadThrow m)
- newtype RunInIO m = RunInIO {}
- captureMonadState :: MonadBaseControl IO m => m (RunInIO m)
- doFork :: MonadBaseControl IO m => m () -> RunInIO m -> (SomeException -> IO ()) -> m ThreadId
- fork :: MonadBaseControl IO m => m () -> m ThreadId
- forkManaged :: (MonadIO m, MonadBaseControl IO m) => m () -> m ThreadId
Documentation
type MonadAsync m = (MonadIO m, MonadBaseControl IO m, MonadThrow m) Source #
A monad that can perform concurrent or parallel IO operations. Streams
that can be composed concurrently require the underlying monad to be
MonadAsync
.
Since: 0.1.0 (Streamly)
Since: 0.8.0
captureMonadState :: MonadBaseControl IO m => m (RunInIO m) Source #
When we run computations concurrently, we completely isolate the state of the concurrent computations from the parent computation. The invariant is that we should never be running two concurrent computations in the same thread without using the runInIO function. Also, we should never be running a concurrent computation in the parent thread, otherwise it may affect the state of the parent which is against the defined semantics of concurrent execution.
doFork :: MonadBaseControl IO m => m () -> RunInIO m -> (SomeException -> IO ()) -> m ThreadId Source #
Fork a thread to run the given computation, installing the provided exception handler. Lifted to any monad with 'MonadBaseControl IO m' capability.
TODO: the RunInIO argument can be removed, we can directly pass the action as "mrun action" instead.
fork :: MonadBaseControl IO m => m () -> m ThreadId Source #
fork
lifted to any monad with 'MonadBaseControl IO m' capability.
forkManaged :: (MonadIO m, MonadBaseControl IO m) => m () -> m ThreadId Source #
Fork a thread that is automatically killed as soon as the reference to the returned threadId is garbage collected.