package kcas

  1. Overview
  2. Docs
Module type
Class type

Operations on shared memory locations.

type t

Type of operations on shared memory locations.

val make_cas : 'a Loc.t -> 'a -> 'a -> t

make_cas r before after is an operation that attempts to set the shared memory location r to the after value and succeeds if the current content of r is the before value.

val make_cmp : 'a Loc.t -> 'a -> t

make_cmp r expected is an operation that succeeds if the current value of the shared memory location r is the expected value.

val get_id : t -> int

get_id op returns the unique id of the shared memory reference targeted by the operation.

val is_on_loc : t -> 'a Loc.t -> bool

is_on_loc op r determines whether the target of op is the shared memory location r.

val atomic : t -> bool

atomic op attempts to perform the given operation atomically. Returns true on success and false on failure.

val atomically : ?mode:Mode.t -> t list -> bool

atomically ops attempts to perform the given operations atomically. If used in Mode.obstruction_free may raise Mode.Interference. Otherwise returns true on success and false on failure. The default for atomically is Mode.lock_free.

The algorithm requires provided operations to follow a global total order. To eliminate a class of bugs, the operations are sorted automatically. If the operations are given in either ascending or descending order of the targeted shared memory location ids, then sorting is done in linear time O(n) and does not increase the time complexity of the algorithm. Otherwise sorting may take linearithmic time O(n*log(n)).