package kcas

  1. Overview
  2. Docs

Module Kcas.W1Source

Sourcetype 'a ref

The type of shared memory reference.

Sourceval ref : 'a -> 'a ref

Create a new reference.

Sourceval get : 'a ref -> 'a

Get the value of the reference.

Sourceval set : 'a ref -> 'a -> unit
Sourceval cas : 'a ref -> 'a -> 'a -> bool

cas r e u updates the reference r to value u if the current content of r is e.

Sourceval try_map : 'a ref -> ('a -> 'a option) -> 'a cas_result

try_map r f invokes f c, where c is the result of get r. If the result of f c is None, then Aborted is returned. If the result of f c is Some v, then attempt to CAS update r from c to v. If the CAS succeeds, then Success c is returned. If the CAS fails, then Failed is returned.

Sourceval map : 'a ref -> ('a -> 'a option) -> 'a cas_result

Like try_map but retries on CAS failure. Hence, map r f never returns Failed.

Sourceval incr : int ref -> unit

incr r atomically increments r

Sourceval decr : int ref -> unit
OCaml

Innovation. Community. Security.