Skip to content

Commit

Permalink
Add useful warning
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrm committed Nov 26, 2024
1 parent 1a7b012 commit b5fa0a1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/mpsc_queue.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ val create : unit -> 'a t
val of_list : 'a list -> 'a t
(** [of_list l] creates a new single-consumer queue from list [l].
🐌 This is a linear-time operation.
{[
# open Saturn.Single_consumer_queue
# let t : int t = of_list [1; 2; 3]
Expand Down Expand Up @@ -52,7 +54,9 @@ val push_all : 'a t -> 'a list -> unit
the other operations.
@raise Closed if [q] is closed.
🐌 This is a linear-time operation on the size of [vs].
{[
# open Saturn.Single_consumer_queue
# let t : int t = create ()
Expand Down Expand Up @@ -134,7 +138,9 @@ val push_head : 'a t -> 'a -> unit
@raise Closed if [q] is closed and empty. *)

(** {1 Examples}
(** {1 Examples} *)

(** {2 Sequential example}
An example top-level session:
{[
# open Saturn.Single_consumer_queue
Expand All @@ -152,8 +158,14 @@ val push_head : 'a t -> 'a -> unit
- : unit = ()
# pop_exn t
Exception: Saturn__Mpsc_queue.Empty.]}
*)

A multicore example:
(** {2 Multicore example}
Note: The barrier is used in this example solely to make the results more
interesting by increasing the likelihood of parallelism. Spawning a domain is
a costly operation, especially compared to the relatively small amount of work
being performed here. In practice, using a barrier in this manner is unnecessary.
{@ocaml non-deterministic[
# open Saturn.Single_consumer_queue
# let t : (string * int) t = create ()
Expand Down

0 comments on commit b5fa0a1

Please sign in to comment.