A simple concurrency abstraction. Jobs can be spawned and can complete in any order. This allows both serial and parallel implementations.
Modulecabal-install-3.18.1.0Haskell2010
Distribution.Client.JobControl
A job control concurrency abstraction
- 3 types
- 16 values
- Packagecabal-install-3.18.1.0
- Exports19
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceJobControl.hs
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.
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.
Make a JobControl where the parallelism is controlled by a semaphore.
This uses the GHC -jsem option to allow GHC to take additional semaphore slots if we are not using them all.
Add a new job to the pool of jobs
Wait until one job is complete
Returns True if there are any outstanding jobs (ie spawned but yet to be collected)
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).
cleanup any resources created by the JobControl, intended to be used as the finaliser for bracket.
Identifier of the semaphore which can be used to control parallelism, if one is available for that job control type.
Higher level utils
3 declarationsnewJobControlFromParStrat :: Verbosity-> Maybe CompilerThe compiler, used to determine whether Jsem is supported. When Nothing, Jsem is assumed to be unsupported.
-> ParStratInstallThe parallel strategy
-> Maybe IntA cap on the number of jobs (e.g. to force a maximum of 2 concurrent downloads despite a -j8 parallel strategy)
-> IO (JobControl IO a)
Concurrently execute actions on a list using the given JobControl. The maximum number of concurrent jobs is tied to the JobControl instance. The resulting list does not preserve the original order!