network-mux
Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.JobPool

Description

This module allows the management of a multiple Async jobs which are grouped by an 'Ord group => group' type.

Synopsis

Documentation

data JobPool group (m :: Type -> Type) a Source #

JobPool allows to submit asynchronous jobs, wait for their completion or cancel. Jobs are grouped, each group can be cancelled separately.

data Job group (m :: Type -> Type) a Source #

An asynchronous job which belongs to some group and its exception handler.

Constructors

Job 

Fields

withJobPool :: forall group m a b. (MonadAsync m, MonadThrow m, MonadLabelledSTM m) => (JobPool group m a -> m b) -> m b Source #

forkJob :: forall group m a. (MonadAsync m, MonadMask m, Ord group) => JobPool group m a -> Job group m a -> m () Source #

readSize :: forall (m :: Type -> Type) group a. MonadSTM m => JobPool group m a -> STM m Int Source #

readGroupSize :: forall (m :: Type -> Type) group a. (MonadSTM m, Eq group) => JobPool group m a -> group -> STM m Int Source #

waitForJob :: forall (m :: Type -> Type) group a. MonadSTM m => JobPool group m a -> STM m a Source #

Wait for next successfully completed job. Unlike wait it will not throw if a job errors.

cancelGroup :: (MonadAsync m, Eq group) => JobPool group m a -> group -> m () Source #

Cancel all threads in a given group. Blocks until all threads terminated.