Module type Kcas.Backoff

Backoff

Suspend domains with exponential backoff.

type t

The type of backoff value

val create : ?max:int -> unit -> t

create ~max:maxv () returns a backoff value, which when waited upon, suspends the calling domain for x milliseconds, where x is the current value of the backoff. The backoff value x is doubled after every wait upto a maximum of maxv milliseconds. The default maximum is 32 milliseconds. The initial backoff is 1 millisecond.

val once : t -> unit

once b suspends the current domain for x milliseconds, where x is the current value of the backoff.

val reset : t -> unit

Resets the backoff clock to 1 millisecond.