Async_kernel.ThrottledAn applicative type for concurrent computations with limited concurrency.
The computation takes place lazily and only when the run function is called.
Compared to how Throttle is typically used, this type lets you avoid an up-front time&memory cost of adding all concurrent jobs to the throttle. In particular you can implement a throttled traversal of a very large data structure without doing a synchronous walk over the entire structure at any given time.
include Core.Applicative with type 'a t := 'a tval return : 'a 'p 'q. 'a -> 'a tConvert a value to a t.
Applies the functions in one t to the values in another. Well-behaved applicatives satisfy these "laws", using <*> as infix apply:
return Fn.id <*> t is equivalent to treturn Fn.compose <*> tf <*> tg <*> tx is equivalent to tf <*> (tg <*> tx)return f <*> return x is equivalent to return (f x)tf <*> return x is equivalent to return (fun f -> f x) <*> tfCombines values in two ts as tuples. Using <*> as infix apply, equivalent to return (fun a b -> a, b) <*> ta <*> tb.
Transforms the contents of a t. Using <*> as infix apply, equivalent to return f <*> t.
Combines the contents of two ts. Using <*> as infix apply, equivalent to return f <*> ta <*> tb.
Combines the contents of three ts. Using <*> as infix apply, equivalent to return f <*> ta <*> tb <*> tc.
module Applicative_infix : sig ... endval job : (unit -> 'a Deferred.t) -> 'a tjob f takes a function of type unit -> 'a Defferred.t and converts it to a Throttled type than can be executed with throttling using val run.
The function will be holding one throttle token while running.
val run : 'a t -> max_concurrent_jobs:int -> 'a Deferred.trun t takes a Throttled type and runs it.
of_thunk thunk converts a function of type unit -> 'a t to type 'a t. Useful for delaying computation.