Skip to content

Commit

Permalink
Add useful warning
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrm committed Dec 2, 2024
1 parent 5305059 commit a289035
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 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,9 +158,15 @@ val push_head : 'a t -> 'a -> unit
- : unit = ()
# pop_exn t
Exception: Saturn__Mpsc_queue.Empty.]}
*)

A multicore example:
{@ocaml non-deterministic[
(** {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=command[
# open Saturn.Single_consumer_queue
# let t : (string * int) t = create ()
val t : (string * int) t = <abstr>
Expand Down

0 comments on commit a289035

Please sign in to comment.