package kcas

  1. Overview
  2. Docs

Module Kcas.OpSource

Operations on shared memory locations.

Sourcetype t

Type of operations on shared memory locations.

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

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

Sourceval atomic : t -> bool

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

Sourceval atomically : t list -> bool

atomically ops attempts to perform the given operations atomically. Returns true on success and false on failure.

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