Skip to content

Commit 8fda53c

Browse files
committed
Add an example using a limiter
This demonstrates a layout problem where the fibers form a staircase.
1 parent d0a3247 commit 8fda53c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

examples/limiter/dune

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(executable
2+
(name main)
3+
(libraries eio.mock))

examples/limiter/main.ml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(* This runs jobs 4 at a time. It's useful to check eio-trace's layout algorithm. *)
2+
3+
open Eio.Std
4+
5+
let lock = Eio.Mutex.create ()
6+
7+
let main () =
8+
List.init 15 Fun.id
9+
|> Fiber.List.iter ~max_fibers:4 (fun i ->
10+
if i = 4 then Fiber.both Fiber.yield Fiber.yield;
11+
Eio.Mutex.use_ro lock Fiber.yield)
12+
13+
let () =
14+
Eio_mock.Backend.run main

0 commit comments

Comments
 (0)