Skip to content

Commit

Permalink
A bit more documentation improvement.
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrm committed Nov 26, 2024
1 parent 8f92163 commit 71b5847
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
13 changes: 11 additions & 2 deletions src/bounded_queue/bounded_queue_intf.mli
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ module type BOUNDED_QUEUE = sig
queue is full. *)
end

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

(** {2 Sequential example}
An example top-level session:
{[
# open Saturn.Bounded_queue
Expand Down Expand Up @@ -137,8 +139,15 @@ end
- : int option = None
# pop_exn t
Exception: Saturn__Bounded_queue.Empty.]}
*)

(** {2 Multicore example}
**Note** that the use of a barrier is only necessary to make the result of
this example interesting by improving the likelihood of parallelism.
Spawning a domain is a costly operation compared to the work actually run on them
here. In practice, you should not use a barrier.
A multicore example:
{@ocaml non-deterministic[
# open Saturn.Bounded_queue
# let t :int t = create ~capacity:4 ()
Expand Down
14 changes: 11 additions & 3 deletions src/bounded_stack.mli
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ the [seq] is too long to fit in the stack.
🐌 This is a linear-time operation. *)

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

(** {2 Sequential example}
An example top-level session:
{[
# open Saturn.Bounded_stack
Expand All @@ -187,8 +189,15 @@ the [seq] is too long to fit in the stack.
- : int option = None
# pop_exn t
Exception: Saturn__Bounded_stack.Empty.]}
*)

(** {2 Multicore example}
**Note** that the use of a barrier is only necessary to make the result of
this example interesting by improving the likelihood of parallelism.
Spawning a domain is a costly operation compared to the work actually run on them
here. In practice, you should not use a barrier.
A multicore example:
{@ocaml non-deterministic[
# open Saturn.Bounded_stack
# let t :int t = create ()
Expand Down Expand Up @@ -219,5 +228,4 @@ the [seq] is too long to fit in the stack.
# Domain.join domain_popper
- : int option list = [Some 42; Some 3; Some 2; Some 1; None; Some 12]
]}
*)
14 changes: 11 additions & 3 deletions src/treiber_stack.mli
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ val add_seq : 'a t -> 'a Seq.t -> unit
🐌 This is a linear-time operation on the size of [elements]. *)

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

(** {2 Sequential example}
An example top-level session:
{[
# open Saturn.Stack
Expand All @@ -126,8 +128,15 @@ val add_seq : 'a t -> 'a Seq.t -> unit
- : int list = [2; 1; 42]
# pop_exn t
Exception: Saturn__Treiber_stack.Empty.]}
*)

(** {2 Multicore example}
**Note** that the use of a barrier is only necessary to make the result of
this example interesting by improving the likelihood of parallelism.
Spawning a domain is a costly operation compared to the work actually run on them
here. In practice, you should not use a barrier.
A multicore example:
{@ocaml non-deterministic[
# open Saturn.Stack
# let t : int t = create ()
Expand Down Expand Up @@ -158,5 +167,4 @@ val add_seq : 'a t -> 'a Seq.t -> unit
# Domain.join domain_popper
- : int option list = [Some 42; Some 3; Some 2; Some 1; None; Some 12]
]}
*)

0 comments on commit 71b5847

Please sign in to comment.