Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module allows the management of a multiple Async jobs which are grouped by an 'Ord group => group' type.
Synopsis
- data JobPool group (m :: Type -> Type) a
- data Job group (m :: Type -> Type) a = Job (m a) (SomeException -> m a) group String
- withJobPool :: forall group m a b. (MonadAsync m, MonadThrow m, MonadLabelledSTM m) => (JobPool group m a -> m b) -> m b
- forkJob :: forall group m a. (MonadAsync m, MonadMask m, Ord group) => JobPool group m a -> Job group m a -> m ()
- readSize :: forall (m :: Type -> Type) group a. MonadSTM m => JobPool group m a -> STM m Int
- readGroupSize :: forall (m :: Type -> Type) group a. (MonadSTM m, Eq group) => JobPool group m a -> group -> STM m Int
- waitForJob :: forall (m :: Type -> Type) group a. MonadSTM m => JobPool group m a -> STM m a
- cancelGroup :: (MonadAsync m, Eq group) => JobPool group m a -> group -> m ()
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.
Job | |
|
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.