async-2.2.6: Run IO operations asynchronously and wait for their results
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Concurrent.Async.Warden

Description

A more flexible way to create Asyncs and have them automatically cancelled when the Warden is shut down.

Synopsis

Documentation

data Warden Source #

A Warden is an owner of Asyncs which cancels them on shutdown.

Nothing in the MVar means the Warden has been shut down.

withWarden :: (Warden -> IO a) -> IO a Source #

Run the action with a new Warden, and call shutdown when the action exits.

create :: IO Warden Source #

Create a new Warden.

shutdown :: Warden -> IO () Source #

Shutdown a Warden, calling cancel on all owned threads. Subsequent calls to spawn and shutdown will be no-ops.

Note that any exceptions thrown by the threads will be ignored. If you want exceptions to be propagated, either call wait explicitly on the Async, or use link.

spawn :: Warden -> IO a -> IO (Async a) Source #

Spawn a new thread owned by the Warden.

spawn_ :: Warden -> IO () -> IO () Source #

Spawn a new thread owned by the Warden.

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

Spawn a thread with masked exceptions and pass an unmask function to the action.