package async_kernel
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=30753e014bb0b127ee59f10b1073b8ae476468fb2f07dc8c99dbe2ef312fc696
doc/async_kernel.limiter_async/Limiter_async/Token_bucket/index.html
Module Limiter_async.Token_bucket
Source
enqueue_exn t x f a
enqueues an immediate job consuming x
tokens, running f
on input a
.
if allow_immediate_run
is true then f
is allowed to run within the same async job as enqueue_exn
iff there are enough tokens available to fully run the job and there are no other previously enqueued jobs that have not run. If this is the case, it is run before enqueue_exn
returns. Otherwise no part of f
is run before enqueue_exn
returns.
If there is a failure associated with this job then the exception will be raised to the monitor in scope when enqueue_exn
is called. Note that it may fail for a number of reasons, including f
throws an exception, the limiter is killed, or the number of tokens requested is larger than the burst size.
val enqueue' :
t ->
int ->
('a -> 'b Async_kernel.Deferred.t) ->
'a ->
'b Outcome.t Async_kernel.Deferred.t
enqueue' t x f a
enqueues a deferred job consuming x
tokens, running f
on input a
. No part of f is run before enqueue'
returns.
include Common with type 'a t := 'a u
kills t
, which aborts all enqueued jobs that haven't started and all jobs enqueued in the future. If t
has already been killed, then calling kill t
has no effect. Note that kill does not affect currently running jobs in any way.
is_dead t
returns true
if t
was killed, either by kill
or by an unhandled exception in a job.