Limiter.Throttled_rate_limiterA Throttled_rate_limiter combines a Token_bucket and a Throttle. Unlike a Token_bucket, jobs cannot consume variable numbers of tokens, but the number of outstanding jobs is also limited to max_concurrent_jobs. Like a Throttle, finish_job must be called once, and only once, when a job is completed.
type t = private limiterval sexp_of_t : t -> Sexplib0.Sexp.tval create_exn :
now:Core.Time_ns.t ->
burst_size:int ->
sustained_rate_per_sec:float ->
max_concurrent_jobs:int ->
tval try_start_job :
t ->
now:Core.Time_ns.t ->
[ `Start
| `Max_concurrent_jobs_running
| `Unable_until_at_least of Core.Time_ns.t ]val finish_job : t -> now:Core.Time_ns.t -> unitReturn a token to the hopper (not the bucket). Thus, max_concurrent_jobs limits not only the number of open try_start_job-finish_job pairs across time, but also applies to the number of jobs run during the same (1ns) quantum time now - whether they finished now or not, and regardless of what order finish_job is called for the same time now.