@@ -15,8 +15,7 @@ Eio replaces existing concurrency libraries such as Lwt
1515<!-- vim-markdown-toc GFM -->
1616
1717* [ Motivation] ( #motivation )
18- * [ Current Status] ( #current-status )
19- * [ Structure of the Code] ( #structure-of-the-code )
18+ * [ Eio packages] ( #eio-packages )
2019* [ Getting OCaml 5.1] ( #getting-ocaml-51 )
2120* [ Getting Eio] ( #getting-eio )
2221* [ Running Eio] ( #running-eio )
@@ -80,22 +79,18 @@ Additionally, modern operating systems provide high-performance alternatives to
8079For example, Linux's io_uring system has applications write the operations they want to perform to a ring buffer,
8180which Linux handles asynchronously, and Eio can take advantage of this.
8281
83- ## Current Status
84-
85- See [ Eio 1.0 progress tracking] ( https://github.com/ocaml-multicore/eio/issues/388 ) for the current status.
8682Please try porting your programs to use Eio and submit PRs or open issues when you find problems.
8783Remember that you can always [ fall back to using Lwt libraries] ( #lwt ) to provide missing features if necessary.
88-
8984See [ Awesome Multicore OCaml] [ ] for links to work migrating other projects to Eio.
9085
91- ## Structure of the Code
86+ ## Eio packages
9287
9388- [ Eio] [ ] provides concurrency primitives (promises, etc.) and a high-level, cross-platform OS API.
9489- [ Eio_posix] [ ] provides a cross-platform backend for these APIs for POSIX-type systems.
95- - [ Eio_linux] [ ] provides a Linux io-uring backend for these APIs,
96- plus a low-level API that can be used directly (in non-portable code).
90+ - [ Eio_linux] [ ] provides a Linux io_uring backend for these APIs.
9791- [ Eio_windows] [ ] is for use on Windows (incomplete - [ help wanted] ( https://github.com/ocaml-multicore/eio/issues/125 ) ).
9892- [ Eio_main] [ ] selects an appropriate backend (e.g. ` eio_linux ` or ` eio_posix ` ), depending on your platform.
93+ - [ Eio_js] [ ] allows Eio code to run in the browser, using ` js_of_ocaml ` .
9994
10095## Getting OCaml 5.1
10196
@@ -135,18 +130,18 @@ prompt and return after each line.)
135130# open Eio.Std;;
136131```
137132
138- This function writes a greeting to ` stdout ` using [ Eio.Flow] [ ] :
133+ This function writes a greeting to ` out ` using [ Eio.Flow] [ ] :
139134
140135``` ocaml
141- let main ~stdout =
142- Eio.Flow.copy_string "Hello, world!\n" stdout
136+ let main out =
137+ Eio.Flow.copy_string "Hello, world!\n" out
143138```
144139
145140We use [ Eio_main.run] [ ] to run the event loop and call ` main ` from there:
146141
147142``` ocaml
148143# Eio_main.run @@ fun env ->
149- main ~stdout: (Eio.Stdenv.stdout env);;
144+ main (Eio.Stdenv.stdout env);;
150145Hello, world!
151146- : unit = ()
152147```
@@ -156,7 +151,7 @@ Note that:
156151- The ` env ` argument represents the standard environment of a Unix process, allowing it to interact with the outside world.
157152 A program will typically start by extracting from ` env ` whatever things the program will need and then calling ` main ` with them.
158153
159- - The type of the ` main ` function here tells us that this program only interacts via ` stdout ` .
154+ - The type of the ` main ` function here tells us that this program only interacts via the ` out ` flow .
160155
161156- ` Eio_main.run ` automatically calls the appropriate run function for your platform.
162157 For example, on Linux this will call ` Eio_linux.run ` . For non-portable code you can use the platform-specific library directly.
@@ -171,7 +166,7 @@ For example, instead of giving `main` the real standard output, we can have it w
171166``` ocaml
172167# Eio_main.run @@ fun _env ->
173168 let buffer = Buffer.create 20 in
174- main ~stdout: (Eio.Flow.buffer_sink buffer);
169+ main (Eio.Flow.buffer_sink buffer);
175170 traceln "Main would print %S" (Buffer.contents buffer);;
176171+Main would print "Hello, world!\n"
177172- : unit = ()
@@ -185,8 +180,7 @@ The [Eio_mock][] library provides some convenient pre-built mocks:
185180``` ocaml
186181# #require "eio.mock";;
187182# Eio_main.run @@ fun _env ->
188- let mock_stdout = Eio_mock.Flow.make "mock-stdout" in
189- main ~stdout:mock_stdout;;
183+ main (Eio_mock.Flow.make "mock-stdout");;
190184+mock-stdout: wrote "Hello, world!\n"
191185- : unit = ()
192186```
@@ -934,6 +928,9 @@ The mock backend provides a mock clock that advances automatically where there i
934928- : unit = ()
935929```
936930
931+ Note: You could also just use ` Eio_unix.sleep 5.0 ` if you don't want to pass a clock around.
932+ This is especially useful if you need to insert a delay for some quick debugging.
933+
937934## Multicore Support
938935
939936OCaml allows a program to create multiple * domains* in which to run code, allowing multiple CPUs to be used at once.
@@ -1593,6 +1590,9 @@ In particular, if you test your code by providing (deterministic) mocks then the
15931590An easy way to write tests is by having the mocks call ` traceln ` and then comparing the trace output with the expected output.
15941591See Eio's own tests for examples, e.g., [ tests/switch.md] ( tests/switch.md ) .
15951592
1593+ Note: this only applies to the high-level APIs in the ` Eio ` module.
1594+ Programs can behave non-deterministically when using ` Eio_unix ` or the various ` Low_level ` APIs provided by the backends.
1595+
15961596## Provider Interfaces
15971597
15981598Eio applications use resources by calling functions (such as ` Eio.Flow.write ` ).
@@ -1912,3 +1912,4 @@ Some background about the effects system can be found in:
19121912[ Olly ] : https://github.com/tarides/runtime_events_tools
19131913[ eio-trace ] : https://github.com/ocaml-multicore/eio-trace
19141914[ cap_enter ] : https://man.freebsd.org/cgi/man.cgi?query=cap_enter
1915+ [ eio_js ] : https://github.com/ocaml-multicore/eio_js
0 commit comments