cabal-install-3.10.2.1: The command-line interface for Cabal and Hackage.

Copyright | (c) Duncan Coutts 2012
License | BSD-like
Maintainer | cabal-devel@haskell.org
Stability | provisional
Portability | portable
Safe Haskell | None
Language | Haskell2010

Distribution.Client.JobControl

Description

A job control concurrency abstraction

Synopsis

- data JobControl (m :: Type -> Type) a
- newSerialJobControl :: IO (JobControl IO a)
- newParallelJobControl :: WithCallStack (Int -> IO (JobControl IO a))
- spawnJob :: JobControl m a -> m a -> m ()
- collectJob :: JobControl m a -> m a
- remainingJobs :: JobControl m a -> m Bool
- cancelJobs :: JobControl m a -> m ()
- data JobLimit
- newJobLimit :: Int -> IO JobLimit
- withJobLimit :: JobLimit -> IO a -> IO a
- data Lock
- newLock :: IO Lock
- criticalSection :: Lock -> IO a -> IO a

# Documentation

data JobControl (m :: Type -> Type) a #

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) #

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)) #

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 () #

Add a new job to the pool of jobs

collectJob :: JobControl m a -> m a #

Wait until one job is complete

remainingJobs :: JobControl m a -> m Bool #

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

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

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).

data JobLimit #

newJobLimit :: Int -> IO JobLimit #

withJobLimit :: JobLimit -> IO a -> IO a #

data Lock #

newLock :: IO Lock #

criticalSection :: Lock -> IO a -> IO a #