package kcas

  1. Overview
  2. Docs

Module Kcas.LocSource

Shared memory locations.

Sourcetype 'a t

Type of shared memory locations.

Sourceval make : 'a -> 'a t

make initial creates a new shared memory location with the initial value.

Sourceval get_id : 'a t -> int

get_id r returns the unique id of the shared memory location r.

Sourceval get : 'a t -> 'a

get r reads the current value of the shared memory location r.

Sourceval compare_and_set : 'a t -> 'a -> 'a -> bool

compare_and_set r before after atomically updates the shared memory location r to the after value if the current value of r is the before value.

Sourceval update : ?backoff:Backoff.t -> 'a t -> ('a -> 'a) -> 'a

update r f repeats let b = get r in compare_and_set r b (f b) until it succeeds and then returns the b value. It is safe for the given function f to raise an exception to abort the update.

Sourceval exchange : ?backoff:Backoff.t -> 'a t -> 'a -> 'a

exchange r after atomically updates the shared memory location r to the after value and returns the current value (before the exchange).

Sourceval set : ?backoff:Backoff.t -> 'a t -> 'a -> unit

set r after atomically updates the shared memory location r to the after value.

Sourceval fetch_and_add : ?backoff:Backoff.t -> int t -> int -> int

fetch_and_add r n atomically increments the value of r by n, and returns the current value (before the increment).

Sourceval incr : ?backoff:Backoff.t -> int t -> unit

incr r atomically increments r.

Sourceval decr : ?backoff:Backoff.t -> int t -> unit

decr r atomically decrements r.

OCaml

Innovation. Community. Security.