package saturn_lockfree

  1. Overview
  2. Docs

Module Saturn_lockfree.StackSource

Classic multi-producer multi-consumer Treiber stack.

All function are lockfree. It is the recommended starting point when needing LIFO structure.

Sourcetype 'a t

Type of Treiber stack holding items of type t.

Sourceval create : unit -> 'a t

create () returns a new and empty Treiber stack.

Sourceval is_empty : 'a t -> bool

is_empty s checks whether stack s is empty.

Sourceval push : 'a t -> 'a -> unit

push s v adds the element v at the top of stack s.

Sourceexception Empty

Raised when pop or peek is applied to an empty queue.

Sourceval pop : 'a t -> 'a

pop s removes and returns the topmost element in the stack s.

  • raises Empty

    if a is empty.

Sourceval pop_opt : 'a t -> 'a option

pop_opt s removes and returns the topmost element in the stack s, or returns None if the stack is empty.

OCaml

Innovation. Community. Security.