79 Commits

Author SHA1 Message Date
Thomas Leonard
c4d19d5495 Move Eio_null to Eio_mock.Backend
It can be useful for tests to be able to run an event loop without
having to depend on eio_main.

Also, replace the inefficient list-based queue with a proper Lf_queue.
2022-06-25 22:14:37 +01:00
Thomas Leonard
1b511e81ef Minor updates for 5.0.0~alpha0 2022-06-21 16:00:06 +01:00
Thomas Leonard
a23fa39835 Add eio.mock library for testing
At the moment it has mock flows and networks.

Also, add missing `close` and `probe` methods to some network types.
2022-06-20 15:30:32 +01:00
Thomas Leonard
5ca895c635 Lwt_eio has moved 2022-06-03 14:37:59 +01:00
Thomas Leonard
55c08837ab Improve the installation instructions
- Say how to install 5.0+trunk, and mention that this is needed for arm.
- Show how to install a stable release from opam-repository.
2022-05-22 11:40:08 +01:00
Patrick Ferris
b478cb9e99
Update README.md 2022-05-09 13:25:53 +01:00
Thomas Leonard
4d921de00c Rename Fibre to Fiber
This is to match the compiler's spelling.
2022-02-22 13:06:06 +00:00
Thomas Leonard
be793386a6 Remove confusing use of the word "object"
In "Object Capabilities", people frequently assume "object" is referring
to the use of OCaml objects (i.e. polymorphic records).

Also, link to rational document when discussing provider interfaces.
2022-02-21 16:38:56 +00:00
Thomas Leonard
e5dafae6cb Add an example Eio_null backend 2022-02-16 14:13:15 +00:00
Thomas Leonard
ccae40618c Minor documentation fixes 2022-02-10 11:26:50 +00:00
Thomas Leonard
e9b953b062 Link to generated odoc from README 2022-02-09 14:12:32 +00:00
Thomas Leonard
078e35d85c Remove ctf package from README too 2022-02-08 19:51:57 +00:00
Thomas Leonard
9966d9c3fb Move ctf to eio
This isn't a useful package on its own and its API is likely to change a
lot, so hide it inside the eio package for now.
2022-02-08 16:58:44 +00:00
Thomas Leonard
63ceb78f34 Fix deprecation warning in README 2022-02-08 16:24:22 +00:00
Thomas Leonard
83bcd3e28f Update README 2022-02-08 15:30:28 +00:00
Thomas Leonard
3e46d40d27 Remove "broken" state from promises
Lwt needs this because it uses promises for thread results, and threads can always raise.
But we don't use promises for that, and so can afford to be more explicit.

- A promise is now simply unresolved or resolved.
- `Promise.fulfill` is now `Promise.resolve`.
- `Promise.break` and `Promise.broken` are gone.
- `Promise.await` doesn't raise; `await_result` is gone.
- `Promise.state` is now `Promise.peek` and returns an option.
- `Promise.fulfilled` is now `Promise.create_resolved`.

Some helpers using result types are provided to handle cases that need exceptions:

- `type 'a or_exn = ('a, exn) result t`.
- `resolve_ok` and `resolve_error` wrap the value in `Ok` or `Error`.
- `await_exn` awaits a result promise and raises the error.
2022-02-07 09:03:36 +00:00
Thomas Leonard
fa95115806 Document how to implement Eio objects yourself
Also, provide a default implementation of `read_methods`.
2022-02-04 10:29:38 +00:00
Thomas Leonard
3caf6081b3 Document the new load and save functions 2022-01-31 09:52:00 +00:00
Thomas Leonard
e5958e6d82 Add README section on parsing 2022-01-28 14:33:11 +00:00
Thomas Leonard
07bfb2baf2 Split eio.ml out into separate modules
It was getting a bit long.
2022-01-26 13:03:58 +00:00
Thomas Leonard
6d80705250 Don't depend on Unix for IP address type 2022-01-25 13:27:36 +00:00
Thomas Leonard
1307c96e2e Add Multicore Guide explaining the new memory model 2022-01-14 12:11:00 +00:00
Thomas Leonard
e62b883d9d Minor updates to README
- Clarify switch behaviour.
- Mention `Lwt_eio`.
- Note that Eio is getting more mature now.
2022-01-13 09:42:28 +00:00
Thomas Leonard
cb619dd200 Add README example of a cache using promises 2022-01-06 16:57:03 +00:00
Thomas Leonard
61b54b4c73 Simplify and improve error reporting
Cancellation contexts are now only about making things stop promptly,
not about reporting errors. That's now handled entirely by the switches.

This fixes a problem where an error raised while cancelling an operation
would be lost.

`Switch.turn_off` is now called `Switch.fail`.
2022-01-06 10:39:44 +00:00
Thomas Leonard
7db4aa9ea2 Add rationales for end-of-file and dynamic dispatch 2021-12-21 11:06:47 +00:00
Thomas Leonard
89a19a0ea0 Improve cancellation
Documented how cancellation is supposed to work.

