package eio
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=0c33742074562631677886f4fe4a02f9672cec94297ff85c2ed854db5baa71aa
sha512=590843cb5fb3906fd5ab9911d29206172d164a53c48e635871a23c95d4cdce8ae0999480471187fdddee8c9c523148911ca140feabde6a826c317671a3b33090
doc/eio/Eio/index.html
Module EioSource
Effects based parallel IO for OCaml.
Eio provides support for concurrency (juggling many tasks) and parallelism (using multiple CPU cores for performance).
It provides facilities for creating and coordinating fibers (light-weight threads) and domains (for parallel processing), as well as interfaces for interacting with resources provided by the operating system.
These features must be used within an event loop, provided by an Eio backend. Applications can use Eio_main.run to run a suitable loop.
See https://github.com/ocaml-multicore/eio for a tutorial.
Concurrency primitives
Grouping fibers and other resources so they can be turned off together.
A promise is a placeholder for result that will arrive in the future.
Commonly used standard features. This module is intended to be opened.
Cross-platform OS API
The general pattern here is that each type of resource has a set of functions for using it, plus an object type to allow defining your own implementations. To use the resources, it is recommended that you use the functions rather than calling methods directly. Using the functions results in better error messages from the compiler, and may provide extra features or sanity checks.
The system resources are available from the environment argument provided by your event loop (e.g. Eio_main.run).
A base class for objects that can be queried at runtime for extra features.
Parallel computation across multiple CPU cores.
Errors and Debugging
val traceln :
?__POS__:(string * int * int * int) ->
('a, Format.formatter, unit, unit) format4 ->
'atraceln fmt outputs a debug message (typically to stderr).
Trace messages are printed by default and do not require logging to be configured first. The message is printed with a newline, and is flushed automatically. traceln is intended for quick debugging rather than for production code.
Unlike most Eio operations, traceln will never switch to another fiber; if the OS is not ready to accept the message then the whole domain waits.
It is safe to call traceln from multiple domains at the same time. Each line will be written atomically.
Examples:
traceln "x = %d" x;
traceln "x = %d" x ~__POS__; (* With location information *)