package async_kernel

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Async_kernel.ThrottledSource

An 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.

module Deferred := Async_kernel__.Deferred1
Sourcetype 'a t
include Core.Applicative with type 'a t := 'a t
Sourceval return : 'a -> 'a t
Sourceval map : 'a t -> f:('a -> 'b) -> 'b t
Sourceval both : 'a t -> 'b t -> ('a * 'b) t
Sourceval (<*>) : ('a -> 'b) t -> 'a t -> 'b t

same as apply

Sourceval (<*) : 'a t -> unit t -> 'a t
Sourceval (*>) : unit t -> 'a t -> 'a t
Sourceval (>>|) : 'a t -> ('a -> 'b) -> 'b t
Sourceval apply : ('a -> 'b) t -> 'a t -> 'b t
Sourceval map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t
Sourceval map3 : 'a t -> 'b t -> 'c t -> f:('a -> 'b -> 'c -> 'd) -> 'd t
Sourceval all : 'a t list -> 'a list t
Sourceval all_unit : unit t list -> unit t
Sourcemodule Applicative_infix : sig ... end
Sourceval job : (unit -> 'a Deferred.t) -> 'a t

job 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.

Sourceval run : 'a t -> max_concurrent_jobs:int -> 'a Deferred.t

run t takes a Throttled type and runs it.

Sourceval of_thunk : (unit -> 'a t) -> 'a t

of_thunk thunk converts a function of type unit -> 'a t to type 'a t. Useful for delaying computation.

Sourceval both_unit : unit t -> unit t -> unit t

both_unit t1 t2 combines two unit t into one in a way that's more efficent by saving the mapping over the final deferred.

This optimization is important if t1 finishes early but t2 finishes late, since the memory usage between the two events is reduced to 0.

OCaml

Innovation. Community. Security.