package lockfree

  1. Overview
  2. Docs

Module Lockfree.Spsc_queueSource

Sourcetype 'a t

Type of single-producer single-consumer non-resizable thread-safe queue that works in FIFO order.

Sourceexception Full
Sourceval create : size_exponent:int -> 'a t

create ~size_exponent:int creates a empty queue of size 2^size_exponent.

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

push q v pushes v at the back of the queue.

  • raises [Full]

    if the queue is full.

Sourceval pop : 'a t -> 'a option

pop q removes element from head of the queue, if any. This method can be used by at most 1 thread at the time.

Sourceval size : 'a t -> int

size returns the size of the queue. This method linearizes only when called from either enqueuer or dequeuer thread. Otherwise, it is safe to call but provides only an *indication* of the size of the structure.