module Throttle: Throttle
type 'a
t
include Invariant.S1
val create : continue_on_error:bool -> max_concurrent_jobs:int -> unit t
create ~continue_on_error ~max_concurrent_jobs
returns a throttle that will run up
to max_concurrent_jobs
concurrently.
If some job raises an exception, then the throttle will stop, unless
continue_on_error
is true.
val create_with : continue_on_error:bool -> 'a list -> 'a t
create_with ~continue_on_error job_resources
returns a throttle that will run up to
List.length job_resources
concurrently, and will ensure that all running jobs are
supplied distinct elements of job_resources
.type'a
outcome =[ `Aborted | `Ok of 'a | `Raised of exn ]
module Job:sig
..end
val enqueue_job : 'a t -> ('a, 'b) Job.t -> unit
val enqueue' : 'a t -> ('a -> 'b Deferred.t) -> 'b outcome Deferred.t
enqueue t job
schedules job
to be run as soon as possible. Jobs are guaranteed to
be started in the order they are enqueue
d.
enqueue
raises an exception if the throttle is dead.
val enqueue : 'a t -> ('a -> 'b Deferred.t) -> 'b Deferred.t
val prior_jobs_done : 'a t -> unit Deferred.t
prior_jobs_done t
becomes determined when all of the jobs that were previously
enqueued in t
have completed.val num_jobs_waiting_to_start : 'a t -> int
module Sequencer:sig
..end
val sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.t
create ~continue_on_error ~max_concurrent_jobs
returns a throttle that will run up
to max_concurrent_jobs
concurrently.
If some job raises an exception, then the throttle will stop, unless
continue_on_error
is true.
create_with ~continue_on_error job_resources
returns a throttle that will run up to
List.length job_resources
concurrently, and will ensure that all running jobs are
supplied distinct elements of job_resources
.
An ('a, 'b) Job.t
expects a resource of type 'a
and returns a result of type
'b
.
enqueue t job
schedules job
to be run as soon as possible. Jobs are guaranteed to
be started in the order they are enqueue
d.
enqueue
raises an exception if the throttle is dead.
prior_jobs_done t
becomes determined when all of the jobs that were previously
enqueued in t
have completed.
A sequencer is a throttle that is: