File: trace.md

package info (click to toggle)
ocaml-eio 1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,548 kB
  • sloc: ml: 14,608; ansic: 1,237; makefile: 25
file content (50 lines) | stat: -rw-r--r-- 737 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Test unique ID generation


```ocaml
# #require "eio";;
# for _ = 1 to 5 do
    Printf.printf "%d\n%!" (Eio.Private.Trace.mint_id () :> int)
  done;;
1
2
3
4
5
- : unit = ()
```

A new domain gets a new chunk:

```ocaml
# Domain.join @@ Domain.spawn
    (fun () ->
      for _ = 1 to 5 do
        Printf.printf "%d\n%!" (Eio.Private.Trace.mint_id () :> int)
      done);;
1024
1025
1026
1027
1028
- : unit = ()
```

When the original domain exhausts its chunk, it jumps to the next free chunk:

```ocaml
# for _ = 1 to 1024 - 9 do
    Eio.Private.Trace.mint_id () |> ignore
  done;;
- : unit = ()

# for _ = 1 to 5 do
    Printf.printf "%d\n%!" (Eio.Private.Trace.mint_id () :> int)
  done;;
1021
1022
1023
2048
2049
- : unit = ()
```