time-warp-1.1.1.2: Distributed systems execution emulation

Safe HaskellNone
LanguageHaskell2010

Control.TimeWarp.Manager.Job

Contents

Description

This module provides abstractions for parallel job processing.

Synopsis

Job data types

data InterruptType Source #

Defines way to interrupt all jobs in curator.

Constructors

Plain

Just interrupt all jobs

Force

Interrupt all jobs, and treat them all as completed

WithTimeout !Microsecond !(IO ())

Interrupt all jobs in Plain was, but if some jobs fail to complete in time, interrupt Forcely and execute given action.

newtype JobCurator Source #

Keeps set of jobs. Allows to stop jobs and wait till all of them finish.

Constructors

JobCurator 

Fields

JobsState lenses

jcCounter :: Lens' JobCuratorState JobId Source #

jcIsClosed :: Lens' JobCuratorState Bool Source #

jcJobs :: Lens' JobCuratorState (HashMap JobId JobInterrupter) Source #

Manager utilities

addManagerAsJob :: (MonadIO m, MonadTimed m, MonadBaseControl IO m) => JobCurator -> InterruptType -> JobCurator -> m () Source #

Add second manager as a job to first manager.

addSafeThreadJob :: (MonadIO m, MonadMask m, MonadTimed m) => JobCurator -> m () -> m () Source #

Adds job executing in another thread, interrupting does nothing. Usefull then work stops itself on interrupt, and we just need to wait till it fully stops.

addThreadJob :: (CanLog m, MonadIO m, MonadMask m, MonadTimed m, MonadBaseControl IO m) => JobCurator -> m () -> m () Source #

Adds job executing in another thread, where interrupting kills the thread.

interruptAllJobs :: MonadIO m => JobCurator -> InterruptType -> m () Source #

Invokes JobInterrupters for all incompleted jobs. Has no effect on second call.

stopAllJobs :: MonadIO m => JobCurator -> m () Source #

Interrupts and then awaits for all jobs to complete.

unlessInterrupted :: MonadIO m => JobCurator -> m () -> m () Source #