forked from ocaml-multicore/saturn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspsc_queue.mli
More file actions
24 lines (18 loc) · 792 Bytes
/
spsc_queue.mli
File metadata and controls
24 lines (18 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
type 'a t
(** Type of single-producer single-consumer non-resizable thread-safe
queue that works in FIFO order. *)
exception Full
val create : size_exponent:int -> 'a t
(** [create ~size_exponent:int] creates a empty queue of size
[2^size_exponent]. *)
val push : 'a t -> 'a -> unit
(** [push q v] pushes [v] at the back of the queue.
@raise [Full] if the queue is full.
*)
val 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. *)
val 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. *)