cabal-install-3.10.1.0: The command-line interface for Cabal and Hackage.
Copyright(c) Duncan Coutts 2012
LicenseBSD-like
Maintainercabal-devel@haskell.org
Stabilityprovisional
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Distribution.Client.JobControl

Description

A job control concurrency abstraction

Synopsis

Documentation

data JobControl m a Source #

A simple concurrency abstraction. Jobs can be spawned and can complete in any order. This allows both serial and parallel implementations.

newSerialJobControl :: IO (JobControl IO a) Source #

Make a JobControl that executes all jobs serially and in order. It only executes jobs on demand when they are collected, not eagerly.

Cancelling will cancel all jobs that have not been collected yet.

newParallelJobControl :: WithCallStack (Int -> IO (JobControl IO a)) Source #

Make a JobControl that eagerly executes jobs in parallel, with a given maximum degree of parallelism.

Cancelling will cancel jobs that have not yet begun executing, but jobs that have already been executed or are currently executing cannot be cancelled.

spawnJob :: JobControl m a -> m a -> m () Source #

Add a new job to the pool of jobs

collectJob :: JobControl m a -> m a Source #

Wait until one job is complete

remainingJobs :: JobControl m a -> m Bool Source #

Returns True if there are any outstanding jobs (ie spawned but yet to be collected)

cancelJobs :: JobControl m a -> m () Source #

Try to cancel any outstanding but not-yet-started jobs. Call remainingJobs after this to find out if any jobs are left (ie could not be cancelled).