Added `Fibre.check ()`, to check whether the current context has been
cancelled.

In eio_luv, don't wrap an extra Cancelled around cancelled exceptions.

Don't create a `Multiple_exn.T` of a cancellation and something else.
Just ignore the cancellation in that case and report the interesting
exception. Whoever sent the cancellation is responsible for reporting
that problem.

Mark all nested contexts as cancelled before running any functions.
If a function fails (shouldn't happen now), still run those from other
contexts.
2021-12-17 10:14:19 +00:00
Thomas Leonard
3614367515 Make Fibre.fork put both fibres at the head of the run-queue
Some arguments in favour of this:

- This is the most flexible arrangement (you can add yields gets the
  other combinations).
- The order seems a bit more natural (the README examples look better).
- Might be better for the cache in some cases (domainslib works this way).
- Means that `Fibre.both f g` starts `f` and `g` in similar contexts.
  Previously, `f` started before any queued items, while `g` started
  after, which was a bit inconsistent.

This also adds some documentation about scheduling order to the ocamldoc
(note that the previous documentation for `fork` was wrong) and adds a
`rationale.md` file explaining the choice.
2021-12-15 13:58:33 +00:00
Thomas Leonard
983ae79df9 Rename Fork_ignore to Fork
The hardly-used `Fibre.fork` is now `Fibre.fork_promise`.
2021-12-15 13:46:07 +00:00
Thomas Leonard
43bae57330 Explain about Promises and Streams in the README 2021-12-13 12:01:35 +00:00
Thomas Leonard
d8e91951e8 Split out Ctf_unix module
This helps avoid Eio getting a dependency on Unix.
Also, added `Ctf_unix.with_tracing` as a convenience function.
2021-12-02 14:37:13 +00:00
Thomas Leonard
bb105baa32 Add Domain_manager.run to start a domain with an event loop 2021-12-02 14:08:06 +00:00
Thomas Leonard
8f49944508 Add Fibre.first
Runs two threads and returns the result from the first to finish,
cancelling the other thread (like `Lwt.pick`).
2021-11-12 12:00:38 +00:00
Thomas Leonard
6bf90e1cd9 Update trace diagram in README 2021-11-11 19:28:26 +00:00
Thomas Leonard
3713d9470b Split cancellation out from Switch
Cancellation and grouping are easier to handle separately.

`Fibre.both` no longer takes a switch, but instead just creates a new
cancellation context.
2021-11-11 19:13:49 +00:00
Thomas Leonard
ed2382bed5 Implicit cancellation
Instead of requiring every cancellable operation to pass a `~sw`
argument, give each fibre a default switch and use that. It's too easy
to forget to make something cancellable and clutters up the code.
2021-11-08 13:27:51 +00:00
Thomas Leonard
d9f141edf9 Using pin-depends instead of vendoring for uring
See https://github.com/ocaml/dune/issues/3911.

Fixes #87.
2021-11-03 11:57:41 +00:00
Thomas Leonard
dceeecd14f Update README to mention libuv backend
Reported by KC Sivaramakrishnan.
2021-11-01 15:30:39 +00:00
Thomas Leonard
0370b365ba Fix some MDX warnings about missing ;; 2021-10-11 14:15:00 +01:00
Bikal Lem
93c6ed2bdb update opam switch instructions 2021-10-08 11:56:05 +01:00
KC Sivaramakrishnan
5245ca5f74
Update README.md 2021-09-30 18:40:11 +05:30
Christine Rose
82faedb8d9 Initial edits for consistency, formatting, and clarity
(the non-contentious parts of #78)

Signed-off-by: Christine Rose <professor.rose@gmail.com>
2021-08-31 10:19:42 +01:00
Thomas Leonard
84a1983a4e Only try to install eio_linux on Linux 2021-08-25 14:52:03 +01:00
Thomas Leonard
66521eb1fb Disable opam file generation due to dune bug
The `sed` solution doesn't work on macos.
2021-08-25 14:40:16 +01:00
Thomas Leonard
74889d9d43 Link to some eio examples 2021-08-24 10:01:41 +01:00
Thomas Leonard
b77176e212 Add eio_luv backend 2021-07-29 14:39:01 +01:00
Thomas Leonard
8f5043c458 Improve traceln formatting
- Set up a box so that wrapping works correctly.
- Print a `+` at the start of each trace line to show it is trace output.
- Format location tag with the rest of the output (fixes wrapping).
- Add tests for traceln.
2021-07-15 11:42:19 +01:00
Thomas Leonard
457ec702bd Add work-around for dune bug
See https://github.com/ocaml/dune/pull/4806
2021-07-13 14:17:27 +01:00
Thomas Leonard
13a3448833 Update README
It is now necessary to pin the effects versions of ppxlib and
ocaml-migrate-parsetree manually.

Also, add a note about using determinism for tests.
2021-07-13 13:31:43 +01:00
Thomas Leonard
108aa75230 Update to latest MDX to fix exception reporting 2021-07-13 08:48:25 +01:00