File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 17
17
18
18
module type S = sig
19
19
type 'a t
20
+ (* * The type of lock-free queue. *)
21
+
20
22
val create : unit -> 'a t
23
+ (* * Create a new queue, which is initially empty. *)
24
+
21
25
val is_empty : 'a t -> bool
26
+ (* * [is_empty q] returns empty if [q] is empty. *)
27
+
22
28
val push : 'a t -> 'a -> unit
29
+ (* * [push q v] pushes [v] to the back of the queue. *)
30
+
23
31
val pop : 'a t -> 'a option
32
+ (* * [pop q] pops an element [e] from the front of the queue and returns
33
+ [Some v] if the queue is non-empty. Otherwise, returns [None]. *)
34
+
24
35
val clean_until : 'a t -> ('a -> bool ) -> unit
36
+ (* * [clean_until q f] drops the prefix of the queue until the element [e],
37
+ where [f e] is [true]. If no such element exists, then the queue is
38
+ emptied. *)
25
39
26
40
type 'a cursor
41
+ (* * The type of cursor. *)
42
+
27
43
val snapshot : 'a t -> 'a cursor
44
+ (* * Obtain a snapshot of the queue. This is a constant time operation. *)
45
+
28
46
val next : 'a cursor -> ('a * 'a cursor ) option
47
+ (* * [next c] returns [Some (e, c')] where [e] is the head of the queue and
48
+ [c'] is the tail, if the queue is non-empty. Otherwise, returns [None]. *)
29
49
end
30
50
31
51
module M : S
You can’t perform that action at this time.
0 commit comments