package lwt

  1. Overview
  2. Docs
Promises and event-driven I/O

Install

Dune Dependency

Authors

Maintainers

Sources

5.8.0.tar.gz
md5=2682558f405ab7c8638eeb16d0f9f46f
sha512=7f6548a1b1dbfdbc98d9352151ca7be97fa2ab63dbcc429208ce8d08308eee13f7fce31e0cca53f8880233959a60212d622270dd51bf164c3ee272f179769bd9

doc/lwt.unix/Lwt_throttle/module-type-S/index.html

Module type Lwt_throttle.SSource

Sourcetype key
Sourcetype t
Sourceval create : rate:int -> max:int -> n:int -> t

Creates a rate limiter.

  • parameter rate

    Maximum number of promise resolutions per second, per channel.

  • parameter max

    Maximum number of pending promises allowed at once, over all channels.

  • parameter n

    Initial size of the internal channel hash table. This should be approximately the number of different channels that will be used.

Sourceval wait : t -> key -> bool Lwt.t

Lwt_throttle.wait limiter channel returns a new promise associated with the given rate limiter and channel.

If the maximum number of pending promises for limiter has not been reached, the promise starts pending. It will be resolved with true at some future time, such that the rate limit of limiter is not exceeded, with respect to other promises in the same channel.

If the maximum number of pending promises has been reached, the returned promise is already resolved with false.

OCaml

Innovation. Community. Security.