From ba6b7b0eb078c60db341361aef327b07b2676693 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Tue, 29 Aug 2023 11:37:57 +0100 Subject: [PATCH] Update eio doc to 0.11-43-gad7149dc. --- eio/Eio/.dummy | 0 eio/Eio/Buf_read/BE/index.html | 2 +- eio/Eio/Buf_read/LE/index.html | 2 +- eio/Eio/Buf_read/Syntax/index.html | 2 +- eio/Eio/Buf_read/index.html | 8 ++-- eio/Eio/Buf_write/BE/index.html | 2 +- eio/Eio/Buf_write/LE/index.html | 2 +- eio/Eio/Buf_write/index.html | 4 +- eio/Eio/Cancel/index.html | 2 +- eio/Eio/Condition/index.html | 2 +- eio/Eio/Debug/index.html | 4 +- eio/Eio/Domain_manager/Pi/index.html | 2 + .../Pi/module-type-MGR/index.html | 2 + eio/Eio/Domain_manager/class-t/index.html | 2 - eio/Eio/Domain_manager/index.html | 2 +- eio/Eio/Exn/Backend/index.html | 2 +- eio/Eio/Exn/index.html | 2 +- eio/Eio/Fiber/List/index.html | 2 +- eio/Eio/Fiber/index.html | 4 +- eio/Eio/File/Pi/index.html | 2 + eio/Eio/File/Pi/module-type-READ/index.html | 2 + eio/Eio/File/Pi/module-type-WRITE/index.html | 2 + eio/Eio/File/Stat/index.html | 2 +- eio/Eio/File/Unix_perm/index.html | 2 +- eio/Eio/File/class-ro/index.html | 2 - eio/Eio/File/class-rw/index.html | 2 - eio/Eio/File/index.html | 2 +- eio/Eio/Flow/Pi/index.html | 13 ++++++ .../Flow/Pi/module-type-SHUTDOWN/index.html | 2 + eio/Eio/Flow/Pi/module-type-SINK/index.html | 2 + eio/Eio/Flow/Pi/module-type-SOURCE/index.html | 2 + .../Flow/Pi/module-type-TWO_WAY/index.html | 2 + eio/Eio/Flow/class-sink/index.html | 2 - eio/Eio/Flow/class-source/index.html | 2 - eio/Eio/Flow/class-two_way/index.html | 2 - eio/Eio/Flow/class-type-close/index.html | 2 - eio/Eio/Flow/index.html | 2 +- eio/Eio/Fs/Pi/index.html | 2 + eio/Eio/Fs/Pi/module-type-DIR/index.html | 8 ++++ eio/Eio/Fs/class-dir/index.html | 21 --------- eio/Eio/Fs/class-dir_with_close/index.html | 2 - eio/Eio/Fs/index.html | 2 +- eio/Eio/Generic/class-type-close/index.html | 2 - eio/Eio/Generic/class-type-t/index.html | 2 - eio/Eio/Generic/index.html | 2 - eio/Eio/Lazy/index.html | 2 + eio/Eio/Mutex/index.html | 2 +- eio/Eio/Net/Ipaddr/V4/index.html | 2 +- eio/Eio/Net/Ipaddr/V6/index.html | 2 +- eio/Eio/Net/Ipaddr/index.html | 2 +- eio/Eio/Net/Pi/index.html | 10 +++++ .../Pi/module-type-DATAGRAM_SOCKET/index.html | 2 + .../module-type-LISTENING_SOCKET/index.html | 2 + eio/Eio/Net/Pi/module-type-NETWORK/index.html | 15 +++++++ .../Pi/module-type-STREAM_SOCKET/index.html | 2 + eio/Eio/Net/Sockaddr/index.html | 2 +- eio/Eio/Net/class-datagram_socket/index.html | 2 - eio/Eio/Net/class-listening_socket/index.html | 3 -- eio/Eio/Net/class-socket/index.html | 2 - eio/Eio/Net/class-stream_socket/index.html | 2 - eio/Eio/Net/class-t/index.html | 13 ------ eio/Eio/Net/index.html | 45 ++++++++++++------- eio/Eio/Path/index.html | 11 +++-- eio/Eio/Pool/index.html | 8 ++++ eio/Eio/Private/Broadcast/index.html | 2 +- .../Cells/Make/argument-1-Cell/index.html | 2 +- eio/Eio/Private/Cells/Make/index.html | 2 +- eio/Eio/Private/Cells/index.html | 2 +- .../Private/Cells/module-type-CELL/index.html | 2 +- eio/Eio/Private/Ctf/Control/index.html | 2 +- eio/Eio/Private/Ctf/index.html | 2 +- eio/Eio/Private/Debug/index.html | 4 +- eio/Eio/Private/Dla/index.html | 2 +- eio/Eio/Private/Effects/index.html | 2 +- eio/Eio/Private/Fiber_context/index.html | 2 +- eio/Eio/Private/Suspend/index.html | 2 +- eio/Eio/Private/index.html | 2 +- eio/Eio/Process/Pi/index.html | 12 +++++ eio/Eio/Process/Pi/module-type-MGR/index.html | 16 +++++++ .../Process/Pi/module-type-PROCESS/index.html | 2 + eio/Eio/Process/class-mgr/index.html | 14 ------ eio/Eio/Process/class-t/index.html | 2 - eio/Eio/Process/index.html | 43 +++++++++--------- eio/Eio/Promise/index.html | 2 +- eio/Eio/Resource/index.html | 8 ++++ eio/Eio/Semaphore/index.html | 2 +- eio/Eio/Std/index.html | 2 +- eio/Eio/Stdenv/index.html | 4 +- eio/Eio/Stream/index.html | 2 +- eio/Eio/Switch/index.html | 2 +- eio/Eio/Time/Mono/class-t/index.html | 2 - eio/Eio/Time/Mono/index.html | 2 +- eio/Eio/Time/Pi/index.html | 9 ++++ eio/Eio/Time/Pi/module-type-CLOCK/index.html | 2 + eio/Eio/Time/Timeout/index.html | 2 +- eio/Eio/Time/class-clock/index.html | 2 - eio/Eio/Time/class-clock_base/index.html | 2 - eio/Eio/Time/index.html | 6 +-- eio/Eio/index.html | 2 +- eio/Eio__core/.dummy | 0 eio/Eio__core/index.html | 2 +- eio/Eio_mock/.dummy | 0 eio/Eio_mock/Action/index.html | 2 +- eio/Eio_mock/Backend/index.html | 2 +- eio/Eio_mock/Clock/Mono/index.html | 5 +-- eio/Eio_mock/Clock/index.html | 5 +-- eio/Eio_mock/Clock/module-type-S/index.html | 5 +-- eio/Eio_mock/Domain_manager/index.html | 2 + eio/Eio_mock/Flow/index.html | 8 +--- eio/Eio_mock/Handler/index.html | 2 +- eio/Eio_mock/Net/index.html | 14 +----- eio/Eio_mock/index.html | 4 +- eio/Eio_unix/.dummy | 0 eio/Eio_unix/Ctf/index.html | 2 +- eio/Eio_unix/Fd/index.html | 4 +- eio/Eio_unix/Net/Ipaddr/index.html | 2 +- .../Net/class-datagram_socket/index.html | 2 - .../Net/class-stream_socket/index.html | 2 - eio/Eio_unix/Net/class-t/index.html | 2 - eio/Eio_unix/Net/index.html | 35 +++++++++++---- eio/Eio_unix/Pi/index.html | 13 ++++++ .../Pi/module-type-DATAGRAM_SOCKET/index.html | 2 + eio/Eio_unix/Pi/module-type-FLOW/index.html | 7 +++ .../module-type-LISTENING_SOCKET/index.html | 5 +++ .../Pi/module-type-STREAM_SOCKET/index.html | 7 +++ eio/Eio_unix/Private/Rcfd/index.html | 2 +- eio/Eio_unix/Private/index.html | 3 +- .../Process/Make_mgr/argument-1-X/index.html | 10 +++++ eio/Eio_unix/Process/Make_mgr/index.html | 26 +++++++++++ eio/Eio_unix/Process/Pi/index.html | 4 ++ .../Process/Pi/module-type-MGR/index.html | 24 ++++++++++ eio/Eio_unix/Process/class-mgr/index.html | 17 ------- eio/Eio_unix/Process/index.html | 10 +++-- eio/Eio_unix/Resource/index.html | 2 +- eio/Eio_unix/Stdenv/index.html | 24 +++++----- eio/Eio_unix/index.html | 2 +- eio/Eio_utils/.dummy | 0 eio/Eio_utils/Lf_queue/index.html | 2 +- eio/Eio_utils/Suspended/index.html | 2 +- eio/Eio_utils/Zzz/Key/index.html | 2 +- eio/Eio_utils/Zzz/index.html | 2 +- eio/Eio_utils/index.html | 2 +- eio/index.html | 2 +- eio_linux/Eio_linux/.dummy | 0 .../Eio_linux/Low_level/Process/index.html | 2 +- eio_linux/Eio_linux/Low_level/index.html | 2 +- eio_linux/Eio_linux/index.html | 2 +- eio_linux/index.html | 2 +- eio_main/Eio_main/.dummy | 0 eio_main/Eio_main/index.html | 2 +- eio_main/index.html | 2 +- eio_posix/Eio_posix/.dummy | 0 .../Eio_posix/Low_level/Open_flags/index.html | 2 +- .../Eio_posix/Low_level/Process/index.html | 2 +- eio_posix/Eio_posix/Low_level/index.html | 14 +++++- eio_posix/Eio_posix/index.html | 2 +- eio_posix/index.html | 2 +- eio_windows/index.html | 2 +- index.html | 10 ++--- 159 files changed, 446 insertions(+), 303 deletions(-) delete mode 100644 eio/Eio/.dummy create mode 100644 eio/Eio/Domain_manager/Pi/index.html create mode 100644 eio/Eio/Domain_manager/Pi/module-type-MGR/index.html delete mode 100644 eio/Eio/Domain_manager/class-t/index.html create mode 100644 eio/Eio/File/Pi/index.html create mode 100644 eio/Eio/File/Pi/module-type-READ/index.html create mode 100644 eio/Eio/File/Pi/module-type-WRITE/index.html delete mode 100644 eio/Eio/File/class-ro/index.html delete mode 100644 eio/Eio/File/class-rw/index.html create mode 100644 eio/Eio/Flow/Pi/index.html create mode 100644 eio/Eio/Flow/Pi/module-type-SHUTDOWN/index.html create mode 100644 eio/Eio/Flow/Pi/module-type-SINK/index.html create mode 100644 eio/Eio/Flow/Pi/module-type-SOURCE/index.html create mode 100644 eio/Eio/Flow/Pi/module-type-TWO_WAY/index.html delete mode 100644 eio/Eio/Flow/class-sink/index.html delete mode 100644 eio/Eio/Flow/class-source/index.html delete mode 100644 eio/Eio/Flow/class-two_way/index.html delete mode 100644 eio/Eio/Flow/class-type-close/index.html create mode 100644 eio/Eio/Fs/Pi/index.html create mode 100644 eio/Eio/Fs/Pi/module-type-DIR/index.html delete mode 100644 eio/Eio/Fs/class-dir/index.html delete mode 100644 eio/Eio/Fs/class-dir_with_close/index.html delete mode 100644 eio/Eio/Generic/class-type-close/index.html delete mode 100644 eio/Eio/Generic/class-type-t/index.html delete mode 100644 eio/Eio/Generic/index.html create mode 100644 eio/Eio/Lazy/index.html create mode 100644 eio/Eio/Net/Pi/index.html create mode 100644 eio/Eio/Net/Pi/module-type-DATAGRAM_SOCKET/index.html create mode 100644 eio/Eio/Net/Pi/module-type-LISTENING_SOCKET/index.html create mode 100644 eio/Eio/Net/Pi/module-type-NETWORK/index.html create mode 100644 eio/Eio/Net/Pi/module-type-STREAM_SOCKET/index.html delete mode 100644 eio/Eio/Net/class-datagram_socket/index.html delete mode 100644 eio/Eio/Net/class-listening_socket/index.html delete mode 100644 eio/Eio/Net/class-socket/index.html delete mode 100644 eio/Eio/Net/class-stream_socket/index.html delete mode 100644 eio/Eio/Net/class-t/index.html create mode 100644 eio/Eio/Pool/index.html create mode 100644 eio/Eio/Process/Pi/index.html create mode 100644 eio/Eio/Process/Pi/module-type-MGR/index.html create mode 100644 eio/Eio/Process/Pi/module-type-PROCESS/index.html delete mode 100644 eio/Eio/Process/class-mgr/index.html delete mode 100644 eio/Eio/Process/class-t/index.html create mode 100644 eio/Eio/Resource/index.html delete mode 100644 eio/Eio/Time/Mono/class-t/index.html create mode 100644 eio/Eio/Time/Pi/index.html create mode 100644 eio/Eio/Time/Pi/module-type-CLOCK/index.html delete mode 100644 eio/Eio/Time/class-clock/index.html delete mode 100644 eio/Eio/Time/class-clock_base/index.html delete mode 100644 eio/Eio__core/.dummy delete mode 100644 eio/Eio_mock/.dummy create mode 100644 eio/Eio_mock/Domain_manager/index.html delete mode 100644 eio/Eio_unix/.dummy delete mode 100644 eio/Eio_unix/Net/class-datagram_socket/index.html delete mode 100644 eio/Eio_unix/Net/class-stream_socket/index.html delete mode 100644 eio/Eio_unix/Net/class-t/index.html create mode 100644 eio/Eio_unix/Pi/index.html create mode 100644 eio/Eio_unix/Pi/module-type-DATAGRAM_SOCKET/index.html create mode 100644 eio/Eio_unix/Pi/module-type-FLOW/index.html create mode 100644 eio/Eio_unix/Pi/module-type-LISTENING_SOCKET/index.html create mode 100644 eio/Eio_unix/Pi/module-type-STREAM_SOCKET/index.html create mode 100644 eio/Eio_unix/Process/Make_mgr/argument-1-X/index.html create mode 100644 eio/Eio_unix/Process/Make_mgr/index.html create mode 100644 eio/Eio_unix/Process/Pi/index.html create mode 100644 eio/Eio_unix/Process/Pi/module-type-MGR/index.html delete mode 100644 eio/Eio_unix/Process/class-mgr/index.html delete mode 100644 eio/Eio_utils/.dummy delete mode 100644 eio_linux/Eio_linux/.dummy delete mode 100644 eio_main/Eio_main/.dummy delete mode 100644 eio_posix/Eio_posix/.dummy diff --git a/eio/Eio/.dummy b/eio/Eio/.dummy deleted file mode 100644 index e69de29bb..000000000 diff --git a/eio/Eio/Buf_read/BE/index.html b/eio/Eio/Buf_read/BE/index.html index 126ce88f4..1bbcb1de7 100644 --- a/eio/Eio/Buf_read/BE/index.html +++ b/eio/Eio/Buf_read/BE/index.html @@ -1,2 +1,2 @@ -BE (eio.Eio.Buf_read.BE)

Module Buf_read.BE

Big endian parsers

val uint16 : int parser

uint16 parses the next 2 bytes as the lower 16 bits of an int in big-endian byte order

val uint32 : int32 parser

uint32 parses the next 4 bytes as an int32 in big-endian byte order

val uint48 : int64 parser

uint48 parses the next 6 bytes as a 48-bit unsigned big-endian integer

val uint64 : int64 parser

uint64 parses the next 8 bytes as an int64 in big-endian byte order

val float : float parser

float parses the next 4 bytes as a float in big-endian byte order

val double : float parser

double parses the next 8 bytes as a float in big-endian byte order

\ No newline at end of file +BE (eio.Eio.Buf_read.BE)

Module Buf_read.BE

Big endian parsers

val uint16 : int parser

uint16 parses the next 2 bytes as the lower 16 bits of an int in big-endian byte order

val uint32 : int32 parser

uint32 parses the next 4 bytes as an int32 in big-endian byte order

val uint48 : int64 parser

uint48 parses the next 6 bytes as a 48-bit unsigned big-endian integer

val uint64 : int64 parser

uint64 parses the next 8 bytes as an int64 in big-endian byte order

val float : float parser

float parses the next 4 bytes as a float in big-endian byte order

val double : float parser

double parses the next 8 bytes as a float in big-endian byte order

\ No newline at end of file diff --git a/eio/Eio/Buf_read/LE/index.html b/eio/Eio/Buf_read/LE/index.html index 0eb472022..f0b13180a 100644 --- a/eio/Eio/Buf_read/LE/index.html +++ b/eio/Eio/Buf_read/LE/index.html @@ -1,2 +1,2 @@ -LE (eio.Eio.Buf_read.LE)

Module Buf_read.LE

Little endian parsers

val uint16 : int parser

uint16 parses the next 2 bytes as the lower 16 bits of an int in little-endian byte order

val uint32 : int32 parser

uint32 parses the next 4 bytes as an int32 in little-endian byte order

val uint48 : int64 parser

uint48 parses the next 6 bytes as a 48-bit unsigned big-endian integer

val uint64 : int64 parser

uint64 parses the next 8 bytes as an int64 in little-endian byte order

val float : float parser

float parses the next 4 bytes as a float in little-endian byte order

val double : float parser

double parses the next 8 bytes as a float in little-endian byte order

\ No newline at end of file +LE (eio.Eio.Buf_read.LE)

Module Buf_read.LE

Little endian parsers

val uint16 : int parser

uint16 parses the next 2 bytes as the lower 16 bits of an int in little-endian byte order

val uint32 : int32 parser

uint32 parses the next 4 bytes as an int32 in little-endian byte order

val uint48 : int64 parser

uint48 parses the next 6 bytes as a 48-bit unsigned big-endian integer

val uint64 : int64 parser

uint64 parses the next 8 bytes as an int64 in little-endian byte order

val float : float parser

float parses the next 4 bytes as a float in little-endian byte order

val double : float parser

double parses the next 8 bytes as a float in little-endian byte order

\ No newline at end of file diff --git a/eio/Eio/Buf_read/Syntax/index.html b/eio/Eio/Buf_read/Syntax/index.html index 6d4aa22eb..20aae6ce3 100644 --- a/eio/Eio/Buf_read/Syntax/index.html +++ b/eio/Eio/Buf_read/Syntax/index.html @@ -1,2 +1,2 @@ -Syntax (eio.Eio.Buf_read.Syntax)

Module Buf_read.Syntax

Convenient syntax for some of the combinators.

val let+ : 'a parser -> ('a -> 'b) -> 'b parser

Syntax for map.

val let* : 'a parser -> ('a -> 'b parser) -> 'b parser

Syntax for bind

val and+ : 'a parser -> 'b parser -> ('a * 'b) parser

Syntax for pair

val and* : 'a parser -> 'b parser -> ('a * 'b) parser

Syntax for pair (same as and+).

val (<*>) : 'a parser -> 'b parser -> ('a * 'b) parser

a <*> b is pair a b.

val (<*) : 'a parser -> 'b parser -> 'a parser

a <* b is map fst (pair a b). It parses two things and keeps only the first.

val (*>) : 'a parser -> 'b parser -> 'b parser

a *> b is map snd (pair a b). It parses two things and keeps only the second.

\ No newline at end of file +Syntax (eio.Eio.Buf_read.Syntax)

Module Buf_read.Syntax

Convenient syntax for some of the combinators.

val let+ : 'a parser -> ('a -> 'b) -> 'b parser

Syntax for map.

val let* : 'a parser -> ('a -> 'b parser) -> 'b parser

Syntax for bind

val and+ : 'a parser -> 'b parser -> ('a * 'b) parser

Syntax for pair

val and* : 'a parser -> 'b parser -> ('a * 'b) parser

Syntax for pair (same as and+).

val (<*>) : 'a parser -> 'b parser -> ('a * 'b) parser

a <*> b is pair a b.

val (<*) : 'a parser -> 'b parser -> 'a parser

a <* b is map fst (pair a b). It parses two things and keeps only the first.

val (*>) : 'a parser -> 'b parser -> 'b parser

a *> b is map snd (pair a b). It parses two things and keeps only the second.

\ No newline at end of file diff --git a/eio/Eio/Buf_read/index.html b/eio/Eio/Buf_read/index.html index 4d02edad4..7554bf52f 100644 --- a/eio/Eio/Buf_read/index.html +++ b/eio/Eio/Buf_read/index.html @@ -1,17 +1,17 @@ -Buf_read (eio.Eio.Buf_read)

Module Eio.Buf_read

Buffered input and parsing

This module provides fairly efficient non-backtracking parsers. It is modelled on Angstrom's API, and you should use that if backtracking is needed.

Example:

let r = Buf_read.of_flow flow ~max_size:1_000_000 in
+Buf_read (eio.Eio.Buf_read)

Module Eio.Buf_read

Buffered input and parsing

This module provides fairly efficient non-backtracking parsers. It is modelled on Angstrom's API, and you should use that if backtracking is needed.

Example:

let r = Buf_read.of_flow flow ~max_size:1_000_000 in
 Buf_read.line r
type t

An input buffer.

exception Buffer_limit_exceeded

Raised if parsing an item would require enlarging the buffer beyond its configured limit.

type 'a parser = t -> 'a

An 'a parser is a function that consumes and returns a value of type 'a.

  • raises Failure

    The flow can't be parsed as a value of type 'a.

  • raises End_of_file

    The flow ended without enough data to parse an 'a.

  • raises Buffer_limit_exceeded

    Parsing the value would exceed the configured size limit.

val parse : ?initial_size:int -> max_size:int -> 'a parser -> - Flow.source -> + _ Flow.source -> ('a, [> `Msg of string ]) Stdlib.result

parse p flow ~max_size uses p to parse everything in flow.

It is a convenience function that does

let buf = of_flow flow ~max_size in
 format_errors (p <* end_of_input) buf
  • parameter initial_size

    see of_flow.

val parse_exn : ?initial_size:int -> max_size:int -> 'a parser -> - Flow.source -> + _ Flow.source -> 'a

parse_exn wraps parse, but raises Failure msg if that returns Error (`Msg msg).

Catching exceptions with parse and then raising them might seem pointless, but this has the effect of turning e.g. an End_of_file exception into a Failure with a more user-friendly message.

val parse_string : 'a parser -> string -> - ('a, [> `Msg of string ]) Stdlib.result

parse_string p s uses p to parse everything in s. It is defined as format_errors (p <* end_of_input) (of_string s)

val parse_string_exn : 'a parser -> string -> 'a

parse_string_exn is like parse_string, but handles errors like parse_exn.

val of_flow : ?initial_size:int -> max_size:int -> Flow.source -> t

of_flow ~max_size flow is a buffered reader backed by flow.

  • parameter initial_size

    The initial amount of memory to allocate for the buffer.

  • parameter max_size

    The maximum size to which the buffer may grow. This must be large enough to hold the largest single item you want to parse (e.g. the longest line, if using line), plus any terminator needed to know the value is complete (e.g. the newline character(s)). This is just to prevent a run-away input from consuming all memory, and you can usually just set it much larger than you expect to need.

val of_buffer : Cstruct.buffer -> t

of_buffer buf is a reader that reads from buf. buf is used directly, without being copied. eof_seen (of_buffer buf) = true. This module will not modify buf itself, but it will expose it via peek.

val of_string : string -> t

of_string s is a reader that reads from s.

val as_flow : t -> Flow.source

as_flow t is a buffered flow.

Reading from it will return data from the buffer, only reading the underlying flow if the buffer is empty.

Reading data

val line : string parser

line parses one line.

Lines can be terminated by either LF or CRLF. The returned string does not include the terminator.

If End_of_file is reached after seeing some data but before seeing a line terminator, the data seen is returned as the last line.

val lines : string Stdlib.Seq.t parser

lines returns a sequence that lazily reads the next line until the end of the input is reached.

lines = seq line ~stop:at_end_of_input

val char : char -> unit parser

char c checks that the next byte is c and consumes it.

  • raises Failure

    if the next byte is not c

val any_char : char parser

any_char parses one character.

val peek_char : char option parser

peek_char returns Some c where c is the next character, but does not consume it.

Returns None at the end of the input stream rather than raising End_of_file.

val string : string -> unit parser

string s checks that s is the next string in the stream and consumes it.

  • raises Failure

    if s is not a prefix of the stream.

val uint8 : int parser

uint8 parses the next byte as an unsigned 8-bit integer.

module BE : sig ... end

Big endian parsers

module LE : sig ... end

Little endian parsers

val take : int -> string parser

take n takes exactly n bytes from the input.

val take_all : string parser

take_all takes all remaining data until end-of-file.

Returns "" if already at end-of-file.

  • raises Buffer_limit_exceeded

    if the remaining data exceeds or equals the buffer limit (it needs one extra byte to confirm it has reached end-of-file).

val take_while : (char -> bool) -> string parser

take_while p finds the first byte for which p is false and consumes and returns all bytes before that.

If p is true for all remaining bytes, it returns everything until end-of-file.

It will return the empty string if there are no matching characters (and therefore never raises End_of_file).

val take_while1 : (char -> bool) -> string parser

take_while1 p is like take_while. However, the parser fails with "take_while1" if at least one character of input hasn't been consumed by the parser.

val skip_while : (char -> bool) -> unit parser

skip_while p skips zero or more bytes for which p is true.

skip_while p t does the same thing as ignore (take_while p t), except that it is not limited by the buffer size.

val skip_while1 : (char -> bool) -> unit parser

skip_while1 p is like skip_while. However, the parser fails with "skip_while1" if at least one character of input hasn't been skipped.

val skip : int -> unit parser

skip n discards the next n bytes.

skip n = map ignore (take n), except that the number of skipped bytes may be larger than the buffer (it will not grow).

Note: if End_of_file is raised, all bytes in the stream will have been consumed.

val at_end_of_input : bool parser

at_end_of_input returns true when at the end of the stream, or false if there is at least one more byte to be read.

val end_of_input : unit parser

end_of_input checks that there are no further bytes in the stream.

  • raises Failure

    if there are further bytes

Combinators

val seq : ?stop:bool parser -> 'a parser -> 'a Stdlib.Seq.t parser

seq p is a sequence that uses p to get the next item.

A sequence node can only be used while the stream is at the expected position, and will raise Invalid_argument if any bytes have been consumed in the meantime. This also means that each node can only be used once; use Seq.memoize to make the sequence persistent.

It is not necessary to consume all the elements of the sequence.

  • parameter stop

    This is used before parsing each item. The sequence ends if this returns true. The default is at_end_of_input.

val pair : 'a parser -> 'b parser -> ('a * 'b) parser

pair a b is a parser that first uses a to parse a value x, then uses b to parse a value y, then returns (x, y).

Note that this module does not support backtracking, so if b fails then the bytes consumed by a are lost.

val return : 'a -> 'a parser

return x is a parser that consumes nothing and always returns x. return is just Fun.const.

val map : ('a -> 'b) -> 'a parser -> 'b parser

map f a is a parser that parses the stream with a to get v, and then returns f v.

val bind : 'a parser -> ('a -> 'b parser) -> 'b parser

bind a f is a parser that first uses a to parse a value v, then uses f v to select the next parser, and then uses that.

val format_errors : 'a parser -> ('a, [> `Msg of string ]) Stdlib.result parser

format_errors p catches Failure, End_of_file and Buffer_limit_exceeded exceptions and returns them as a formatted error message.

module Syntax : sig ... end

Convenient syntax for some of the combinators.

Low-level API

val buffered_bytes : t -> int

buffered_bytes t is the number of bytes that can be read without reading from the underlying flow.

val peek : t -> Cstruct.t

peek t returns a view onto the active part of t's internal buffer.

Performing any operation that might add to the buffer may invalidate this, so it should be used immediately and then forgotten.

Cstruct.length (peek t) = buffered_bytes t.

val ensure : t -> int -> unit

ensure t n ensures that the buffer contains at least n bytes of data.

If not, it reads from the flow until there is.

buffered_bytes (ensure t n) >= n.

  • raises End_of_file

    if the flow ended before n bytes were available

  • raises Buffer_limit_exceeded

    if n exceeds the buffer's maximum size

val consume : t -> int -> unit

consume t n discards the first n bytes from t's buffer.

Use this after peek to mark some bytes as consumed.

buffered_bytes t' = buffered_bytes t - n

Note: unlike skip, this will not read data from the underlying flow.

val consumed_bytes : t -> int

consumed_bytes t is the total number of bytes consumed.

i.e. it is the offset into the stream of the next byte to be parsed.

val eof_seen : t -> bool

eof_seen t indicates whether we've received End_of_file from the underlying flow.

If so, there will never be any further data beyond what peek already returns.

Note that this returns false if we're at the end of the stream but don't know it yet. Use at_end_of_input to be sure.

\ No newline at end of file + ('a, [> `Msg of string ]) Stdlib.result

parse_string p s uses p to parse everything in s. It is defined as format_errors (p <* end_of_input) (of_string s)

val parse_string_exn : 'a parser -> string -> 'a

parse_string_exn is like parse_string, but handles errors like parse_exn.

val of_flow : ?initial_size:int -> max_size:int -> _ Flow.source -> t

of_flow ~max_size flow is a buffered reader backed by flow.

  • parameter initial_size

    The initial amount of memory to allocate for the buffer.

  • parameter max_size

    The maximum size to which the buffer may grow. This must be large enough to hold the largest single item you want to parse (e.g. the longest line, if using line), plus any terminator needed to know the value is complete (e.g. the newline character(s)). This is just to prevent a run-away input from consuming all memory, and you can usually just set it much larger than you expect to need.

val of_buffer : Cstruct.buffer -> t

of_buffer buf is a reader that reads from buf. buf is used directly, without being copied. eof_seen (of_buffer buf) = true. This module will not modify buf itself, but it will expose it via peek.

val of_string : string -> t

of_string s is a reader that reads from s.

val as_flow : t -> Flow.source_ty Std.r

as_flow t is a buffered flow.

Reading from it will return data from the buffer, only reading the underlying flow if the buffer is empty.

Reading data

val line : string parser

line parses one line.

Lines can be terminated by either LF or CRLF. The returned string does not include the terminator.

If End_of_file is reached after seeing some data but before seeing a line terminator, the data seen is returned as the last line.

val lines : string Stdlib.Seq.t parser

lines returns a sequence that lazily reads the next line until the end of the input is reached.

lines = seq line ~stop:at_end_of_input

val char : char -> unit parser

char c checks that the next byte is c and consumes it.

  • raises Failure

    if the next byte is not c

val any_char : char parser

any_char parses one character.

val peek_char : char option parser

peek_char returns Some c where c is the next character, but does not consume it.

Returns None at the end of the input stream rather than raising End_of_file.

val string : string -> unit parser

string s checks that s is the next string in the stream and consumes it.

  • raises Failure

    if s is not a prefix of the stream.

val uint8 : int parser

uint8 parses the next byte as an unsigned 8-bit integer.

module BE : sig ... end

Big endian parsers

module LE : sig ... end

Little endian parsers

val take : int -> string parser

take n takes exactly n bytes from the input.

val take_all : string parser

take_all takes all remaining data until end-of-file.

Returns "" if already at end-of-file.

  • raises Buffer_limit_exceeded

    if the remaining data exceeds or equals the buffer limit (it needs one extra byte to confirm it has reached end-of-file).

val take_while : (char -> bool) -> string parser

take_while p finds the first byte for which p is false and consumes and returns all bytes before that.

If p is true for all remaining bytes, it returns everything until end-of-file.

It will return the empty string if there are no matching characters (and therefore never raises End_of_file).

val take_while1 : (char -> bool) -> string parser

take_while1 p is like take_while. However, the parser fails with "take_while1" if at least one character of input hasn't been consumed by the parser.

val skip_while : (char -> bool) -> unit parser

skip_while p skips zero or more bytes for which p is true.

skip_while p t does the same thing as ignore (take_while p t), except that it is not limited by the buffer size.

val skip_while1 : (char -> bool) -> unit parser

skip_while1 p is like skip_while. However, the parser fails with "skip_while1" if at least one character of input hasn't been skipped.

val skip : int -> unit parser

skip n discards the next n bytes.

skip n = map ignore (take n), except that the number of skipped bytes may be larger than the buffer (it will not grow).

Note: if End_of_file is raised, all bytes in the stream will have been consumed.

val at_end_of_input : bool parser

at_end_of_input returns true when at the end of the stream, or false if there is at least one more byte to be read.

val end_of_input : unit parser

end_of_input checks that there are no further bytes in the stream.

  • raises Failure

    if there are further bytes

Combinators

val seq : ?stop:bool parser -> 'a parser -> 'a Stdlib.Seq.t parser

seq p is a sequence that uses p to get the next item.

A sequence node can only be used while the stream is at the expected position, and will raise Invalid_argument if any bytes have been consumed in the meantime. This also means that each node can only be used once; use Seq.memoize to make the sequence persistent.

It is not necessary to consume all the elements of the sequence.

  • parameter stop

    This is used before parsing each item. The sequence ends if this returns true. The default is at_end_of_input.

val pair : 'a parser -> 'b parser -> ('a * 'b) parser

pair a b is a parser that first uses a to parse a value x, then uses b to parse a value y, then returns (x, y).

Note that this module does not support backtracking, so if b fails then the bytes consumed by a are lost.

val return : 'a -> 'a parser

return x is a parser that consumes nothing and always returns x. return is just Fun.const.

val map : ('a -> 'b) -> 'a parser -> 'b parser

map f a is a parser that parses the stream with a to get v, and then returns f v.

val bind : 'a parser -> ('a -> 'b parser) -> 'b parser

bind a f is a parser that first uses a to parse a value v, then uses f v to select the next parser, and then uses that.

val format_errors : 'a parser -> ('a, [> `Msg of string ]) Stdlib.result parser

format_errors p catches Failure, End_of_file and Buffer_limit_exceeded exceptions and returns them as a formatted error message.

module Syntax : sig ... end

Convenient syntax for some of the combinators.

Low-level API

val buffered_bytes : t -> int

buffered_bytes t is the number of bytes that can be read without reading from the underlying flow.

val peek : t -> Cstruct.t

peek t returns a view onto the active part of t's internal buffer.

Performing any operation that might add to the buffer may invalidate this, so it should be used immediately and then forgotten.

Cstruct.length (peek t) = buffered_bytes t.

val ensure : t -> int -> unit

ensure t n ensures that the buffer contains at least n bytes of data.

If not, it reads from the flow until there is.

buffered_bytes (ensure t n) >= n.

  • raises End_of_file

    if the flow ended before n bytes were available

  • raises Buffer_limit_exceeded

    if n exceeds the buffer's maximum size

val consume : t -> int -> unit

consume t n discards the first n bytes from t's buffer.

Use this after peek to mark some bytes as consumed.

buffered_bytes t' = buffered_bytes t - n

Note: unlike skip, this will not read data from the underlying flow.

val consumed_bytes : t -> int

consumed_bytes t is the total number of bytes consumed.

i.e. it is the offset into the stream of the next byte to be parsed.

val eof_seen : t -> bool

eof_seen t indicates whether we've received End_of_file from the underlying flow.

If so, there will never be any further data beyond what peek already returns.

Note that this returns false if we're at the end of the stream but don't know it yet. Use at_end_of_input to be sure.

\ No newline at end of file diff --git a/eio/Eio/Buf_write/BE/index.html b/eio/Eio/Buf_write/BE/index.html index 8b2a74b9e..4e73a195a 100644 --- a/eio/Eio/Buf_write/BE/index.html +++ b/eio/Eio/Buf_write/BE/index.html @@ -1,2 +1,2 @@ -BE (eio.Eio.Buf_write.BE)

Module Buf_write.BE

Big endian serializers

val uint16 : t -> int -> unit

uint16 t n copies the lower 16 bits of n into the serializer's internal buffer in big-endian byte order.

val uint32 : t -> int32 -> unit

uint32 t n copies n into the serializer's internal buffer in big-endian byte order.

val uint48 : t -> int64 -> unit

uint48 t n copies the lower 48 bits of n into the serializer's internal buffer in big-endian byte order.

val uint64 : t -> int64 -> unit

uint64 t n copies n into the serializer's internal buffer in big-endian byte order.

val float : t -> float -> unit

float t n copies the lower 32 bits of n into the serializer's internal buffer in big-endian byte order.

val double : t -> float -> unit

double t n copies n into the serializer's internal buffer in big-endian byte order.

\ No newline at end of file +BE (eio.Eio.Buf_write.BE)

Module Buf_write.BE

Big endian serializers

val uint16 : t -> int -> unit

uint16 t n copies the lower 16 bits of n into the serializer's internal buffer in big-endian byte order.

val uint32 : t -> int32 -> unit

uint32 t n copies n into the serializer's internal buffer in big-endian byte order.

val uint48 : t -> int64 -> unit

uint48 t n copies the lower 48 bits of n into the serializer's internal buffer in big-endian byte order.

val uint64 : t -> int64 -> unit

uint64 t n copies n into the serializer's internal buffer in big-endian byte order.

val float : t -> float -> unit

float t n copies the lower 32 bits of n into the serializer's internal buffer in big-endian byte order.

val double : t -> float -> unit

double t n copies n into the serializer's internal buffer in big-endian byte order.

\ No newline at end of file diff --git a/eio/Eio/Buf_write/LE/index.html b/eio/Eio/Buf_write/LE/index.html index f0ea66db2..d5eebcead 100644 --- a/eio/Eio/Buf_write/LE/index.html +++ b/eio/Eio/Buf_write/LE/index.html @@ -1,2 +1,2 @@ -LE (eio.Eio.Buf_write.LE)

Module Buf_write.LE

Little endian serializers

val uint16 : t -> int -> unit

uint16 t n copies the lower 16 bits of n into the serializer's internal buffer in little-endian byte order.

val uint32 : t -> int32 -> unit

uint32 t n copies n into the serializer's internal buffer in little-endian byte order.

val uint48 : t -> int64 -> unit

uint48 t n copies the lower 48 bits of n into the serializer's internal buffer in little-endian byte order.

val uint64 : t -> int64 -> unit

uint64 t n copies n into the serializer's internal buffer in little-endian byte order.

val float : t -> float -> unit

float t n copies the lower 32 bits of n into the serializer's internal buffer in little-endian byte order.

val double : t -> float -> unit

double t n copies n into the serializer's internal buffer in little-endian byte order.

\ No newline at end of file +LE (eio.Eio.Buf_write.LE)

Module Buf_write.LE

Little endian serializers

val uint16 : t -> int -> unit

uint16 t n copies the lower 16 bits of n into the serializer's internal buffer in little-endian byte order.

val uint32 : t -> int32 -> unit

uint32 t n copies n into the serializer's internal buffer in little-endian byte order.

val uint48 : t -> int64 -> unit

uint48 t n copies the lower 48 bits of n into the serializer's internal buffer in little-endian byte order.

val uint64 : t -> int64 -> unit

uint64 t n copies n into the serializer's internal buffer in little-endian byte order.

val float : t -> float -> unit

float t n copies the lower 32 bits of n into the serializer's internal buffer in little-endian byte order.

val double : t -> float -> unit

double t n copies n into the serializer's internal buffer in little-endian byte order.

\ No newline at end of file diff --git a/eio/Eio/Buf_write/index.html b/eio/Eio/Buf_write/index.html index dfb9277b3..ed41cfb2d 100644 --- a/eio/Eio/Buf_write/index.html +++ b/eio/Eio/Buf_write/index.html @@ -1,5 +1,5 @@ -Buf_write (eio.Eio.Buf_write)

Module Eio.Buf_write

Buffered output

Serialization primitives built for speed and memory-efficiency.

Buf_write is designed for writing fast and memory-efficient serializers. It is based on the Faraday library, but adapted for Eio. Its core type and related operation gives the user fine-grained control over copying and allocation behavior while serializing user-defined types, and presents the output in a form that makes it possible to use vectorized write operations, such as the writev system call, or any other platform or application-specific output APIs.

A Buf_write serializer manages an internal buffer and a queue of output buffers. The output bufferes may be a sub range of the serializer's internal buffer or one that is user-provided. Buffered writes such as string, char, cstruct, etc., copy the source bytes into the serializer's internal buffer. Unbuffered writes are done with schedule_cstruct, which performs no copying. Instead, it enqueues the source bytes into the serializer's write queue directly.

Example:

module Write = Eio.Buf_write
+Buf_write (eio.Eio.Buf_write)

Module Eio.Buf_write

Buffered output

Serialization primitives built for speed and memory-efficiency.

Buf_write is designed for writing fast and memory-efficient serializers. It is based on the Faraday library, but adapted for Eio. Its core type and related operation gives the user fine-grained control over copying and allocation behavior while serializing user-defined types, and presents the output in a form that makes it possible to use vectorized write operations, such as the writev system call, or any other platform or application-specific output APIs.

A Buf_write serializer manages an internal buffer and a queue of output buffers. The output bufferes may be a sub range of the serializer's internal buffer or one that is user-provided. Buffered writes such as string, char, cstruct, etc., copy the source bytes into the serializer's internal buffer. Unbuffered writes are done with schedule_cstruct, which performs no copying. Instead, it enqueues the source bytes into the serializer's write queue directly.

Example:

module Write = Eio.Buf_write
 
 let () =
     Eio_mock.Backend.run @@ fun () ->
@@ -10,7 +10,7 @@
         Eio.Fiber.yield ();
         Write.string w "baz";
     )

This combines the first two writes, giving:

+stdout: wrote "foobar"
-+stdout: wrote "baz"
type t

The type of a serializer.

exception Flush_aborted

Raised when waiting for a flush to complete if the buffer is destroyed instead.

Running

val with_flow : ?initial_size:int -> Flow.sink -> (t -> 'a) -> 'a

with_flow flow fn runs fn writer, where writer is a buffer that flushes to flow.

Concurrently with fn, it also runs a fiber that copies from writer to flow. If this fiber runs out of data to copy then it will suspend itself. Writing to writer will automatically schedule it to be resumed. This means that pending data is flushed automatically before the process sleeps.

When fn returns, writer is automatically closed and any remaining data is flushed before with_flow itself returns.

  • parameter initial_size

    The initial size of the buffer used to collect writes. New buffers will be allocated as needed, with the same size. If the buffer is too small to contain a write, the size is increased.

Buffered Writes

A serializer manages an internal buffer for coalescing small writes. The size of this buffer is determined when the serializer is created. If the buffer does not contain sufficient space to service a caller's buffered write, the serializer will allocate a new buffer of the sufficient size and use it for the current and subsequent writes. The old buffer will be garbage collected once all of its contents have been flushed.

val string : t -> ?off:int -> ?len:int -> string -> unit

string t ?off ?len str copies str into the serializer's internal buffer.

val bytes : t -> ?off:int -> ?len:int -> Stdlib.Bytes.t -> unit

bytes t ?off ?len bytes copies bytes into the serializer's internal buffer. It is safe to modify bytes after this call returns.

val cstruct : t -> Cstruct.t -> unit

cstruct t cs copies cs into the serializer's internal buffer. It is safe to modify cs after this call returns. For large cstructs, it may be more efficient to use schedule_cstruct.

val write_gen : ++stdout: wrote "baz"
type t

The type of a serializer.

exception Flush_aborted

Raised when waiting for a flush to complete if the buffer is destroyed instead.

Running

val with_flow : ?initial_size:int -> _ Flow.sink -> (t -> 'a) -> 'a

with_flow flow fn runs fn writer, where writer is a buffer that flushes to flow.

Concurrently with fn, it also runs a fiber that copies from writer to flow. If this fiber runs out of data to copy then it will suspend itself. Writing to writer will automatically schedule it to be resumed. This means that pending data is flushed automatically before the process sleeps.

When fn returns, writer is automatically closed and any remaining data is flushed before with_flow itself returns.

  • parameter initial_size

    The initial size of the buffer used to collect writes. New buffers will be allocated as needed, with the same size. If the buffer is too small to contain a write, the size is increased.

Buffered Writes

A serializer manages an internal buffer for coalescing small writes. The size of this buffer is determined when the serializer is created. If the buffer does not contain sufficient space to service a caller's buffered write, the serializer will allocate a new buffer of the sufficient size and use it for the current and subsequent writes. The old buffer will be garbage collected once all of its contents have been flushed.

val string : t -> ?off:int -> ?len:int -> string -> unit

string t ?off ?len str copies str into the serializer's internal buffer.

val bytes : t -> ?off:int -> ?len:int -> Stdlib.Bytes.t -> unit

bytes t ?off ?len bytes copies bytes into the serializer's internal buffer. It is safe to modify bytes after this call returns.

val cstruct : t -> Cstruct.t -> unit

cstruct t cs copies cs into the serializer's internal buffer. It is safe to modify cs after this call returns. For large cstructs, it may be more efficient to use schedule_cstruct.

val write_gen : t -> blit:('a -> src_off:int -> Cstruct.buffer -> dst_off:int -> len:int -> unit) -> off:int -> diff --git a/eio/Eio/Cancel/index.html b/eio/Eio/Cancel/index.html index 412003e9b..24486832e 100644 --- a/eio/Eio/Cancel/index.html +++ b/eio/Eio/Cancel/index.html @@ -1,2 +1,2 @@ -Cancel (eio.Eio.Cancel)

Module Eio.Cancel

Cancelling fibers.

This is the low-level interface to cancellation. Every Switch includes a cancellation context and most users will just use that API instead.

Each domain has a tree of cancellation contexts, and every fiber is registered with one context. A fiber can switch to a different context (e.g. by calling sub). When a context is cancelled, all registered fibers have their current cancellation function (if any) called and removed. Child contexts are cancelled too, recursively, unless marked as protected.

Many operations also check that the current context hasn't been cancelled, so if a fiber is performing a non-cancellable operation it will still get cancelled soon afterwards. This check is typically done when starting an operation, not at the end. If an operation is cancelled after succeeding, but while still waiting on the run queue, it will still return the operation's result. A notable exception is Fiber.yield, which checks at the end. You can also use Fiber.check to check manually.

Whether a fiber is cancelled through a cancellation function or by checking its context, it will receive a Cancelled exception. It is possible the exception will get lost (if something catches it and forgets to re-raise). It is also possible to get this exception even when not cancelled, for example by awaiting a promise which another fiber has resolved to a cancelled exception. When in doubt, use Fiber.check () to find out if your fiber is really cancelled. Ideally this should be done any time you have caught an exception and are planning to ignore it, although if you forget then the next IO operation will typically abort anyway.

When handling a Cancelled exception, quick clean-up actions (such as releasing a mutex or deleting a temporary file) are OK, but operations that may block should be avoided. For example, a network connection should simply be closed, without attempting to send a goodbye message.

The purpose of the cancellation system is to stop fibers quickly, not to report errors. Use Switch.fail instead to record an error.

type t

A cancellation context.

exception Cancelled of exn

Cancelled ex indicates that the context was cancelled with exception ex. It is usually not necessary to report a Cancelled exception to the user, as the original problem will be handled elsewhere.

The nested exception is only intended for debug-level logging and should generally be ignored.

exception Cancel_hook_failed of exn list

Raised by cancel if any of the cancellation hooks themselves fail.

val sub : (t -> 'a) -> 'a

sub fn installs a new cancellation context t, runs fn t inside it, and then restores the old context.

If the old context is cancelled while fn is running then t is cancelled too. t cannot be used after sub returns.

val protect : (unit -> 'a) -> 'a

protect fn runs fn in a new cancellation context that isn't cancelled when its parent is.

This can be used to clean up resources on cancellation. However, it is usually better to use Switch.on_release (which calls this for you).

Note that protect does not check its parent context when it finishes.

val check : t -> unit

check t checks that t hasn't been cancelled.

  • raises Cancelled

    If the context has been cancelled.

val get_error : t -> exn option

get_error t is like check t except that it returns the exception instead of raising it.

If t is finished, this returns (rather than raising) the Invalid_argument exception too.

val cancel : t -> exn -> unit

cancel t ex marks t and its child contexts as cancelled, recursively, and calls all registered fibers' cancellation functions, passing Cancelled ex as the argument.

All cancellation functions are run, even if some of them raise exceptions.

If t is already cancelled then this does nothing.

Note that the caller of this function is still responsible for handling the error somehow (e.g. reporting it to the user); it does not become the responsibility of the cancelled thread(s).

  • raises Cancel_hook_failed

    if one or more hooks fail.

val dump : t Fmt.t

Show the cancellation sub-tree rooted at t, for debugging.

\ No newline at end of file +Cancel (eio.Eio.Cancel)

Module Eio.Cancel

Cancelling fibers.

This is the low-level interface to cancellation. Every Switch includes a cancellation context and most users will just use that API instead.

Each domain has a tree of cancellation contexts, and every fiber is registered with one context. A fiber can switch to a different context (e.g. by calling sub). When a context is cancelled, all registered fibers have their current cancellation function (if any) called and removed. Child contexts are cancelled too, recursively, unless marked as protected.

Many operations also check that the current context hasn't been cancelled, so if a fiber is performing a non-cancellable operation it will still get cancelled soon afterwards. This check is typically done when starting an operation, not at the end. If an operation is cancelled after succeeding, but while still waiting on the run queue, it will still return the operation's result. A notable exception is Fiber.yield, which checks at the end. You can also use Fiber.check to check manually.

Whether a fiber is cancelled through a cancellation function or by checking its context, it will receive a Cancelled exception. It is possible the exception will get lost (if something catches it and forgets to re-raise). It is also possible to get this exception even when not cancelled, for example by awaiting a promise which another fiber has resolved to a cancelled exception. When in doubt, use Fiber.check () to find out if your fiber is really cancelled. Ideally this should be done any time you have caught an exception and are planning to ignore it, although if you forget then the next IO operation will typically abort anyway.

When handling a Cancelled exception, quick clean-up actions (such as releasing a mutex or deleting a temporary file) are OK, but operations that may block should be avoided. For example, a network connection should simply be closed, without attempting to send a goodbye message.

The purpose of the cancellation system is to stop fibers quickly, not to report errors. Use Switch.fail instead to record an error.

type t

A cancellation context.

exception Cancelled of exn

Cancelled ex indicates that the context was cancelled with exception ex. It is usually not necessary to report a Cancelled exception to the user, as the original problem will be handled elsewhere.

The nested exception is only intended for debug-level logging and should generally be ignored.

exception Cancel_hook_failed of exn list

Raised by cancel if any of the cancellation hooks themselves fail.

val sub : (t -> 'a) -> 'a

sub fn installs a new cancellation context t, runs fn t inside it, and then restores the old context.

If the old context is cancelled while fn is running then t is cancelled too. t cannot be used after sub returns.

val protect : (unit -> 'a) -> 'a

protect fn runs fn in a new cancellation context that isn't cancelled when its parent is.

This can be used to clean up resources on cancellation. However, it is usually better to use Switch.on_release (which calls this for you).

Note that protect does not check its parent context when it finishes.

val check : t -> unit

check t checks that t hasn't been cancelled.

  • raises Cancelled

    If the context has been cancelled.

val get_error : t -> exn option

get_error t is like check t except that it returns the exception instead of raising it.

If t is finished, this returns (rather than raising) the Invalid_argument exception too.

val cancel : t -> exn -> unit

cancel t ex marks t and its child contexts as cancelled, recursively, and calls all registered fibers' cancellation functions, passing Cancelled ex as the argument.

All cancellation functions are run, even if some of them raise exceptions.

If t is already cancelled then this does nothing.

Note that the caller of this function is still responsible for handling the error somehow (e.g. reporting it to the user); it does not become the responsibility of the cancelled thread(s).

  • raises Cancel_hook_failed

    if one or more hooks fail.

val dump : t Fmt.t

Show the cancellation sub-tree rooted at t, for debugging.

\ No newline at end of file diff --git a/eio/Eio/Condition/index.html b/eio/Eio/Condition/index.html index 3909b49ce..b7641fb4a 100644 --- a/eio/Eio/Condition/index.html +++ b/eio/Eio/Condition/index.html @@ -1,5 +1,5 @@ -Condition (eio.Eio.Condition)

Module Eio.Condition

Waiting for a condition to become true.

Waiters call await in a loop as long as some condition is false. Fibers that modify inputs to the condition must call broadcast soon afterwards so that waiters can re-check the condition.

Example:

let x = ref 0
+Condition (eio.Eio.Condition)

Module Eio.Condition

Waiting for a condition to become true.

Waiters call await in a loop as long as some condition is false. Fibers that modify inputs to the condition must call broadcast soon afterwards so that waiters can re-check the condition.

Example:

let x = ref 0
 let cond = Eio.Condition.create ()
 let mutex = Eio.Mutex.create ()
 
diff --git a/eio/Eio/Debug/index.html b/eio/Eio/Debug/index.html
index f7420ca4b..720fbc599 100644
--- a/eio/Eio/Debug/index.html
+++ b/eio/Eio/Debug/index.html
@@ -1,5 +1,5 @@
 
-Debug (eio.Eio.Debug)

Module Eio.Debug

Control over debugging.

Example:

open Eio.Std
+Debug (eio.Eio.Debug)

Module Eio.Debug

Control over debugging.

Example:

open Eio.Std
 
 let my_traceln = {
   Eio.Debug.traceln = fun ?__POS__:_ fmt -> Fmt.epr ("[custom-trace] " ^^ fmt ^^ "@.")
@@ -11,4 +11,4 @@
   Fiber.with_binding debug#traceln my_traceln @@ fun () ->
   traceln "Traced with custom function"

This will output:

[custom-trace] Traced with custom function 
type traceln = Private.Debug.traceln = {
  1. traceln : 'a. ?__POS__:(string * int * int * int) -> ('a, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> - 'a;
}

A function that writes trace logging to some trace output.

It must not switch fibers, as tracing must not affect scheduling. If the system is not ready to receive the trace output, the whole domain must block until it is.

type t = < traceln : traceln Fiber.key >

Fiber keys used to control debugging. Use Stdenv.debug to get this.

\ No newline at end of file + 'a;
}

A function that writes trace logging to some trace output.

It must not switch fibers, as tracing must not affect scheduling. If the system is not ready to receive the trace output, the whole domain must block until it is.

val with_trace_prefix : (Stdlib.Format.formatter -> unit) -> (unit -> 'a) -> 'a

with_trace_prefix fmt fn runs fn () with a traceln that outputs fmt before each message.

type t = < traceln : traceln Fiber.key >

Fiber keys used to control debugging. Use Stdenv.debug to get this.

\ No newline at end of file diff --git a/eio/Eio/Domain_manager/Pi/index.html b/eio/Eio/Domain_manager/Pi/index.html new file mode 100644 index 000000000..e202b92a9 --- /dev/null +++ b/eio/Eio/Domain_manager/Pi/index.html @@ -0,0 +1,2 @@ + +Pi (eio.Eio.Domain_manager.Pi)

Module Domain_manager.Pi

module type MGR = sig ... end
type Resource.pi +=
  1. | Mgr : ('t, (module MGR with type t = 't), [> ty ]) Resource.pi
val mgr : (module MGR with type t = 't) -> ('t, ty) Resource.handler
\ No newline at end of file diff --git a/eio/Eio/Domain_manager/Pi/module-type-MGR/index.html b/eio/Eio/Domain_manager/Pi/module-type-MGR/index.html new file mode 100644 index 000000000..8d34a3fce --- /dev/null +++ b/eio/Eio/Domain_manager/Pi/module-type-MGR/index.html @@ -0,0 +1,2 @@ + +MGR (eio.Eio.Domain_manager.Pi.MGR)

Module type Pi.MGR

type t
val run : t -> (cancelled:exn Promise.t -> 'a) -> 'a

run t fn runs fn ~cancelled in a new domain.

If the calling fiber is cancelled, cancelled becomes resolved to the Cancel.Cancelled exception. fn should cancel itself in this case.

val run_raw : t -> (unit -> 'a) -> 'a
\ No newline at end of file diff --git a/eio/Eio/Domain_manager/class-t/index.html b/eio/Eio/Domain_manager/class-t/index.html deleted file mode 100644 index 8f05bf444..000000000 --- a/eio/Eio/Domain_manager/class-t/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -t (eio.Eio.Domain_manager.t)

Class Domain_manager.t

method virtual run_raw : 'a. (unit -> 'a) -> 'a
method virtual run : 'a. (cancelled:exn Promise.t -> 'a) -> 'a

t#run fn runs fn ~cancelled in a new domain.

If the calling fiber is cancelled, cancelled becomes resolved to the Cancel.Cancelled exception. fn should cancel itself in this case.

\ No newline at end of file diff --git a/eio/Eio/Domain_manager/index.html b/eio/Eio/Domain_manager/index.html index b2a61602f..99188dc26 100644 --- a/eio/Eio/Domain_manager/index.html +++ b/eio/Eio/Domain_manager/index.html @@ -1,2 +1,2 @@ -Domain_manager (eio.Eio.Domain_manager)

Module Eio.Domain_manager

Parallel computation across multiple CPU cores.

class virtual t : object ... end
val run : t -> (unit -> 'a) -> 'a

run t f runs f () in a newly-created domain and returns the result.

Other fibers in the calling domain can run in parallel with the new domain.

Warning: f must only access thread-safe values from the calling domain, but this is not enforced by the type system.

If the calling fiber is cancelled, this is propagated to the spawned domain.

val run_raw : t -> (unit -> 'a) -> 'a

run_raw t f is like run, but does not run an event loop in the new domain, and so cannot perform IO, fork fibers, etc.

\ No newline at end of file +Domain_manager (eio.Eio.Domain_manager)

Module Eio.Domain_manager

Parallel computation across multiple CPU cores.

type ty = [
  1. | `Domain_mgr
]
type 'a t = [> ty ] as 'a Resource.t
val run : _ t -> (unit -> 'a) -> 'a

run t f runs f () in a newly-created domain and returns the result.

Other fibers in the calling domain can run in parallel with the new domain.

Warning: f must only access thread-safe values from the calling domain, but this is not enforced by the type system.

If the calling fiber is cancelled, this is propagated to the spawned domain.

val run_raw : _ t -> (unit -> 'a) -> 'a

run_raw t f is like run, but does not run an event loop in the new domain, and so cannot perform IO, fork fibers, etc.

Provider Interface

module Pi : sig ... end
\ No newline at end of file diff --git a/eio/Eio/Exn/Backend/index.html b/eio/Eio/Exn/Backend/index.html index 68e1404f2..e6cdfdd4e 100644 --- a/eio/Eio/Exn/Backend/index.html +++ b/eio/Eio/Exn/Backend/index.html @@ -1,2 +1,2 @@ -Backend (eio.Eio.Exn.Backend)

Module Exn.Backend

Extensible backend-specific exceptions.

type t = ..
val show : bool Stdlib.ref

Controls the behaviour of pp.

val register_pp : (Stdlib.Format.formatter -> t -> bool) -> unit

register_pp pp adds pp as a pretty-printer of backend errors.

pp f err should format err using f, if possible. It should return true on success, or false if it didn't recognise err.

val pp : t Fmt.t

pp behaves like pp except that if display of backend errors has been turned off (with show) then it just prints a place-holder.

This is useful for formatting the backend-specific part of exceptions, which should be hidden in expect-style testing that needs to work on multiple backends.

\ No newline at end of file +Backend (eio.Eio.Exn.Backend)

Module Exn.Backend

Extensible backend-specific exceptions.

type t = ..
val show : bool Stdlib.ref

Controls the behaviour of pp.

val register_pp : (Stdlib.Format.formatter -> t -> bool) -> unit

register_pp pp adds pp as a pretty-printer of backend errors.

pp f err should format err using f, if possible. It should return true on success, or false if it didn't recognise err.

val pp : t Fmt.t

pp behaves like pp except that if display of backend errors has been turned off (with show) then it just prints a place-holder.

This is useful for formatting the backend-specific part of exceptions, which should be hidden in expect-style testing that needs to work on multiple backends.

\ No newline at end of file diff --git a/eio/Eio/Exn/index.html b/eio/Eio/Exn/index.html index a89738db2..3041f0578 100644 --- a/eio/Eio/Exn/index.html +++ b/eio/Eio/Exn/index.html @@ -1,5 +1,5 @@ -Exn (eio.Eio.Exn)

Module Eio.Exn

Eio exceptions.

type with_bt = exn * Stdlib.Printexc.raw_backtrace
type err = ..

Describes the particular error that occurred.

They are typically nested (e.g. Fs (Permission_denied (Unix_error ...))) so that you can match e.g. all IO errors, all file-system errors, all permission denied errors, etc.

If you extend this, use register_pp to add a printer for the new error.

type context

Extra information attached to an IO error. This provides contextual information about what caused the error.

exception Io of err * context

A general purpose IO exception.

This is used for most errors interacting with the outside world, and is similar to Unix.Unix_error, but more general. An unknown Io error should typically be reported to the user, but does not generally indicate a bug in the program.

type err +=
  1. | Multiple_io of (err * context * Stdlib.Printexc.raw_backtrace) list
    (*

    Error code used when multiple IO errors occur.

    This is useful if you want to catch and report all IO errors.

    *)
val create : err -> exn

create err is an Io exception with an empty context.

val add_context : +Exn (eio.Eio.Exn)

Module Eio.Exn

Eio exceptions.

type with_bt = exn * Stdlib.Printexc.raw_backtrace
type err = ..

Describes the particular error that occurred.

They are typically nested (e.g. Fs (Permission_denied (Unix_error ...))) so that you can match e.g. all IO errors, all file-system errors, all permission denied errors, etc.

If you extend this, use register_pp to add a printer for the new error.

type context

Extra information attached to an IO error. This provides contextual information about what caused the error.

exception Io of err * context

A general purpose IO exception.

This is used for most errors interacting with the outside world, and is similar to Unix.Unix_error, but more general. An unknown Io error should typically be reported to the user, but does not generally indicate a bug in the program.

type err +=
  1. | Multiple_io of (err * context * Stdlib.Printexc.raw_backtrace) list
    (*

    Error code used when multiple IO errors occur.

    This is useful if you want to catch and report all IO errors.

    *)
val create : err -> exn

create err is an Io exception with an empty context.

val add_context : exn -> ('a, Stdlib.Format.formatter, unit, exn) Stdlib.format4 -> 'a

add_context ex msg returns a new exception with msg added to ex's context, if ex is an Io exception.

If ex is not an Io exception, this function just returns the original exception.

val reraise_with_context : diff --git a/eio/Eio/Fiber/List/index.html b/eio/Eio/Fiber/List/index.html index 3ee0b7563..52e2957b1 100644 --- a/eio/Eio/Fiber/List/index.html +++ b/eio/Eio/Fiber/List/index.html @@ -1,2 +1,2 @@ -List (eio.Eio.Fiber.List)

Module Fiber.List

Concurrent list operations.

These functions behave like the ones in the standard library's List module, except that multiple items can be processed concurrently.

They correspond to Lwt's Lwt_list.*_p operations. e.g. Lwt_list.iter_p becomes Fiber.List.iter. For the Lwt_list.*_s operations, just use the standard library function. e.g. Lwt_list.iter_s can be replaced by a plain List.iter.

val filter : ?max_fibers:int -> ('a -> bool) -> 'a list -> 'a list

filter f x is like List.filter f x except that the invocations of f are run concurrently in separate fibers.

  • parameter max_fibers

    Maximum number of fibers to run concurrently

val map : ?max_fibers:int -> ('a -> 'b) -> 'a list -> 'b list

map f x is like List.map f x except that the invocations of f are run concurrently in separate fibers.

  • parameter max_fibers

    Maximum number of fibers to run concurrently

val filter_map : ?max_fibers:int -> ('a -> 'b option) -> 'a list -> 'b list

filter_map f x is like List.filter_map f x except that the invocations of f are run concurrently in separate fibers.

  • parameter max_fibers

    Maximum number of fibers to run concurrently

val iter : ?max_fibers:int -> ('a -> unit) -> 'a list -> unit

iter f x is like List.iter f x except that the invocations of f are run concurrently in separate fibers.

  • parameter max_fibers

    Maximum number of fibers to run concurrently

\ No newline at end of file +List (eio.Eio.Fiber.List)

Module Fiber.List

Concurrent list operations.

These functions behave like the ones in the standard library's List module, except that multiple items can be processed concurrently.

They correspond to Lwt's Lwt_list.*_p operations. e.g. Lwt_list.iter_p becomes Fiber.List.iter. For the Lwt_list.*_s operations, just use the standard library function. e.g. Lwt_list.iter_s can be replaced by a plain List.iter.

val filter : ?max_fibers:int -> ('a -> bool) -> 'a list -> 'a list

filter f x is like List.filter f x except that the invocations of f are run concurrently in separate fibers.

  • parameter max_fibers

    Maximum number of fibers to run concurrently

val map : ?max_fibers:int -> ('a -> 'b) -> 'a list -> 'b list

map f x is like List.map f x except that the invocations of f are run concurrently in separate fibers.

  • parameter max_fibers

    Maximum number of fibers to run concurrently

val filter_map : ?max_fibers:int -> ('a -> 'b option) -> 'a list -> 'b list

filter_map f x is like List.filter_map f x except that the invocations of f are run concurrently in separate fibers.

  • parameter max_fibers

    Maximum number of fibers to run concurrently

val iter : ?max_fibers:int -> ('a -> unit) -> 'a list -> unit

iter f x is like List.iter f x except that the invocations of f are run concurrently in separate fibers.

  • parameter max_fibers

    Maximum number of fibers to run concurrently

\ No newline at end of file diff --git a/eio/Eio/Fiber/index.html b/eio/Eio/Fiber/index.html index ec0982057..4707401b9 100644 --- a/eio/Eio/Fiber/index.html +++ b/eio/Eio/Fiber/index.html @@ -1,9 +1,9 @@ -Fiber (eio.Eio.Fiber)

Module Eio.Fiber

A fiber is a light-weight thread.

Within a domain, only one fiber can be running at a time. A fiber runs until it performs an IO operation (directly or indirectly). At that point, it may be suspended and the next fiber on the run queue runs.

val both : (unit -> unit) -> (unit -> unit) -> unit

both f g runs f () and g () concurrently.

They run in a new cancellation sub-context, and if either raises an exception, the other is cancelled. both waits for both functions to finish even if one raises (it will then re-raise the original exception).

f runs immediately, without switching to any other thread. g is inserted at the head of the run-queue, so it runs next even if other threads are already enqueued. You can get other scheduling orders by adding calls to yield in various places. e.g. to append both fibers to the end of the run-queue, yield immediately before calling both.

If both fibers fail, Exn.combine is used to combine the exceptions.

val pair : (unit -> 'a) -> (unit -> 'b) -> 'a * 'b

pair f g is like both, but returns the two results.

val all : (unit -> unit) list -> unit

all fs is like both, but for any number of fibers. all [] returns immediately.

val first : (unit -> 'a) -> (unit -> 'a) -> 'a

first f g runs f () and g () concurrently.

They run in a new cancellation sub-context, and when one finishes the other is cancelled. If one raises, the other is cancelled and the exception is reported.

As with both, f runs immediately and g is scheduled next, ahead of any other queued work.

If both fibers fail, Exn.combine is used to combine the exceptions.

Warning: it is always possible that both operations will succeed (and one result will be thrown away). This is because there is a period of time after the first operation succeeds, but before its fiber finishes, during which the other operation may also succeed.

val any : (unit -> 'a) list -> 'a

any fs is like first, but for any number of fibers.

any [] just waits forever (or until cancelled).

val await_cancel : unit -> 'a

await_cancel () waits until cancelled.

  • raises Cancel.Cancelled
val fork : sw:Switch.t -> (unit -> unit) -> unit

fork ~sw fn runs fn () in a new fiber, but does not wait for it to complete.

The new fiber is attached to sw (which can't finish until the fiber ends).

The new fiber inherits sw's cancellation context. If the fiber raises an exception, Switch.fail sw is called. If sw is already off then fn fails immediately, but the calling thread continues.

fn runs immediately, without switching to any other fiber first. The calling fiber is placed at the head of the run queue, ahead of any previous items.

val fork_promise : sw:Switch.t -> (unit -> 'a) -> 'a Promise.or_exn

fork_promise ~sw fn schedules fn () to run in a new fiber and returns a promise for its result.

This is just a convenience wrapper around fork. If fn raises an exception then the promise is resolved to the error, but sw is not failed.

val fork_seq : sw:Switch.t -> (('a -> unit) -> unit) -> 'a Stdlib.Seq.t

fork_seq ~sw fn creates (but does not start) a new fiber to run fn yield.

Requesting the next item from the returned sequence resumes the fiber until it calls yield x, using x value as the next item in the sequence. If fn returns without producing a value then the result is Seq.Nil (end-of-sequence).

The returned sequence can be consumed safely from another domain. fn itself always runs in the domain that called fork_seq.

Example:

Switch.run @@ fun sw ->
+Fiber (eio.Eio.Fiber)

Module Eio.Fiber

A fiber is a light-weight thread.

Within a domain, only one fiber can be running at a time. A fiber runs until it performs an IO operation (directly or indirectly). At that point, it may be suspended and the next fiber on the run queue runs.

val both : (unit -> unit) -> (unit -> unit) -> unit

both f g runs f () and g () concurrently.

They run in a new cancellation sub-context, and if either raises an exception, the other is cancelled. both waits for both functions to finish even if one raises (it will then re-raise the original exception).

f runs immediately, without switching to any other thread. g is inserted at the head of the run-queue, so it runs next even if other threads are already enqueued. You can get other scheduling orders by adding calls to yield in various places. e.g. to append both fibers to the end of the run-queue, yield immediately before calling both.

If both fibers fail, Exn.combine is used to combine the exceptions.

val pair : (unit -> 'a) -> (unit -> 'b) -> 'a * 'b

pair f g is like both, but returns the two results.

val all : (unit -> unit) list -> unit

all fs is like both, but for any number of fibers. all [] returns immediately.

val first : (unit -> 'a) -> (unit -> 'a) -> 'a

first f g runs f () and g () concurrently.

They run in a new cancellation sub-context, and when one finishes the other is cancelled. If one raises, the other is cancelled and the exception is reported.

As with both, f runs immediately and g is scheduled next, ahead of any other queued work.

If both fibers fail, Exn.combine is used to combine the exceptions.

Warning: it is always possible that both operations will succeed (and one result will be thrown away). This is because there is a period of time after the first operation succeeds, but before its fiber finishes, during which the other operation may also succeed.

val any : (unit -> 'a) list -> 'a

any fs is like first, but for any number of fibers.

any [] just waits forever (or until cancelled).

val await_cancel : unit -> 'a

await_cancel () waits until cancelled.

  • raises Cancel.Cancelled
val fork : sw:Switch.t -> (unit -> unit) -> unit

fork ~sw fn runs fn () in a new fiber, but does not wait for it to complete.

The new fiber is attached to sw (which can't finish until the fiber ends).

The new fiber inherits sw's cancellation context. If the fiber raises an exception, Switch.fail sw is called. If sw is already off then fn fails immediately, but the calling thread continues.

fn runs immediately, without switching to any other fiber first. The calling fiber is placed at the head of the run queue, ahead of any previous items.

val fork_promise : sw:Switch.t -> (unit -> 'a) -> 'a Promise.or_exn

fork_promise ~sw fn schedules fn () to run in a new fiber and returns a promise for its result.

This is just a convenience wrapper around fork. If fn raises an exception then the promise is resolved to the error, but sw is not failed.

val fork_seq : sw:Switch.t -> (('a -> unit) -> unit) -> 'a Stdlib.Seq.t

fork_seq ~sw fn creates (but does not start) a new fiber to run fn yield.

Requesting the next item from the returned sequence resumes the fiber until it calls yield x, using x value as the next item in the sequence. If fn returns without producing a value then the result is Seq.Nil (end-of-sequence).

The returned sequence can be consumed safely from another domain. fn itself always runs in the domain that called fork_seq.

Example:

Switch.run @@ fun sw ->
 let seq = Fiber.fork_seq ~sw (fun yield ->
     for i = 1 to 3 do
       traceln "Yielding %d" i;
       yield i
     done
   ) in
-Seq.iter (traceln "Got: %d") seq

If fn raises an exception then the consumer receives it. If the consumer cancels while awaiting a value, the producer is cancelled when it next calls yield. It is an error to request two items at once, or to request items out of sequence.

  • parameter sw

    When the switch finishes, the fiber is cancelled (if still running). Attempting to read from the sequence after this raises an exception.

val fork_daemon : sw:Switch.t -> (unit -> [ `Stop_daemon ]) -> unit

fork_daemon is like fork except that instead of waiting for the fiber to finish, the switch will cancel it once all non-daemon fibers are done.

The switch will still wait for the daemon fiber to finish cancelling.

The return type of [`Stop_daemon] instead of unit is just to catch mistakes, as daemons normally aren't expected to return.

val check : unit -> unit

check () checks that the fiber's context hasn't been cancelled. Many operations automatically check this before starting.

  • raises Cancel.Cancelled

    if the fiber's context has been cancelled.

val yield : unit -> unit

yield () asks the scheduler to switch to the next runnable task. The current task remains runnable, but goes to the back of the queue. Automatically calls check just before resuming.

module List : sig ... end

Concurrent list operations.

Fiber-local variables

Each fiber maintains a map of additional variables associated with it, which can be used to store fiber-related state or context. This map is propagated to any forked fibers.

While fiber-local variables can be useful, they can also make code much harder to reason about, as they effectively act as another form of global state. When possible, prefer passing arguments around explicitly.

Fiber-local variables are particularly useful for attaching extra information for debugging, such as a request ID that the log system can include in all logged messages.

type 'a key

'a key is a fiber-local variable of type 'a.

Since the key is required to get or set a variable, a library can keep its key private to control how the variable can be accessed.

val create_key : unit -> 'a key

create_key () creates a new fiber-local variable.

val get : 'a key -> 'a option

get key reads key from the map of fiber local variables, returning its value or None if it has not been bound.

val with_binding : 'a key -> 'a -> (unit -> 'b) -> 'b

with_binding key value fn runs fn with key bound to the provided value.

Whilst this binding only exists for the duration of this function on this fiber, it will be propagated to any forked fibers. If fn creates fibers using an external switch, the bound value may be continue to be used after this function returns.

val without_binding : 'a key -> (unit -> 'b) -> 'b

with_binding key value fn runs fn with any binding for key removed.

\ No newline at end of file +Seq.iter (traceln "Got: %d") seq

If fn raises an exception then the consumer receives it. If the consumer cancels while awaiting a value, the producer is cancelled when it next calls yield. It is an error to request two items at once, or to request items out of sequence.

  • parameter sw

    When the switch finishes, the fiber is cancelled (if still running). Attempting to read from the sequence after this raises an exception.

val fork_daemon : sw:Switch.t -> (unit -> [ `Stop_daemon ]) -> unit

fork_daemon is like fork except that instead of waiting for the fiber to finish, the switch will cancel it once all non-daemon fibers are done.

The switch will still wait for the daemon fiber to finish cancelling.

The return type of [`Stop_daemon] instead of unit is just to catch mistakes, as daemons normally aren't expected to return.

val check : unit -> unit

check () checks that the fiber's context hasn't been cancelled. Many operations automatically check this before starting.

  • raises Cancel.Cancelled

    if the fiber's context has been cancelled.

val is_cancelled : unit -> bool

is_cancelled () is true iff check would raise an exception.

val yield : unit -> unit

yield () asks the scheduler to switch to the next runnable task. The current task remains runnable, but goes to the back of the queue. Automatically calls check just before resuming.

module List : sig ... end

Concurrent list operations.

Fiber-local variables

Each fiber maintains a map of additional variables associated with it, which can be used to store fiber-related state or context. This map is propagated to any forked fibers.

While fiber-local variables can be useful, they can also make code much harder to reason about, as they effectively act as another form of global state. When possible, prefer passing arguments around explicitly.

Fiber-local variables are particularly useful for attaching extra information for debugging, such as a request ID that the log system can include in all logged messages.

type 'a key

'a key is a fiber-local variable of type 'a.

Since the key is required to get or set a variable, a library can keep its key private to control how the variable can be accessed.

val create_key : unit -> 'a key

create_key () creates a new fiber-local variable.

val get : 'a key -> 'a option

get key reads key from the map of fiber local variables, returning its value or None if it has not been bound.

val with_binding : 'a key -> 'a -> (unit -> 'b) -> 'b

with_binding key value fn runs fn with key bound to the provided value.

Whilst this binding only exists for the duration of this function on this fiber, it will be propagated to any forked fibers. If fn creates fibers using an external switch, the bound value may be continue to be used after this function returns.

val without_binding : 'a key -> (unit -> 'b) -> 'b

with_binding key value fn runs fn with any binding for key removed.

\ No newline at end of file diff --git a/eio/Eio/File/Pi/index.html b/eio/Eio/File/Pi/index.html new file mode 100644 index 000000000..e5cd87b1d --- /dev/null +++ b/eio/Eio/File/Pi/index.html @@ -0,0 +1,2 @@ + +Pi (eio.Eio.File.Pi)

Module File.Pi

module type READ = sig ... end
module type WRITE = sig ... end
type Resource.pi +=
  1. | Read : ('t, (module READ with type t = 't), [> ro_ty ]) Resource.pi
  2. | Write : ('t, (module WRITE with type t = 't), [> rw_ty ]) Resource.pi
val ro : (module READ with type t = 't) -> ('t, ro_ty) Resource.handler
val rw : (module WRITE with type t = 't) -> ('t, rw_ty) Resource.handler
\ No newline at end of file diff --git a/eio/Eio/File/Pi/module-type-READ/index.html b/eio/Eio/File/Pi/module-type-READ/index.html new file mode 100644 index 000000000..34c6445d5 --- /dev/null +++ b/eio/Eio/File/Pi/module-type-READ/index.html @@ -0,0 +1,2 @@ + +READ (eio.Eio.File.Pi.READ)

Module type Pi.READ

include Flow.Pi.SOURCE
type t
val read_methods : t Flow.read_method list
val single_read : t -> Cstruct.t -> int
val pread : t -> file_offset:Optint.Int63.t -> Cstruct.t list -> int
val stat : t -> Stat.t
val close : t -> unit
\ No newline at end of file diff --git a/eio/Eio/File/Pi/module-type-WRITE/index.html b/eio/Eio/File/Pi/module-type-WRITE/index.html new file mode 100644 index 000000000..406d6fa00 --- /dev/null +++ b/eio/Eio/File/Pi/module-type-WRITE/index.html @@ -0,0 +1,2 @@ + +WRITE (eio.Eio.File.Pi.WRITE)

Module type Pi.WRITE

include Flow.Pi.SINK
type t
val single_write : t -> Cstruct.t list -> int
val copy : t -> src:_ Flow.source -> unit

copy t ~src allows for optimising copy operations.

If you have no optimisations, you can use simple_copy to implement this using single_write.

include READ with type t := t
include Flow.Pi.SOURCE with type t := t
val read_methods : t Flow.read_method list
val single_read : t -> Cstruct.t -> int
val pread : t -> file_offset:Optint.Int63.t -> Cstruct.t list -> int
val stat : t -> Stat.t
val close : t -> unit
val pwrite : t -> file_offset:Optint.Int63.t -> Cstruct.t list -> int
\ No newline at end of file diff --git a/eio/Eio/File/Stat/index.html b/eio/Eio/File/Stat/index.html index 979c93ffc..9b20e7f26 100644 --- a/eio/Eio/File/Stat/index.html +++ b/eio/Eio/File/Stat/index.html @@ -1,2 +1,2 @@ -Stat (eio.Eio.File.Stat)

Module File.Stat

Portable file stats.

type kind = [
  1. | `Unknown
  2. | `Fifo
  3. | `Character_special
  4. | `Directory
  5. | `Block_device
  6. | `Regular_file
  7. | `Socket
]

Kind of file from st_mode. *

type t = {
  1. dev : Stdlib.Int64.t;
  2. ino : Stdlib.Int64.t;
  3. kind : kind;
  4. perm : Unix_perm.t;
  5. uid : Stdlib.Int64.t;
  6. gid : Stdlib.Int64.t;
  7. rdev : Stdlib.Int64.t;
  8. size : Optint.Int63.t;
  9. atime : float;
  10. mtime : float;
  11. ctime : float;
}

Like stat(2).

\ No newline at end of file +Stat (eio.Eio.File.Stat)

Module File.Stat

Portable file stats.

type kind = [
  1. | `Unknown
  2. | `Fifo
  3. | `Character_special
  4. | `Directory
  5. | `Block_device
  6. | `Regular_file
  7. | `Socket
]

Kind of file from st_mode. *

type t = {
  1. dev : Stdlib.Int64.t;
  2. ino : Stdlib.Int64.t;
  3. kind : kind;
  4. perm : Unix_perm.t;
  5. uid : Stdlib.Int64.t;
  6. gid : Stdlib.Int64.t;
  7. rdev : Stdlib.Int64.t;
  8. size : Optint.Int63.t;
  9. atime : float;
  10. mtime : float;
  11. ctime : float;
}

Like stat(2).

\ No newline at end of file diff --git a/eio/Eio/File/Unix_perm/index.html b/eio/Eio/File/Unix_perm/index.html index 555204145..f0bf01615 100644 --- a/eio/Eio/File/Unix_perm/index.html +++ b/eio/Eio/File/Unix_perm/index.html @@ -1,2 +1,2 @@ -Unix_perm (eio.Eio.File.Unix_perm)

Module File.Unix_perm

Tranditional Unix permissions.

type t = int

This is the same as Unix.file_perm, but avoids a dependency on Unix.

\ No newline at end of file +Unix_perm (eio.Eio.File.Unix_perm)

Module File.Unix_perm

Tranditional Unix permissions.

type t = int

This is the same as Unix.file_perm, but avoids a dependency on Unix.

\ No newline at end of file diff --git a/eio/Eio/File/class-ro/index.html b/eio/Eio/File/class-ro/index.html deleted file mode 100644 index 39f150b14..000000000 --- a/eio/Eio/File/class-ro/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -ro (eio.Eio.File.ro)

Class File.ro

A file opened for reading.

method probe : ro -> 'a. 'a Eio__.Generic.ty -> 'a option
method read_methods : 'b -> Eio__.Flow.read_method list
method virtual pread : file_offset:Optint.Int63.t -> Cstruct.t list -> int
method virtual stat : Stat.t
\ No newline at end of file diff --git a/eio/Eio/File/class-rw/index.html b/eio/Eio/File/class-rw/index.html deleted file mode 100644 index 8b377d9f4..000000000 --- a/eio/Eio/File/class-rw/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -rw (eio.Eio.File.rw)

Class File.rw

A file opened for reading and writing.

inherit ro
method virtual pwrite : file_offset:Optint.Int63.t -> Cstruct.t list -> int
\ No newline at end of file diff --git a/eio/Eio/File/index.html b/eio/Eio/File/index.html index c8274a9dd..c6961b86c 100644 --- a/eio/Eio/File/index.html +++ b/eio/Eio/File/index.html @@ -1,2 +1,2 @@ -File (eio.Eio.File)

Module Eio.File

Operations on open files.

module Unix_perm : sig ... end

Tranditional Unix permissions.

module Stat : sig ... end

Portable file stats.

class virtual ro : object ... end

A file opened for reading.

class virtual rw : object ... end

A file opened for reading and writing.

val stat : ro -> Stat.t

stat t returns the Stat.t record associated with t.

val size : ro -> Optint.Int63.t

size t returns the size of t.

val pread : ro -> file_offset:Optint.Int63.t -> Cstruct.t list -> int

pread t ~file_offset bufs performs a single read of t at file_offset into bufs.

It returns the number of bytes read, which may be less than the space in bufs, even if more bytes are available. Use pread_exact instead if you require the buffer to be filled.

To read at the current offset, use Flow.single_read instead.

val pread_exact : ro -> file_offset:Optint.Int63.t -> Cstruct.t list -> unit

pread_exact t ~file_offset bufs reads from t into bufs until bufs is full.

  • raises End_of_file

    if the buffer could not be filled.

val pwrite_single : rw -> file_offset:Optint.Int63.t -> Cstruct.t list -> int

pwrite_single t ~file_offset bufs performs a single write operation, writing data from bufs to location file_offset in t.

It returns the number of bytes written, which may be less than the length of bufs. In most cases, you will want to use pwrite_all instead.

val pwrite_all : rw -> file_offset:Optint.Int63.t -> Cstruct.t list -> unit

pwrite_all t ~file_offset bufs writes all the data in bufs to location file_offset in t.

\ No newline at end of file +File (eio.Eio.File)

Module Eio.File

Operations on open files.

module Unix_perm : sig ... end

Tranditional Unix permissions.

module Stat : sig ... end

Portable file stats.

type ro_ty = [
  1. | `File
  2. | Flow.source_ty
  3. | Resource.close_ty
]
type 'a ro = [> ro_ty ] as 'a Std.r

A file opened for reading.

type rw_ty = [
  1. | ro_ty
  2. | Flow.sink_ty
]
type 'a rw = [> rw_ty ] as 'a Std.r

A file opened for reading and writing.

module Pi : sig ... end
val stat : _ ro -> Stat.t

stat t returns the Stat.t record associated with t.

val size : _ ro -> Optint.Int63.t

size t returns the size of t.

val pread : _ ro -> file_offset:Optint.Int63.t -> Cstruct.t list -> int

pread t ~file_offset bufs performs a single read of t at file_offset into bufs.

It returns the number of bytes read, which may be less than the space in bufs, even if more bytes are available. Use pread_exact instead if you require the buffer to be filled.

To read at the current offset, use Flow.single_read instead.

val pread_exact : _ ro -> file_offset:Optint.Int63.t -> Cstruct.t list -> unit

pread_exact t ~file_offset bufs reads from t into bufs until bufs is full.

  • raises End_of_file

    if the buffer could not be filled.

val pwrite_single : _ rw -> file_offset:Optint.Int63.t -> Cstruct.t list -> int

pwrite_single t ~file_offset bufs performs a single write operation, writing data from bufs to location file_offset in t.

It returns the number of bytes written, which may be less than the length of bufs. In most cases, you will want to use pwrite_all instead.

val pwrite_all : _ rw -> file_offset:Optint.Int63.t -> Cstruct.t list -> unit

pwrite_all t ~file_offset bufs writes all the data in bufs to location file_offset in t.

\ No newline at end of file diff --git a/eio/Eio/Flow/Pi/index.html b/eio/Eio/Flow/Pi/index.html new file mode 100644 index 000000000..164003273 --- /dev/null +++ b/eio/Eio/Flow/Pi/index.html @@ -0,0 +1,13 @@ + +Pi (eio.Eio.Flow.Pi)

Module Flow.Pi

module type SOURCE = sig ... end
module type SINK = sig ... end
module type SHUTDOWN = sig ... end
val source : + (module SOURCE with type t = 't) -> + ('t, source_ty) Resource.handler
val sink : (module SINK with type t = 't) -> ('t, sink_ty) Resource.handler
val shutdown : + (module SHUTDOWN with type t = 't) -> + ('t, shutdown_ty) Resource.handler
module type TWO_WAY = sig ... end
val two_way : + (module TWO_WAY with type t = 't) -> + ('t, two_way_ty) Resource.handler
type Resource.pi +=
  1. | Source : ('t, (module SOURCE with type t = 't), [> source_ty ]) Resource.pi
  2. | Sink : ('t, (module SINK with type t = 't), [> sink_ty ]) Resource.pi
  3. | Shutdown : ('t, (module SHUTDOWN with type t = 't), [> shutdown_ty ]) + Resource.pi
val simple_copy : + single_write:('t -> Cstruct.t list -> int) -> + 't -> + src:_ source -> + unit

simple_copy ~single_write implements SINK's copy API using single_write.

\ No newline at end of file diff --git a/eio/Eio/Flow/Pi/module-type-SHUTDOWN/index.html b/eio/Eio/Flow/Pi/module-type-SHUTDOWN/index.html new file mode 100644 index 000000000..811fd8e42 --- /dev/null +++ b/eio/Eio/Flow/Pi/module-type-SHUTDOWN/index.html @@ -0,0 +1,2 @@ + +SHUTDOWN (eio.Eio.Flow.Pi.SHUTDOWN)

Module type Pi.SHUTDOWN

type t
val shutdown : t -> shutdown_command -> unit
\ No newline at end of file diff --git a/eio/Eio/Flow/Pi/module-type-SINK/index.html b/eio/Eio/Flow/Pi/module-type-SINK/index.html new file mode 100644 index 000000000..b548430e7 --- /dev/null +++ b/eio/Eio/Flow/Pi/module-type-SINK/index.html @@ -0,0 +1,2 @@ + +SINK (eio.Eio.Flow.Pi.SINK)

Module type Pi.SINK

type t
val single_write : t -> Cstruct.t list -> int
val copy : t -> src:_ source -> unit

copy t ~src allows for optimising copy operations.

If you have no optimisations, you can use simple_copy to implement this using single_write.

\ No newline at end of file diff --git a/eio/Eio/Flow/Pi/module-type-SOURCE/index.html b/eio/Eio/Flow/Pi/module-type-SOURCE/index.html new file mode 100644 index 000000000..ede0f4024 --- /dev/null +++ b/eio/Eio/Flow/Pi/module-type-SOURCE/index.html @@ -0,0 +1,2 @@ + +SOURCE (eio.Eio.Flow.Pi.SOURCE)

Module type Pi.SOURCE

type t
val read_methods : t read_method list
val single_read : t -> Cstruct.t -> int
\ No newline at end of file diff --git a/eio/Eio/Flow/Pi/module-type-TWO_WAY/index.html b/eio/Eio/Flow/Pi/module-type-TWO_WAY/index.html new file mode 100644 index 000000000..947198161 --- /dev/null +++ b/eio/Eio/Flow/Pi/module-type-TWO_WAY/index.html @@ -0,0 +1,2 @@ + +TWO_WAY (eio.Eio.Flow.Pi.TWO_WAY)

Module type Pi.TWO_WAY

include SHUTDOWN
type t
val shutdown : t -> shutdown_command -> unit
include SOURCE with type t := t
val read_methods : t read_method list
val single_read : t -> Cstruct.t -> int
include SINK with type t := t
val single_write : t -> Cstruct.t list -> int
val copy : t -> src:_ source -> unit

copy t ~src allows for optimising copy operations.

If you have no optimisations, you can use simple_copy to implement this using single_write.

\ No newline at end of file diff --git a/eio/Eio/Flow/class-sink/index.html b/eio/Eio/Flow/class-sink/index.html deleted file mode 100644 index c06f8a73c..000000000 --- a/eio/Eio/Flow/class-sink/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -sink (eio.Eio.Flow.sink)

Class Flow.sink

Consumer base class.

inherit Eio__.Generic.t
method virtual copy : 'a. source as 'a -> unit
method write : Cstruct.t list -> unit

The default implementation is copy (cstruct_source ...), but it can be overridden for speed.

\ No newline at end of file diff --git a/eio/Eio/Flow/class-source/index.html b/eio/Eio/Flow/class-source/index.html deleted file mode 100644 index 21f82202b..000000000 --- a/eio/Eio/Flow/class-source/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -source (eio.Eio.Flow.source)

Class Flow.source

inherit Eio__.Generic.t
method read_methods : read_method list
method virtual read_into : Cstruct.t -> int
\ No newline at end of file diff --git a/eio/Eio/Flow/class-two_way/index.html b/eio/Eio/Flow/class-two_way/index.html deleted file mode 100644 index 3ac2b314b..000000000 --- a/eio/Eio/Flow/class-two_way/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -two_way (eio.Eio.Flow.two_way)

Class Flow.two_way

inherit source
inherit sink
method virtual shutdown : shutdown_command -> unit
\ No newline at end of file diff --git a/eio/Eio/Flow/class-type-close/index.html b/eio/Eio/Flow/class-type-close/index.html deleted file mode 100644 index 7cd719a97..000000000 --- a/eio/Eio/Flow/class-type-close/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -close (eio.Eio.Flow.close)

Class type Flow.close

method close : unit
\ No newline at end of file diff --git a/eio/Eio/Flow/index.html b/eio/Eio/Flow/index.html index 3f32f8657..eb32d1e81 100644 --- a/eio/Eio/Flow/index.html +++ b/eio/Eio/Flow/index.html @@ -1,2 +1,2 @@ -Flow (eio.Eio.Flow)

Module Eio.Flow

Byte streams.

Flows are used to represent byte streams, such as open files and network sockets. A source provides a stream of bytes. A sink consumes a stream. A two_way can do both.

To read structured data (e.g. a line at a time), wrap a source using Buf_read.

Reading

type read_method = ..

Sources can offer a list of ways to read them, in order of preference.

class virtual source : object ... end
val single_read : source -> Cstruct.t -> int

single_read src buf reads one or more bytes into buf.

It returns the number of bytes read (which may be less than the buffer size even if there is more data to be read). single_read src just makes a single call to src#read_into (and asserts that the result is in range).

  • Use read_exact instead if you want to fill buf completely.
  • Use Buf_read.line to read complete lines.
  • Use copy to stream data directly from a source to a sink.

buf must not be zero-length.

  • raises End_of_file

    if there is no more data to read

val read_exact : source -> Cstruct.t -> unit

read_exact src dst keeps reading into dst until it is full.

  • raises End_of_file

    if the buffer could not be filled.

val read_methods : source -> read_method list

read_methods flow is a list of extra ways of reading from flow, with the preferred (most efficient) methods first.

If no method is suitable, read should be used as the fallback.

val string_source : string -> source

string_source s is a source that gives the bytes of s.

val cstruct_source : Cstruct.t list -> source

cstruct_source cs is a source that gives the bytes of cs.

type read_method +=
  1. | Read_source_buffer of (Cstruct.t list -> int) -> unit
    (*

    If a source offers Read_source_buffer rsb then the user can call rsb fn to borrow a view of the source's buffers. fn returns the number of bytes it consumed.

    rsb will raise End_of_file if no more data will be produced. If no data is currently available, rsb will wait for some to become available before calling fn.

    fn must not continue to use the buffers after it returns.

    *)

Writing

class virtual sink : object ... end

Consumer base class.

val write : sink -> Cstruct.t list -> unit

write dst bufs writes all bytes from bufs.

You should not perform multiple concurrent writes on the same flow (the output may get interleaved).

This is a low level API. Consider using:

  • Buf_write to combine multiple small writes.
  • copy for bulk transfers, as it allows some extra optimizations.
val copy : source -> sink -> unit

copy src dst copies data from src to dst until end-of-file.

val copy_string : string -> sink -> unit

copy_string s = copy (string_source s)

val buffer_sink : Stdlib.Buffer.t -> sink

buffer_sink b is a sink that adds anything sent to it to b.

To collect data as a cstruct, use Buf_read instead.

Bidirectional streams

type shutdown_command = [
  1. | `Receive
    (*

    Indicate that no more reads will be done

    *)
  2. | `Send
    (*

    Indicate that no more writes will be done

    *)
  3. | `All
    (*

    Indicate that no more reads or writes will be done

    *)
]
class virtual two_way : object ... end
val shutdown : two_way -> shutdown_command -> unit

shutdown t cmd indicates that the caller has finished reading or writing t (depending on cmd).

This is useful in some protocols to indicate that you have finished sending the request, and that the remote peer should now send the response.

Closing

Flows are usually attached to switches and closed automatically when the switch finishes. However, it can be useful to close them sooner manually in some cases.

class type close = Eio__.Generic.close
val close : close -> unit

Alias of Generic.close.

\ No newline at end of file +Flow (eio.Eio.Flow)

Module Eio.Flow

Byte streams.

Flows are used to represent byte streams, such as open files and network sockets. A source provides a stream of bytes. A sink consumes a stream. A two_way can do both.

To read structured data (e.g. a line at a time), wrap a source using Buf_read.

Types

type source_ty = [
  1. | `R
  2. | `Flow
]
type 'a source = [> source_ty ] as 'a Std.r

A readable flow provides a stream of bytes.

type sink_ty = [
  1. | `W
  2. | `Flow
]
type 'a sink = [> sink_ty ] as 'a Std.r

A writeable flow accepts a stream of bytes.

type shutdown_ty = [
  1. | `Shutdown
]
type 'a shutdown = [> shutdown_ty ] as 'a Std.r
type 'a read_method = ..

Sources can offer a list of ways to read them, in order of preference.

type shutdown_command = [
  1. | `Receive
    (*

    Indicate that no more reads will be done

    *)
  2. | `Send
    (*

    Indicate that no more writes will be done

    *)
  3. | `All
    (*

    Indicate that no more reads or writes will be done

    *)
]

Reading

val single_read : _ source -> Cstruct.t -> int

single_read src buf reads one or more bytes into buf.

It returns the number of bytes read (which may be less than the buffer size even if there is more data to be read).

  • Use read_exact instead if you want to fill buf completely.
  • Use Buf_read.line to read complete lines.
  • Use copy to stream data directly from a source to a sink.

buf must not be zero-length.

  • raises End_of_file

    if there is no more data to read

val read_exact : _ source -> Cstruct.t -> unit

read_exact src dst keeps reading into dst until it is full.

  • raises End_of_file

    if the buffer could not be filled.

val string_source : string -> source_ty Std.r

string_source s is a source that gives the bytes of s.

val cstruct_source : Cstruct.t list -> source_ty Std.r

cstruct_source cs is a source that gives the bytes of cs.

type read_method +=
  1. | Read_source_buffer of 't -> (Cstruct.t list -> int) -> unit
    (*

    If a source offers Read_source_buffer rsb then the user can call rsb t fn to borrow a view of the source's buffers. fn returns the number of bytes it consumed.

    rsb will raise End_of_file if no more data will be produced. If no data is currently available, rsb will wait for some to become available before calling fn.

    fn must not continue to use the buffers after it returns.

    *)

Writing

val write : _ sink -> Cstruct.t list -> unit

write dst bufs writes all bytes from bufs.

You should not perform multiple concurrent writes on the same flow (the output may get interleaved).

This is a low level API. Consider using:

  • Buf_write to combine multiple small writes.
  • copy for bulk transfers, as it allows some extra optimizations.
val single_write : _ sink -> Cstruct.t list -> int

single_write dst bufs writes at least one byte from bufs and returns the number of bytes written.

val copy : _ source -> _ sink -> unit

copy src dst copies data from src to dst until end-of-file.

val copy_string : string -> _ sink -> unit

copy_string s = copy (string_source s)

val buffer_sink : Stdlib.Buffer.t -> sink_ty Std.r

buffer_sink b is a sink that adds anything sent to it to b.

To collect data as a cstruct, use Buf_read instead.

Bidirectional streams

type two_way_ty = [
  1. | source_ty
  2. | sink_ty
  3. | shutdown_ty
]
type 'a two_way = [> two_way_ty ] as 'a Std.r
val shutdown : _ two_way -> shutdown_command -> unit

shutdown t cmd indicates that the caller has finished reading or writing t (depending on cmd).

This is useful in some protocols to indicate that you have finished sending the request, and that the remote peer should now send the response.

Closing

Flows are usually attached to switches and closed automatically when the switch finishes. However, it can be useful to close them sooner manually in some cases.

val close : [> `Close ] Std.r -> unit

Alias of Resource.close.

Provider Interface

module Pi : sig ... end
\ No newline at end of file diff --git a/eio/Eio/Fs/Pi/index.html b/eio/Eio/Fs/Pi/index.html new file mode 100644 index 000000000..5ec9c02f4 --- /dev/null +++ b/eio/Eio/Fs/Pi/index.html @@ -0,0 +1,2 @@ + +Pi (eio.Eio.Fs.Pi)

Module Fs.Pi

Note: use the functions in Path to access directories.

module type DIR = sig ... end
type Resource.pi +=
  1. | Dir : ('t, (module DIR with type t = 't), [> dir_ty ]) Resource.pi
\ No newline at end of file diff --git a/eio/Eio/Fs/Pi/module-type-DIR/index.html b/eio/Eio/Fs/Pi/module-type-DIR/index.html new file mode 100644 index 000000000..d43b9ffed --- /dev/null +++ b/eio/Eio/Fs/Pi/module-type-DIR/index.html @@ -0,0 +1,8 @@ + +DIR (eio.Eio.Fs.Pi.DIR)

Module type Pi.DIR

type t
val open_in : t -> sw:Switch.t -> path -> File.ro_ty Std.r
val open_out : + t -> + sw:Switch.t -> + append:bool -> + create:create -> + path -> + File.rw_ty Std.r
val mkdir : t -> perm:File.Unix_perm.t -> path -> unit
val open_dir : t -> sw:Switch.t -> path -> [ `Close | dir_ty ] Std.r
val read_dir : t -> path -> string list
val rmdir : t -> path -> unit
val rename : t -> path -> _ dir -> path -> unit
val pp : t Fmt.t
val native : t -> string -> string option
\ No newline at end of file diff --git a/eio/Eio/Fs/class-dir/index.html b/eio/Eio/Fs/class-dir/index.html deleted file mode 100644 index 596f4e2bc..000000000 --- a/eio/Eio/Fs/class-dir/index.html +++ /dev/null @@ -1,21 +0,0 @@ - -dir (eio.Eio.Fs.dir)

Class Fs.dir

Note: use the functions in Path to access directories.

method probe : dir -> 'a. 'a Eio__.Generic.ty -> 'a option
method virtual open_in : sw:Eio__core.Switch.t -> - path -> - < close : unit - ; pread : file_offset:Optint.Int63.t -> Cstruct.t list -> int - ; probe : 'a. 'a Eio__.Generic.ty -> 'a option - ; read_into : Cstruct.t -> int - ; read_methods : Eio__.Flow.read_method list - ; stat : Eio__.File.Stat.t >
method virtual open_out : sw:Eio__core.Switch.t -> - append:bool -> - create:create -> - path -> - < close : unit - ; copy : 'b. Eio__.Flow.source as 'c -> unit - ; pread : file_offset:Optint.Int63.t -> Cstruct.t list -> int - ; probe : 'a. 'a Eio__.Generic.ty -> 'a option - ; pwrite : file_offset:Optint.Int63.t -> Cstruct.t list -> int - ; read_into : Cstruct.t -> int - ; read_methods : Eio__.Flow.read_method list - ; stat : Eio__.File.Stat.t - ; write : Cstruct.t list -> unit >
method virtual mkdir : perm:Eio__.File.Unix_perm.t -> path -> unit
method virtual open_dir : sw:Eio__core.Switch.t -> path -> dir_with_close
method virtual read_dir : path -> string list
method virtual rmdir : path -> unit
method virtual rename : path -> dir -> path -> unit
method virtual pp : Stdlib.Format.formatter -> unit
\ No newline at end of file diff --git a/eio/Eio/Fs/class-dir_with_close/index.html b/eio/Eio/Fs/class-dir_with_close/index.html deleted file mode 100644 index 917867a92..000000000 --- a/eio/Eio/Fs/class-dir_with_close/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -dir_with_close (eio.Eio.Fs.dir_with_close)

Class Fs.dir_with_close

inherit dir
\ No newline at end of file diff --git a/eio/Eio/Fs/index.html b/eio/Eio/Fs/index.html index 40b6c2617..bfe905908 100644 --- a/eio/Eio/Fs/index.html +++ b/eio/Eio/Fs/index.html @@ -1,2 +1,2 @@ -Fs (eio.Eio.Fs)

Module Eio.Fs

File-system types.

Defines types used by file-systems.

type path = string
type error =
  1. | Already_exists of Exn.Backend.t
  2. | Not_found of Exn.Backend.t
  3. | Permission_denied of Exn.Backend.t
  4. | File_too_large
type Exn.err +=
  1. | E of error
val err : error -> exn
type create = [
  1. | `Never
    (*

    fail if the named file doesn't exist

    *)
  2. | `If_missing of File.Unix_perm.t
    (*

    create if file doesn't already exist

    *)
  3. | `Or_truncate of File.Unix_perm.t
    (*

    any existing file is truncated to zero length

    *)
  4. | `Exclusive of File.Unix_perm.t
    (*

    always create; fail if the file already exists

    *)
]

When to create a new file.

If a new file is created, the given permissions are used for it.

class virtual dir : object ... end

Note: use the functions in Path to access directories.

class virtual dir_with_close : object ... end
\ No newline at end of file +Fs (eio.Eio.Fs)

Module Eio.Fs

File-system types.

Defines types used by file-systems.

type path = string
type error =
  1. | Already_exists of Exn.Backend.t
  2. | Not_found of Exn.Backend.t
  3. | Permission_denied of Exn.Backend.t
  4. | File_too_large
  5. | Not_native of string
    (*

    Raised by Path.native_exn.

    *)
type Exn.err +=
  1. | E of error
val err : error -> exn
type create = [
  1. | `Never
    (*

    fail if the named file doesn't exist

    *)
  2. | `If_missing of File.Unix_perm.t
    (*

    create if file doesn't already exist

    *)
  3. | `Or_truncate of File.Unix_perm.t
    (*

    any existing file is truncated to zero length

    *)
  4. | `Exclusive of File.Unix_perm.t
    (*

    always create; fail if the file already exists

    *)
]

When to create a new file.

If a new file is created, the given permissions are used for it.

type dir_ty = [
  1. | `Dir
]
type 'a dir = [> dir_ty ] as 'a Std.r
module Pi : sig ... end

Note: use the functions in Path to access directories.

\ No newline at end of file diff --git a/eio/Eio/Generic/class-type-close/index.html b/eio/Eio/Generic/class-type-close/index.html deleted file mode 100644 index 4a9ccf02f..000000000 --- a/eio/Eio/Generic/class-type-close/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -close (eio.Eio.Generic.close)

Class type Generic.close

method close : unit
\ No newline at end of file diff --git a/eio/Eio/Generic/class-type-t/index.html b/eio/Eio/Generic/class-type-t/index.html deleted file mode 100644 index aab0fe6f9..000000000 --- a/eio/Eio/Generic/class-type-t/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -t (eio.Eio.Generic.t)

Class type Generic.t

method probe : 'a. 'a ty -> 'a option
\ No newline at end of file diff --git a/eio/Eio/Generic/index.html b/eio/Eio/Generic/index.html deleted file mode 100644 index cb8ebd917..000000000 --- a/eio/Eio/Generic/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Generic (eio.Eio.Generic)

Module Eio.Generic

A base class for objects that can be queried at runtime for extra features.

type 'a ty = ..

An 'a ty is a query for a feature of type 'a.

class type t = object ... end
val probe : t -> 'a ty -> 'a option

probe t feature checks whether t supports feature. This is mostly for internal use. For example, Eio_unix.FD.peek_opt uses this to get the underlying Unix file descriptor from a flow.

Closing

Resources are usually attached to switches and closed automatically when the switch finishes. However, it can be useful to close them sooner in some cases.

class type close = object ... end
val close : close -> unit

close t marks the resource as closed. It can no longer be used after this.

If t is already closed then this does nothing (it does not raise an exception).

Note: if an operation is currently in progress when this is called then it is not necessarily cancelled, and any underlying OS resource (such as a file descriptor) might not be closed immediately if other operations are using it. Closing a resource only prevents new operations from starting.

\ No newline at end of file diff --git a/eio/Eio/Lazy/index.html b/eio/Eio/Lazy/index.html new file mode 100644 index 000000000..6ad4f54b2 --- /dev/null +++ b/eio/Eio/Lazy/index.html @@ -0,0 +1,2 @@ + +Lazy (eio.Eio.Lazy)

Module Eio.Lazy

Delayed evaluation.

This is like Stdlib.Lazy, but multiple fibers or domains can force at once.

type 'a t

A lazy value that produces a value of type 'a.

val from_fun : cancel:[ `Restart | `Record | `Protect ] -> (unit -> 'a) -> 'a t

from_fun ~cancel fn is a lazy value that runs fn () the first time it is forced.

cancel determines how cancellation is handled while forcing:

  • `Restart : if the forcing fiber is cancelled, the next waiting fiber runs fn again.
  • `Record : the failure is recorded and the lazy value will always report cancelled if used.
  • `Protect : the forcing fiber is protected from cancellation while running.
val from_val : 'a -> 'a t

from_val v is a lazy value that is already forced.

It is equivalent to from_fun (fun () -> v).

val force : 'a t -> 'a

force t returns the result of running the function passed to from_fun.

If the function is currently running, this waits for it to finish and then retries. If the function has already completed then it returns the saved result. If the function returned an exception then force re-raises it.

\ No newline at end of file diff --git a/eio/Eio/Mutex/index.html b/eio/Eio/Mutex/index.html index 17f52235b..266c375e7 100644 --- a/eio/Eio/Mutex/index.html +++ b/eio/Eio/Mutex/index.html @@ -1,2 +1,2 @@ -Mutex (eio.Eio.Mutex)

Module Eio.Mutex

Mutual exclusion.

A mutex can be used to ensure that only one piece of code can access a shared resource at one time.

Unlike Stdlib.Mutex, which blocks the whole domain while waiting to take the mutex, this module allows other Eio fibers to run while waiting. You should use this module if your critical section may perform blocking operations, while Stdlib.Mutex may be more efficient if the lock is held only briefly and the critial section does not switch fibers.

Note that mutexes are often unnecessary for code running in a single domain, as the scheduler will only switch to another fiber if you perform an operation that can block.

type t = Mutex.t

The type for a concurrency-friendly mutex.

exception Poisoned of exn

Raised if you attempt to use a mutex that has been disabled.

val create : unit -> t

create () creates an initially unlocked mutex.

val use_rw : protect:bool -> t -> (unit -> 'a) -> 'a

use_rw ~protect t fn waits for the mutex to be free and then executes fn () while holding the mutex locked. fn may mutate the resource protected by the mutex, but must ensure the resource is in a consistent state before returning. If fn raises an exception, the mutex is disabled and cannot be used again.

  • parameter protect

    If true, uses Cancel.protect to prevent the critical section from being cancelled. Cancellation is not prevented while waiting to take the lock.

val use_ro : t -> (unit -> 'a) -> 'a

use_ro t fn is like use_rw ~protect:false, but if fn raises an exception it unlocks the mutex instead of disabling it. Use this if you only need read-only access to the mutex's resource and so know that it will be in a consistent state even if an exception is raised.

Note: a mutex still only allows one fiber to have the mutex locked at a time, even if all operations are "read-only".

Low-level API

Care must be taken when locking a mutex manually. It is easy to forget to unlock it in some cases, which will result in deadlock the next time a fiber tries to use it. In particular, you need to consider:

  • What happens if your critical section raises an exception.
  • What happens if your fiber is cancelled while in its critical section.
val lock : t -> unit

Lock the given mutex. Only one fiber can have the mutex locked at any time. A fiber that attempts to lock a mutex already locked by another fiber will suspend until the other fiber unlocks the mutex. If no other fiber has the lock, this returns immediately without switching fibers.

val unlock : t -> unit

unlock t unlocks the mutex.

  • raises Sys_error

    if the mutex is unlocked.

val try_lock : t -> bool

Same as lock, but does not suspend the calling thread if the mutex is already locked: just return false immediately in that case. If the mutex is unlocked, lock it and return true.

\ No newline at end of file +Mutex (eio.Eio.Mutex)

Module Eio.Mutex

Mutual exclusion.

A mutex can be used to ensure that only one piece of code can access a shared resource at one time.

Unlike Stdlib.Mutex, which blocks the whole domain while waiting to take the mutex, this module allows other Eio fibers to run while waiting. You should use this module if your critical section may perform blocking operations, while Stdlib.Mutex may be more efficient if the lock is held only briefly and the critial section does not switch fibers.

Note that mutexes are often unnecessary for code running in a single domain, as the scheduler will only switch to another fiber if you perform an operation that can block.

type t = Mutex.t

The type for a concurrency-friendly mutex.

exception Poisoned of exn

Raised if you attempt to use a mutex that has been disabled.

val create : unit -> t

create () creates an initially unlocked mutex.

val use_rw : protect:bool -> t -> (unit -> 'a) -> 'a

use_rw ~protect t fn waits for the mutex to be free and then executes fn () while holding the mutex locked. fn may mutate the resource protected by the mutex, but must ensure the resource is in a consistent state before returning. If fn raises an exception, the mutex is disabled and cannot be used again.

  • parameter protect

    If true, uses Cancel.protect to prevent the critical section from being cancelled. Cancellation is not prevented while waiting to take the lock.

val use_ro : t -> (unit -> 'a) -> 'a

use_ro t fn is like use_rw ~protect:false, but if fn raises an exception it unlocks the mutex instead of disabling it. Use this if you only need read-only access to the mutex's resource and so know that it will be in a consistent state even if an exception is raised.

Note: a mutex still only allows one fiber to have the mutex locked at a time, even if all operations are "read-only".

Low-level API

Care must be taken when locking a mutex manually. It is easy to forget to unlock it in some cases, which will result in deadlock the next time a fiber tries to use it. In particular, you need to consider:

  • What happens if your critical section raises an exception.
  • What happens if your fiber is cancelled while in its critical section.
val lock : t -> unit

Lock the given mutex. Only one fiber can have the mutex locked at any time. A fiber that attempts to lock a mutex already locked by another fiber will suspend until the other fiber unlocks the mutex. If no other fiber has the lock, this returns immediately without switching fibers.

val unlock : t -> unit

unlock t unlocks the mutex.

  • raises Sys_error

    if the mutex is unlocked.

val try_lock : t -> bool

Same as lock, but does not suspend the calling thread if the mutex is already locked: just return false immediately in that case. If the mutex is unlocked, lock it and return true.

\ No newline at end of file diff --git a/eio/Eio/Net/Ipaddr/V4/index.html b/eio/Eio/Net/Ipaddr/V4/index.html index c1cc9b064..495e95025 100644 --- a/eio/Eio/Net/Ipaddr/V4/index.html +++ b/eio/Eio/Net/Ipaddr/V4/index.html @@ -1,2 +1,2 @@ -V4 (eio.Eio.Net.Ipaddr.V4)

Module Ipaddr.V4

IPv4 addresses.

val any : [> `V4 ] t

A special IPv4 address, for use only with listen, representing all the Internet addresses that the host machine possesses.

val loopback : [> `V4 ] t

A special IPv4 address representing the host machine (127.0.0.1).

\ No newline at end of file +V4 (eio.Eio.Net.Ipaddr.V4)

Module Ipaddr.V4

IPv4 addresses.

val any : [> `V4 ] t

A special IPv4 address, for use only with listen, representing all the Internet addresses that the host machine possesses.

val loopback : [> `V4 ] t

A special IPv4 address representing the host machine (127.0.0.1).

\ No newline at end of file diff --git a/eio/Eio/Net/Ipaddr/V6/index.html b/eio/Eio/Net/Ipaddr/V6/index.html index 64536766e..6651770ef 100644 --- a/eio/Eio/Net/Ipaddr/V6/index.html +++ b/eio/Eio/Net/Ipaddr/V6/index.html @@ -1,2 +1,2 @@ -V6 (eio.Eio.Net.Ipaddr.V6)

Module Ipaddr.V6

IPv6 addresses.

val any : [> `V6 ] t

A special IPv6 address, for use only with listen, representing all the Internet addresses that the host machine possesses.

val loopback : [> `V6 ] t

A special IPv6 address representing the host machine (::1).

\ No newline at end of file +V6 (eio.Eio.Net.Ipaddr.V6)

Module Ipaddr.V6

IPv6 addresses.

val any : [> `V6 ] t

A special IPv6 address, for use only with listen, representing all the Internet addresses that the host machine possesses.

val loopback : [> `V6 ] t

A special IPv6 address representing the host machine (::1).

\ No newline at end of file diff --git a/eio/Eio/Net/Ipaddr/index.html b/eio/Eio/Net/Ipaddr/index.html index e1fc44b47..ffddb4f06 100644 --- a/eio/Eio/Net/Ipaddr/index.html +++ b/eio/Eio/Net/Ipaddr/index.html @@ -1,5 +1,5 @@ -Ipaddr (eio.Eio.Net.Ipaddr)

Module Net.Ipaddr

IP addresses.

type 'a t = private string

The raw bytes of the IP address. It is either 4 bytes long (for an IPv4 address) or 16 bytes long (for IPv6).

module V4 : sig ... end

IPv4 addresses.

module V6 : sig ... end

IPv6 addresses.

val pp : [< `V4 | `V6 ] t Fmt.t

pp formats IP addresses. For IPv6 addresses, it follows http://tools.ietf.org/html/rfc5952.

type v4v6 = [ `V4 | `V6 ] t
val fold : +Ipaddr (eio.Eio.Net.Ipaddr)

Module Net.Ipaddr

IP addresses.

type 'a t = private string

The raw bytes of the IP address. It is either 4 bytes long (for an IPv4 address) or 16 bytes long (for IPv6).

module V4 : sig ... end

IPv4 addresses.

module V6 : sig ... end

IPv6 addresses.

val pp : [< `V4 | `V6 ] t Fmt.t

pp formats IP addresses. For IPv6 addresses, it follows http://tools.ietf.org/html/rfc5952.

type v4v6 = [ `V4 | `V6 ] t
val fold : v4:([> `V4 ] t -> 'a) -> v6:([> `V6 ] t -> 'a) -> [< `V4 | `V6 ] t -> diff --git a/eio/Eio/Net/Pi/index.html b/eio/Eio/Net/Pi/index.html new file mode 100644 index 000000000..37ff962a9 --- /dev/null +++ b/eio/Eio/Net/Pi/index.html @@ -0,0 +1,10 @@ + +Pi (eio.Eio.Net.Pi)

Module Net.Pi

module type STREAM_SOCKET = sig ... end
val stream_socket : + (module STREAM_SOCKET with type t = 't and type tag = 'tag) -> + ('t, 'tag stream_socket_ty) Resource.handler
module type DATAGRAM_SOCKET = sig ... end
val datagram_socket : + (module DATAGRAM_SOCKET with type t = 't and type tag = 'tag) -> + ('t, 'tag datagram_socket_ty) Resource.handler
module type LISTENING_SOCKET = sig ... end
val listening_socket : + (module LISTENING_SOCKET with type t = 't and type tag = 'tag) -> + ('t, 'tag listening_socket_ty) Resource.handler
module type NETWORK = sig ... end
val network : + (module NETWORK with type t = 't and type tag = 'tag) -> + ('t, 'tag ty) Resource.handler
\ No newline at end of file diff --git a/eio/Eio/Net/Pi/module-type-DATAGRAM_SOCKET/index.html b/eio/Eio/Net/Pi/module-type-DATAGRAM_SOCKET/index.html new file mode 100644 index 000000000..2c1f62ccd --- /dev/null +++ b/eio/Eio/Net/Pi/module-type-DATAGRAM_SOCKET/index.html @@ -0,0 +1,2 @@ + +DATAGRAM_SOCKET (eio.Eio.Net.Pi.DATAGRAM_SOCKET)

Module type Pi.DATAGRAM_SOCKET

type tag
include Flow.Pi.SHUTDOWN
type t
val shutdown : t -> Flow.shutdown_command -> unit
val send : t -> ?dst:Sockaddr.datagram -> Cstruct.t list -> unit
val recv : t -> Cstruct.t -> Sockaddr.datagram * int
val close : t -> unit
\ No newline at end of file diff --git a/eio/Eio/Net/Pi/module-type-LISTENING_SOCKET/index.html b/eio/Eio/Net/Pi/module-type-LISTENING_SOCKET/index.html new file mode 100644 index 000000000..c0d576003 --- /dev/null +++ b/eio/Eio/Net/Pi/module-type-LISTENING_SOCKET/index.html @@ -0,0 +1,2 @@ + +LISTENING_SOCKET (eio.Eio.Net.Pi.LISTENING_SOCKET)

Module type Pi.LISTENING_SOCKET

type t
type tag
val close : t -> unit
\ No newline at end of file diff --git a/eio/Eio/Net/Pi/module-type-NETWORK/index.html b/eio/Eio/Net/Pi/module-type-NETWORK/index.html new file mode 100644 index 000000000..59eece4c9 --- /dev/null +++ b/eio/Eio/Net/Pi/module-type-NETWORK/index.html @@ -0,0 +1,15 @@ + +NETWORK (eio.Eio.Net.Pi.NETWORK)

Module type Pi.NETWORK

type t
type tag
val listen : + t -> + reuse_addr:bool -> + reuse_port:bool -> + backlog:int -> + sw:Switch.t -> + Sockaddr.stream -> + tag listening_socket_ty Std.r
val datagram_socket : + t -> + reuse_addr:bool -> + reuse_port:bool -> + sw:Switch.t -> + [ Sockaddr.datagram | `UdpV4 | `UdpV6 ] -> + tag datagram_socket_ty Std.r
val getaddrinfo : t -> service:string -> string -> Sockaddr.t list
val getnameinfo : t -> Sockaddr.t -> string * string
\ No newline at end of file diff --git a/eio/Eio/Net/Pi/module-type-STREAM_SOCKET/index.html b/eio/Eio/Net/Pi/module-type-STREAM_SOCKET/index.html new file mode 100644 index 000000000..5cffcd9bf --- /dev/null +++ b/eio/Eio/Net/Pi/module-type-STREAM_SOCKET/index.html @@ -0,0 +1,2 @@ + +STREAM_SOCKET (eio.Eio.Net.Pi.STREAM_SOCKET)

Module type Pi.STREAM_SOCKET

type tag
include Flow.Pi.SHUTDOWN
type t
val shutdown : t -> Flow.shutdown_command -> unit
include Flow.Pi.SOURCE with type t := t
val read_methods : t Flow.read_method list
val single_read : t -> Cstruct.t -> int
include Flow.Pi.SINK with type t := t
val single_write : t -> Cstruct.t list -> int
val copy : t -> src:_ Flow.source -> unit

copy t ~src allows for optimising copy operations.

If you have no optimisations, you can use simple_copy to implement this using single_write.

val close : t -> unit
\ No newline at end of file diff --git a/eio/Eio/Net/Sockaddr/index.html b/eio/Eio/Net/Sockaddr/index.html index a7ab33bff..080336e94 100644 --- a/eio/Eio/Net/Sockaddr/index.html +++ b/eio/Eio/Net/Sockaddr/index.html @@ -1,2 +1,2 @@ -Sockaddr (eio.Eio.Net.Sockaddr)

Module Net.Sockaddr

Network addresses.

type stream = [
  1. | `Unix of string
  2. | `Tcp of Ipaddr.v4v6 * int
]

Socket addresses that we can build a Flow.two_way for i.e. stream-oriented protocols.

type datagram = [
  1. | `Udp of Ipaddr.v4v6 * int
  2. | `Unix of string
]

Socket addresses that are message-oriented.

type t = [
  1. | stream
  2. | datagram
]
val pp : Stdlib.Format.formatter -> [< t ] -> unit
\ No newline at end of file +Sockaddr (eio.Eio.Net.Sockaddr)

Module Net.Sockaddr

Network addresses.

type stream = [
  1. | `Unix of string
  2. | `Tcp of Ipaddr.v4v6 * int
]

Socket addresses that we can build a Flow.two_way for i.e. stream-oriented protocols.

type datagram = [
  1. | `Udp of Ipaddr.v4v6 * int
  2. | `Unix of string
]

Socket addresses that are message-oriented.

type t = [
  1. | stream
  2. | datagram
]
val pp : Stdlib.Format.formatter -> [< t ] -> unit
\ No newline at end of file diff --git a/eio/Eio/Net/class-datagram_socket/index.html b/eio/Eio/Net/class-datagram_socket/index.html deleted file mode 100644 index b12c7b002..000000000 --- a/eio/Eio/Net/class-datagram_socket/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -datagram_socket (eio.Eio.Net.datagram_socket)

Class Net.datagram_socket

inherit socket
method virtual send : ?dst:Sockaddr.datagram -> Cstruct.t list -> unit
method virtual recv : Cstruct.t -> Sockaddr.datagram * int
\ No newline at end of file diff --git a/eio/Eio/Net/class-listening_socket/index.html b/eio/Eio/Net/class-listening_socket/index.html deleted file mode 100644 index 336e05ec8..000000000 --- a/eio/Eio/Net/class-listening_socket/index.html +++ /dev/null @@ -1,3 +0,0 @@ - -listening_socket (eio.Eio.Net.listening_socket)

Class Net.listening_socket

inherit socket
method virtual accept : sw:Eio__core.Switch.t -> - stream_socket * Sockaddr.stream
\ No newline at end of file diff --git a/eio/Eio/Net/class-socket/index.html b/eio/Eio/Net/class-socket/index.html deleted file mode 100644 index 68cc92b05..000000000 --- a/eio/Eio/Net/class-socket/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -socket (eio.Eio.Net.socket)

Class Net.socket

inherit Eio__.Generic.t
\ No newline at end of file diff --git a/eio/Eio/Net/class-stream_socket/index.html b/eio/Eio/Net/class-stream_socket/index.html deleted file mode 100644 index fc57b9e30..000000000 --- a/eio/Eio/Net/class-stream_socket/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -stream_socket (eio.Eio.Net.stream_socket)

Class Net.stream_socket

inherit socket
inherit Eio__.Flow.two_way
\ No newline at end of file diff --git a/eio/Eio/Net/class-t/index.html b/eio/Eio/Net/class-t/index.html deleted file mode 100644 index 4c3fb4a84..000000000 --- a/eio/Eio/Net/class-t/index.html +++ /dev/null @@ -1,13 +0,0 @@ - -t (eio.Eio.Net.t)

Class Net.t

method virtual listen : reuse_addr:bool -> - reuse_port:bool -> - backlog:int -> - sw:Eio__core.Switch.t -> - Sockaddr.stream -> - listening_socket
method virtual connect : sw:Eio__core.Switch.t -> - Sockaddr.stream -> - stream_socket
method virtual datagram_socket : reuse_addr:bool -> - reuse_port:bool -> - sw:Eio__core.Switch.t -> - [ Sockaddr.datagram | `UdpV4 | `UdpV6 ] -> - datagram_socket
method virtual getaddrinfo : service:string -> string -> Sockaddr.t list
method virtual getnameinfo : Sockaddr.t -> string * string
\ No newline at end of file diff --git a/eio/Eio/Net/index.html b/eio/Eio/Net/index.html index 5edc2f2c6..5c027cb8c 100644 --- a/eio/Eio/Net/index.html +++ b/eio/Eio/Net/index.html @@ -1,44 +1,59 @@ -Net (eio.Eio.Net)

Module Eio.Net

Networking.

Example:

let addr = `Tcp (Ipaddr.V4.loopback, 8080)
+Net (eio.Eio.Net)

Module Eio.Net

Networking.

Example:

let addr = `Tcp (Ipaddr.V4.loopback, 8080)
 
 let http_get ~net ~stdout addr =
   Switch.run @@ fun sw ->
   let flow = Net.connect ~sw net addr in
   Flow.copy_string "GET / HTTP/1.0\r\n\r\n" flow;
   Flow.shutdown flow `Send;
-  Flow.copy flow stdout
type connection_failure =
  1. | Refused of Exn.Backend.t
  2. | No_matching_addresses
  3. | Timeout
type error =
  1. | Connection_reset of Exn.Backend.t
    (*

    This is a wrapper for epipe, econnreset and similar errors. It indicates that the flow has failed, and data may have been lost.

    *)
  2. | Connection_failure of connection_failure
type Exn.err +=
  1. | E of error
val err : error -> exn

err e is Eio.Exn.create (Net e)

module Ipaddr : sig ... end

IP addresses.

module Sockaddr : sig ... end

Network addresses.

Provider Interfaces

class virtual socket : object ... end
class virtual stream_socket : object ... end
class virtual datagram_socket : object ... end
class virtual listening_socket : object ... end
class virtual t : object ... end

Out-bound Connections

val connect : sw:Switch.t -> t -> Sockaddr.stream -> stream_socket

connect ~sw t addr is a new socket connected to remote address addr.

The new socket will be closed when sw finishes, unless closed manually first.

val with_tcp_connect : + Flow.copy flow stdout
type connection_failure =
  1. | Refused of Exn.Backend.t
  2. | No_matching_addresses
  3. | Timeout
type error =
  1. | Connection_reset of Exn.Backend.t
    (*

    This is a wrapper for epipe, econnreset and similar errors. It indicates that the flow has failed, and data may have been lost.

    *)
  2. | Connection_failure of connection_failure
type Exn.err +=
  1. | E of error
val err : error -> exn

err e is Eio.Exn.create (Net e)

module Ipaddr : sig ... end

IP addresses.

module Sockaddr : sig ... end

Network addresses.

Types

type socket_ty = [
  1. | `Socket
  2. | `Close
]
type 'a socket = [> socket_ty ] as 'a Std.r
type 'tag stream_socket_ty = [
  1. | `Stream
  2. | `Platform of 'tag
  3. | `Shutdown
  4. | socket_ty
  5. | Flow.source_ty
  6. | Flow.sink_ty
]
type 'a stream_socket = 'a Std.r constraint 'a = [> [> `Generic ] stream_socket_ty ]
type 'tag listening_socket_ty = [
  1. | `Accept
  2. | `Platform of 'tag
  3. | socket_ty
]
type 'a listening_socket = 'a Std.r constraint 'a = [> [> `Generic ] listening_socket_ty ]
type 'a connection_handler = 'a stream_socket -> Sockaddr.stream -> unit

A _ connection_handler handles incoming connections from a listening socket.

type 'tag datagram_socket_ty = [
  1. | `Datagram
  2. | `Platform of 'tag
  3. | `Shutdown
  4. | socket_ty
]
type 'a datagram_socket = 'a Std.r constraint 'a = [> [> `Generic ] datagram_socket_ty ]
type 'tag ty = [
  1. | `Network
  2. | `Platform of 'tag
]
type 'a t = 'a Std.r constraint 'a = [> [> `Generic ] ty ]

Out-bound Connections

val connect : + sw:Switch.t -> + [> 'tag ty ] t -> + Sockaddr.stream -> + 'tag stream_socket_ty Std.r

connect ~sw t addr is a new socket connected to remote address addr.

The new socket will be closed when sw finishes, unless closed manually first.

val with_tcp_connect : ?timeout:Time.Timeout.t -> host:string -> service:string -> - t -> - (stream_socket -> 'b) -> + [> 'tag ty ] Std.r -> + ('tag stream_socket_ty Std.r -> 'b) -> 'b

with_tcp_connect ~host ~service t f creates a tcp connection conn to host and service and executes f conn.

conn is closed after f returns (if it isn't already closed by then).

host is either an IP address or a domain name, eg. "www.example.org", "www.ocaml.org" or "127.0.0.1".

service is an IANA recognized service name or port number, eg. "http", "ftp", "8080" etc. See https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml.

Addresses are tried in the order they are returned by getaddrinfo, until one succeeds.

  • parameter timeout

    Limits how long to wait for each connection attempt before moving on to the next. By default there is no timeout (beyond what the underlying network does).

  • raises Connection_failure

    A connection couldn't be established for any of the addresses defined for host.

Incoming Connections

val listen : ?reuse_addr:bool -> ?reuse_port:bool -> backlog:int -> sw:Switch.t -> - t -> + [> 'tag ty ] Std.r -> Sockaddr.stream -> - listening_socket

listen ~sw ~backlog t addr is a new listening socket bound to local address addr.

The new socket will be closed when sw finishes, unless closed manually first.

For (non-abstract) Unix domain sockets, the path will be removed afterwards.

  • parameter backlog

    The number of pending connections that can be queued up (see listen(2)).

  • parameter reuse_addr

    Set the Unix.SO_REUSEADDR socket option. For Unix paths, also remove any stale left-over socket.

  • parameter reuse_port

    Set the Unix.SO_REUSEPORT socket option.

accept ~sw socket waits until a new connection is ready on socket and returns it.

The new socket will be closed automatically when sw finishes, if not closed earlier. If you want to handle multiple connections, consider using accept_fork instead.

type connection_handler = stream_socket -> Sockaddr.stream -> unit

connection_handler handles incoming connections from a listening socket.

val accept_fork : + 'tag listening_socket_ty Std.r

listen ~sw ~backlog t addr is a new listening socket bound to local address addr.

The new socket will be closed when sw finishes, unless closed manually first.

For (non-abstract) Unix domain sockets, the path will be removed afterwards.

  • parameter backlog

    The number of pending connections that can be queued up (see listen(2)).

  • parameter reuse_addr

    Set the Unix.SO_REUSEADDR socket option. For Unix paths, also remove any stale left-over socket.

  • parameter reuse_port

    Set the Unix.SO_REUSEPORT socket option.

val accept : + sw:Switch.t -> + [> 'tag listening_socket_ty ] Std.r -> + 'tag stream_socket_ty Std.r * Sockaddr.stream

accept ~sw socket waits until a new connection is ready on socket and returns it.

The new socket will be closed automatically when sw finishes, if not closed earlier. If you want to handle multiple connections, consider using accept_fork instead.

val accept_fork : sw:Switch.t -> - listening_socket -> + [> 'tag listening_socket_ty ] Std.r -> on_error:(exn -> unit) -> - connection_handler -> + [< 'tag stream_socket_ty ] connection_handler -> unit

accept_fork ~sw ~on_error socket fn accepts a connection and handles it in a new fiber.

After accepting a connection to socket, it runs fn flow client_addr in a new fiber.

flow will be closed when fn returns. The new fiber is attached to sw.

  • parameter on_error

    Called if connection_handler raises an exception. This is typically a good place to log the error and continue. If the exception is an Eio.Io error then the caller's address is added to it.

    If you don't want to handle connection errors, use ~on_error:raise to cancel the caller's context.

    on_error is not called for Cancel.Cancelled exceptions, which do not need to be reported.

Running Servers

val run_server : ?max_connections:int -> - ?additional_domains:(Domain_manager.t * int) -> + ?additional_domains:(_ Domain_manager.t * int) -> ?stop:'a Promise.t -> on_error:(exn -> unit) -> - listening_socket -> - connection_handler -> + [> 'tag listening_socket_ty ] Std.r -> + [< 'tag stream_socket_ty ] connection_handler -> 'a

run_server ~on_error sock connection_handler establishes a concurrent socket server s.

It accepts incoming client connections on socket sock and handles them with accept_fork (see that for the description of on_error and connection_handler).

Running a Parallel Server

By default s runs on a single OCaml Domain. However, if additional_domains:(domain_mgr, domains) parameter is given, then s will spawn domains additional domains and run accept loops in those too. In such cases you must ensure that connection_handler only accesses thread-safe values. Note that having more than Domain.recommended_domain_count domains in total is likely to result in bad performance.

  • parameter max_connections

    The maximum number of concurrent connections accepted by s at any time. The default is Int.max_int.

  • parameter stop

    Resolving this promise causes s to stop accepting new connections. run_server will wait for all existing connections to finish and then return. This is useful to upgrade a server without clients noticing. To stop immediately, cancelling all connections, just cancel s's fiber instead.

  • parameter on_error

    Connection error handler (see accept_fork).

  • raises Invalid_argument

    if max_connections <= 0. if additional_domains = (domain_mgr, domains) is used and domains < 0.

Datagram Sockets

val datagram_socket : ?reuse_addr:bool -> ?reuse_port:bool -> sw:Switch.t -> - t -> + [> 'tag ty ] Std.r -> [< Sockaddr.datagram | `UdpV4 | `UdpV6 ] -> - datagram_socket

datagram_socket ~sw t addr creates a new datagram socket bound to addr. The new socket will be closed when sw finishes.

`UdpV4 and `UdpV6 represents IPv4 and IPv6 datagram client sockets where the OS assigns the next available socket address and port automatically. `Udp .. can be used to create both listening server socket and client socket.

  • parameter reuse_addr

    Set the Unix.SO_REUSEADDR socket option.

  • parameter reuse_port

    Set the Unix.SO_REUSEPORT socket option.

val send : datagram_socket -> ?dst:Sockaddr.datagram -> Cstruct.t list -> unit

send sock buf sends the data in buf using the the datagram socket sock.

  • parameter dst

    If sock isn't connected, this provides the destination.

val recv : datagram_socket -> Cstruct.t -> Sockaddr.datagram * int

recv sock buf receives data from the socket sock putting it in buf. The number of bytes received is returned along with the sender address and port. If the buf is too small then excess bytes may be discarded depending on the type of the socket the message is received from.

DNS queries

val getaddrinfo : ?service:string -> t -> string -> Sockaddr.t list

getaddrinfo ?service t node returns a list of IP addresses for node. node is either a domain name or an IP address.

  • parameter service

    is a human friendly textual name for internet services assigned by IANA., eg. 'http', 'https', 'ftp', etc.

    For a more thorough treatment, see getaddrinfo.

val getaddrinfo_stream : ?service:string -> t -> string -> Sockaddr.stream list

getaddrinfo_stream is like getaddrinfo, but filters out non-stream protocols.

val getaddrinfo_datagram : + 'tag datagram_socket_ty Std.r

datagram_socket ~sw t addr creates a new datagram socket bound to addr. The new socket will be closed when sw finishes.

`UdpV4 and `UdpV6 represents IPv4 and IPv6 datagram client sockets where the OS assigns the next available socket address and port automatically. `Udp .. can be used to create both listening server socket and client socket.

  • parameter reuse_addr

    Set the Unix.SO_REUSEADDR socket option.

  • parameter reuse_port

    Set the Unix.SO_REUSEPORT socket option.

val send : + _ datagram_socket -> + ?dst:Sockaddr.datagram -> + Cstruct.t list -> + unit

send sock buf sends the data in buf using the the datagram socket sock.

  • parameter dst

    If sock isn't connected, this provides the destination.

val recv : _ datagram_socket -> Cstruct.t -> Sockaddr.datagram * int

recv sock buf receives data from the socket sock putting it in buf. The number of bytes received is returned along with the sender address and port. If the buf is too small then excess bytes may be discarded depending on the type of the socket the message is received from.

DNS queries

val getaddrinfo : ?service:string -> _ t -> string -> Sockaddr.t list

getaddrinfo ?service t node returns a list of IP addresses for node. node is either a domain name or an IP address.

  • parameter service

    is a human friendly textual name for internet services assigned by IANA., eg. 'http', 'https', 'ftp', etc.

    For a more thorough treatment, see getaddrinfo.

val getaddrinfo_stream : + ?service:string -> + _ t -> + string -> + Sockaddr.stream list

getaddrinfo_stream is like getaddrinfo, but filters out non-stream protocols.

val getaddrinfo_datagram : ?service:string -> - t -> + _ t -> string -> - Sockaddr.datagram list

getaddrinfo_datagram is like getaddrinfo, but filters out non-datagram protocols.

val getnameinfo : t -> Sockaddr.t -> string * string

getnameinfo t sockaddr is (hostname, service) corresponding to sockaddr. hostname is the registered domain name represented by sockaddr. service is the IANA specified textual name of the port specified in sockaddr, e.g. 'ftp', 'http', 'https', etc.

Closing

val close : Generic.close -> unit

Alias of Generic.close.

\ No newline at end of file + Sockaddr.datagram list

getaddrinfo_datagram is like getaddrinfo, but filters out non-datagram protocols.

val getnameinfo : _ t -> Sockaddr.t -> string * string

getnameinfo t sockaddr is (hostname, service) corresponding to sockaddr. hostname is the registered domain name represented by sockaddr. service is the IANA specified textual name of the port specified in sockaddr, e.g. 'ftp', 'http', 'https', etc.

Closing

val close : [> `Close ] Std.r -> unit

Alias of Resource.close.

Provider Interface

module Pi : sig ... end
\ No newline at end of file diff --git a/eio/Eio/Path/index.html b/eio/Eio/Path/index.html index e12e3a7a4..7dbc908b0 100644 --- a/eio/Eio/Path/index.html +++ b/eio/Eio/Path/index.html @@ -1,5 +1,5 @@ -Path (eio.Eio.Path)

Module Eio.Path

Accessing paths on a file-system.

A _ Path.t represents a particular location in some filesystem. It is a pair of a base directory and a relative path from there.

Eio.Stdenv.cwd provides access to the current working directory. For example:

let ( / ) = Eio.Path.( / )
+Path (eio.Eio.Path)

Module Eio.Path

Accessing paths on a file-system.

A _ Path.t represents a particular location in some filesystem. It is a pair of a base directory and a relative path from there.

Eio.Stdenv.cwd provides access to the current working directory. For example:

let ( / ) = Eio.Path.( / )
 
 let run dir =
   Eio.Path.save ~create:(`Exclusive 0o600)
@@ -7,15 +7,14 @@
 
 let () =
   Eio_main.run @@ fun env ->
-  run (Eio.Stdenv.cwd env)

It is normally not permitted to access anything above the base directory, even by following a symlink. The exception is Stdenv.fs, which provides access to the whole file-system:

Eio.Path.load (fs / "/etc/passwd")
type 'a t = Fs.dir as 'a * Fs.path

An OS directory FD and a path relative to it, for use with e.g. openat(2).

val (/) : 'a t -> string -> 'a t

t / step is t with step appended to t's path, or replacing t's path if step is absolute:

  • (fd, "foo") / "bar" = (fd, "foo/bar")
  • (fd, "foo") / "/bar" = (fd, "/bar")
val pp : _ t Fmt.t

pp formats a _ t as "<label:path>", suitable for logging.

Reading files

val load : _ t -> string

load t returns the contents of the given file.

This is a convenience wrapper around with_open_in.

val open_in : sw:Switch.t -> _ t -> < File.ro ; Flow.close >

open_in ~sw t opens t for reading.

Note: files are always opened in binary mode.

val with_open_in : _ t -> (< File.ro ; Flow.close > -> 'a) -> 'a

with_open_in is like open_in, but calls fn flow with the new flow and closes it automatically when fn returns (if it hasn't already been closed by then).

val with_lines : _ t -> (string Stdlib.Seq.t -> 'a) -> 'a

with_lines t fn is a convenience function for streaming the lines of the file.

It uses Buf_read.lines.

Writing files

val save : ?append:bool -> create:Fs.create -> _ t -> string -> unit

save t data ~create writes data to t.

This is a convenience wrapper around with_open_out.

val open_out : + run (Eio.Stdenv.cwd env)

It is normally not permitted to access anything above the base directory, even by following a symlink. The exception is Stdenv.fs, which provides access to the whole file-system:

Eio.Path.load (fs / "/etc/passwd")

In Eio, the directory separator is always "/", even on Windows. Use native to convert to a native path.

type 'a t = 'a Fs.dir * Fs.path

An OS directory FD and a path relative to it, for use with e.g. openat(2).

val (/) : 'a t -> string -> 'a t

t / step is t with step appended to t's path, or replacing t's path if step is absolute:

  • (fd, "foo") / "bar" = (fd, "foo/bar")
  • (fd, "foo") / "/bar" = (fd, "/bar")
val pp : _ t Fmt.t

pp formats a _ t as "<label:path>", suitable for logging.

val native : _ t -> string option

native t returns a path that can be used to refer to t with the host platform's native string-based file-system APIs, if available. This is intended for interoperability with non-Eio libraries.

This does not check for confinement (the resulting path might not be accessible via t itself). Also, if a directory was opened with open_dir and later renamed, this might use the old name.

Using strings as paths is not secure if components in the path can be replaced by symlinks while the path is being used. For example, if you try to write to "/home/mal/output.txt" just as mal replaces "output.txt" with a symlink to "/etc/passwd".

val native_exn : _ t -> string

Like native, but raise a suitable exception if the path is not a native path.

Reading files

val load : _ t -> string

load t returns the contents of the given file.

This is a convenience wrapper around with_open_in.

val open_in : sw:Switch.t -> _ t -> File.ro_ty Std.r

open_in ~sw t opens t for reading.

Note: files are always opened in binary mode.

val with_open_in : _ t -> (File.ro_ty Std.r -> 'a) -> 'a

with_open_in is like open_in, but calls fn flow with the new flow and closes it automatically when fn returns (if it hasn't already been closed by then).

val with_lines : _ t -> (string Stdlib.Seq.t -> 'a) -> 'a

with_lines t fn is a convenience function for streaming the lines of the file.

It uses Buf_read.lines.

Writing files

val save : ?append:bool -> create:Fs.create -> _ t -> string -> unit

save t data ~create writes data to t.

This is a convenience wrapper around with_open_out.

val open_out : sw:Switch.t -> ?append:bool -> create:Fs.create -> _ t -> - < File.rw - ; Flow.close >

open_out ~sw t opens t for reading and writing.

Note: files are always opened in binary mode.

  • parameter append

    Open for appending: always write at end of file.

  • parameter create

    Controls whether to create the file, and what permissions to give it if so.

val with_open_out : + File.rw_ty Resource.t

open_out ~sw t opens t for reading and writing.

Note: files are always opened in binary mode.

  • parameter append

    Open for appending: always write at end of file.

  • parameter create

    Controls whether to create the file, and what permissions to give it if so.

val with_open_out : ?append:bool -> create:Fs.create -> _ t -> - (< File.rw ; Flow.close > -> 'a) -> - 'a

with_open_out is like open_out, but calls fn flow with the new flow and closes it automatically when fn returns (if it hasn't already been closed by then).

Directories

val mkdir : perm:File.Unix_perm.t -> _ t -> unit

mkdir ~perm t creates a new directory t with permissions perm.

val open_dir : sw:Switch.t -> _ t -> < Fs.dir ; Flow.close > t

open_dir ~sw t opens t.

This can be passed to functions to grant access only to the subtree t.

val with_open_dir : _ t -> (< Fs.dir ; Flow.close > t -> 'a) -> 'a

with_open_dir is like open_dir, but calls fn dir with the new directory and closes it automatically when fn returns (if it hasn't already been closed by then).

val read_dir : _ t -> string list

read_dir t reads directory entries for t.

The entries are sorted using String.compare.

Note: The special Unix entries "." and ".." are not included in the results.

Other

unlink t removes directory entry t.

Note: this cannot be used to unlink directories. Use rmdir for directories.

val rmdir : _ t -> unit

rmdir t removes directory entry t. This only works when the entry is itself a directory.

Note: this usually requires the directory to be empty.

val rename : _ t -> _ t -> unit

rename old_t new_t atomically unlinks old_t and links it as new_t.

If new_t already exists, it is atomically replaced.

\ No newline at end of file + (File.rw_ty Std.r -> 'a) -> + 'a

with_open_out is like open_out, but calls fn flow with the new flow and closes it automatically when fn returns (if it hasn't already been closed by then).

Directories

val mkdir : perm:File.Unix_perm.t -> _ t -> unit

mkdir ~perm t creates a new directory t with permissions perm.

val open_dir : sw:Switch.t -> _ t -> [ `Close | Fs.dir_ty ] t

open_dir ~sw t opens t.

This can be passed to functions to grant access only to the subtree t.

val with_open_dir : _ t -> ([ `Close | Fs.dir_ty ] t -> 'a) -> 'a

with_open_dir is like open_dir, but calls fn dir with the new directory and closes it automatically when fn returns (if it hasn't already been closed by then).

val read_dir : _ t -> string list

read_dir t reads directory entries for t.

The entries are sorted using String.compare.

Note: The special Unix entries "." and ".." are not included in the results.

Other

unlink t removes directory entry t.

Note: this cannot be used to unlink directories. Use rmdir for directories.

val rmdir : _ t -> unit

rmdir t removes directory entry t. This only works when the entry is itself a directory.

Note: this usually requires the directory to be empty.

val rename : _ t -> _ t -> unit

rename old_t new_t atomically unlinks old_t and links it as new_t.

If new_t already exists, it is atomically replaced.

\ No newline at end of file diff --git a/eio/Eio/Pool/index.html b/eio/Eio/Pool/index.html new file mode 100644 index 000000000..2c3a9d991 --- /dev/null +++ b/eio/Eio/Pool/index.html @@ -0,0 +1,8 @@ + +Pool (eio.Eio.Pool)

Module Eio.Pool

A pool of resources.

This is useful to manage a collection of resources where creating new ones is expensive and so you want to reuse them where possible.

Example:

let buffer_pool = Eio.Pool.create 10 (fun () -> Bytes.create 1024) in
+Eio.Pool.use buffer_pool (fun buf -> ...)

Note: If you just need to limit how many resources are in use, it is simpler to use Eio.Semaphore instead.

type 'a t
val create : + ?validate:('a -> bool) -> + ?dispose:('a -> unit) -> + int -> + (unit -> 'a) -> + 'a t

create n alloc is a fresh pool which allows up to n resources to be live at a time. It uses alloc to create new resources as needed. If alloc raises an exception then that use fails, but future calls to use will retry.

The alloc function is called in the context of the fiber trying to use the pool. If the pool is shared between domains and the resources are attached to a switch, this might cause trouble (since switches can't be shared between domains). You might therefore want to make alloc request a resource from the main domain rather than creating one itself.

You should also take care about handling cancellation in alloc, since resources are typically attached to a switch with the lifetime of the pool, meaning that if alloc fails then they won't be freed automatically until the pool itself is finished.

  • parameter validate

    If given, this is used to check each resource before using it. If it returns false, the pool removes it with dispose and then allocates a fresh resource.

  • parameter dispose

    Used to free resources rejected by validate. If it raises, the exception is passed on to the user, but resource is still considered to have been disposed.

val use : 'a t -> ('a -> 'b) -> 'b

use t fn waits for some resource x to be available and then runs f x. Afterwards (on success or error), x is returned to the pool.

\ No newline at end of file diff --git a/eio/Eio/Private/Broadcast/index.html b/eio/Eio/Private/Broadcast/index.html index 15569d827..f16f312ef 100644 --- a/eio/Eio/Private/Broadcast/index.html +++ b/eio/Eio/Private/Broadcast/index.html @@ -1,2 +1,2 @@ -Broadcast (eio.Eio.Private.Broadcast)

Module Private.Broadcast

A lock-free queue of waiters that should all be resumed at once.

This uses Cells internally.

type t
type request

A handle to a pending request that can be used to cancel it.

val create : unit -> t

create () is a fresh broadcast queue.

val suspend : t -> (unit -> unit) -> request option

suspend t fn arranges for fn () to be called on resume_all.

fn () may be called from the caller's context, or by resume_all, so it needs to be able to cope with running in any context where that can run. For example, fn must be safe to call from a signal handler if resume_all can be called from one. fn must not raise.

The returned request can be used to cancel. It can be None in the (unlikely) event that t got resumed before the function returned.

val resume_all : t -> unit

resume_all t calls all non-cancelled callbacks attached to t, in the order in which they were suspended.

This function is lock-free and can be used safely even from a signal handler or GC finalizer.

val cancel : request -> bool

cancel request attempts to remove a pending request.

It returns true if the request was cancelled, or false if it got resumed before that could happen.

val dump : Stdlib.Format.formatter -> t -> unit

Display the internal state of a queue, for debugging.

\ No newline at end of file +Broadcast (eio.Eio.Private.Broadcast)

Module Private.Broadcast

A lock-free queue of waiters that should all be resumed at once.

This uses Cells internally.

type t
type request

A handle to a pending request that can be used to cancel it.

val create : unit -> t

create () is a fresh broadcast queue.

val suspend : t -> (unit -> unit) -> request option

suspend t fn arranges for fn () to be called on resume_all.

fn () may be called from the caller's context, or by resume_all, so it needs to be able to cope with running in any context where that can run. For example, fn must be safe to call from a signal handler if resume_all can be called from one. fn must not raise.

The returned request can be used to cancel. It can be None in the (unlikely) event that t got resumed before the function returned.

val resume_all : t -> unit

resume_all t calls all non-cancelled callbacks attached to t, in the order in which they were suspended.

This function is lock-free and can be used safely even from a signal handler or GC finalizer.

val cancel : request -> bool

cancel request attempts to remove a pending request.

It returns true if the request was cancelled, or false if it got resumed before that could happen.

val dump : Stdlib.Format.formatter -> t -> unit

Display the internal state of a queue, for debugging.

\ No newline at end of file diff --git a/eio/Eio/Private/Cells/Make/argument-1-Cell/index.html b/eio/Eio/Private/Cells/Make/argument-1-Cell/index.html index 1c7aa0590..9195deb3e 100644 --- a/eio/Eio/Private/Cells/Make/argument-1-Cell/index.html +++ b/eio/Eio/Private/Cells/Make/argument-1-Cell/index.html @@ -1,2 +1,2 @@ -Cell (eio.Eio.Private.Cells.Make.Cell)

Parameter Make.Cell

type 'a t
val init : 'a t

The value to give newly-allocated cells.

val segment_order : int

The number of bits to use for the offset into the segment.

The number of cells per segment is 2 ** segment_order.

val dump : _ t Fmt.t

Display the cell state for debugging.

\ No newline at end of file +Cell (eio.Eio.Private.Cells.Make.Cell)

Parameter Make.Cell

type 'a t
val init : 'a t

The value to give newly-allocated cells.

val segment_order : int

The number of bits to use for the offset into the segment.

The number of cells per segment is 2 ** segment_order.

val dump : _ t Fmt.t

Display the cell state for debugging.

\ No newline at end of file diff --git a/eio/Eio/Private/Cells/Make/index.html b/eio/Eio/Private/Cells/Make/index.html index fc3c382c0..a2f3c0537 100644 --- a/eio/Eio/Private/Cells/Make/index.html +++ b/eio/Eio/Private/Cells/Make/index.html @@ -1,2 +1,2 @@ -Make (eio.Eio.Private.Cells.Make)

Module Cells.Make

Parameters

module Cell : CELL

Signature

type 'a t
type 'a segment
val make : unit -> 'a t

make () is a fresh sequence of cells.

val next_suspend : 'a t -> 'a segment * 'a Cell.t Stdlib.Atomic.t

next_suspend t atomically returns the next suspend cell and its segment.

If multiple domains call this at the same time, they will each get a different location.

The cell might or might not have already been filled in by a resumer. You need to handle both cases (typically by using Atomic.compare_and_set).

The segment can be used with cancel_cell.

This function is lock-free and is safe to call even from a signal handler or GC finalizer.

val next_resume : 'a t -> 'a Cell.t Stdlib.Atomic.t

next_resume t atomically returns the next resume cell.

If multiple domains call this at the same time, they will each get a different cell.

The cell might or might not contain a request from a suspender that got there first. You need to handle both cases (typically by using Atomic.compare_and_set).

Note: cancelled cells may or may not be skipped (you need to handle the case of the cell you get being cancelled before you can write to it, but you also can't rely on seeing every cancelled cell, as cancelled segments may be deleted).

This function is lock-free and is safe to call even from a signal handler or GC finalizer.

val resume_all : 'a t -> ('a Cell.t Stdlib.Atomic.t -> unit) -> unit

resume_all t f advances the resume position to the current suspend position, then calls f cell on each cell advanced over.

Note: as with next_resume, f may be called for some cancelled cells but not others.

f must not raise an exception (if it does, it will not be called on the remaining cells).

If the resume position is ahead of the suspend position, then calling this function does nothing.

This function is lock-free and is safe to call even from a signal handler or GC finalizer.

val cancel_cell : 'a segment -> unit

cancel_cell segment increments the segment's count of the number of cancelled cells.

Once all cells are cancelled it may be possible to discard the whole segment. This avoids leaking memory if a user keeps suspending and then cancelling.

You must not call this more than once per cell.

This function is lock-free and is safe to call even from a signal handler or GC finalizer.

val validate : _ t -> unit

validate t checks that t is in a valid state, assuming there are no operations currently in progress.

val dump : _ t Fmt.t

dump outputs the internal state of a _ t, for debugging.

\ No newline at end of file +Make (eio.Eio.Private.Cells.Make)

Module Cells.Make

Parameters

module Cell : CELL

Signature

type 'a t
type 'a segment
val make : unit -> 'a t

make () is a fresh sequence of cells.

val next_suspend : 'a t -> 'a segment * 'a Cell.t Stdlib.Atomic.t

next_suspend t atomically returns the next suspend cell and its segment.

If multiple domains call this at the same time, they will each get a different location.

The cell might or might not have already been filled in by a resumer. You need to handle both cases (typically by using Atomic.compare_and_set).

The segment can be used with cancel_cell.

This function is lock-free and is safe to call even from a signal handler or GC finalizer.

val next_resume : 'a t -> 'a Cell.t Stdlib.Atomic.t

next_resume t atomically returns the next resume cell.

If multiple domains call this at the same time, they will each get a different cell.

The cell might or might not contain a request from a suspender that got there first. You need to handle both cases (typically by using Atomic.compare_and_set).

Note: cancelled cells may or may not be skipped (you need to handle the case of the cell you get being cancelled before you can write to it, but you also can't rely on seeing every cancelled cell, as cancelled segments may be deleted).

This function is lock-free and is safe to call even from a signal handler or GC finalizer.

val resume_all : 'a t -> ('a Cell.t Stdlib.Atomic.t -> unit) -> unit

resume_all t f advances the resume position to the current suspend position, then calls f cell on each cell advanced over.

Note: as with next_resume, f may be called for some cancelled cells but not others.

f must not raise an exception (if it does, it will not be called on the remaining cells).

If the resume position is ahead of the suspend position, then calling this function does nothing.

This function is lock-free and is safe to call even from a signal handler or GC finalizer.

val cancel_cell : 'a segment -> unit

cancel_cell segment increments the segment's count of the number of cancelled cells.

Once all cells are cancelled it may be possible to discard the whole segment. This avoids leaking memory if a user keeps suspending and then cancelling.

You must not call this more than once per cell.

This function is lock-free and is safe to call even from a signal handler or GC finalizer.

val validate : _ t -> unit

validate t checks that t is in a valid state, assuming there are no operations currently in progress.

val dump : _ t Fmt.t

dump outputs the internal state of a _ t, for debugging.

\ No newline at end of file diff --git a/eio/Eio/Private/Cells/index.html b/eio/Eio/Private/Cells/index.html index 1fab5852b..dd6908690 100644 --- a/eio/Eio/Private/Cells/index.html +++ b/eio/Eio/Private/Cells/index.html @@ -1,2 +1,2 @@ -Cells (eio.Eio.Private.Cells)

Module Private.Cells

A lock-free queue-like structure with suspension and cancellation.

This module provides an infinite sequence of atomic cells, which can be used for whatever you like. There are two pointers into this sequence: a suspend (consumer) pointer and a resume (producer) pointer. These are similar to the head and tail pointers in a traditional queue, except that the consumer is also permitted to get ahead of the producer.

To use this as a plain queue, each producer calls Make.next_resume to get the cell at the resume (tail) pointer (and advance it atomically), then stores its value in the cell. Each consumer calls Make.next_suspend to get the next cell at the head of the queue (and advance the suspend pointer).

The consumer/suspender is permitted to get ahead of the producer. In this case, the consumer will CAS the cell from its initial state to a Request state containing a callback to receive the value when it arrives. When a producer later tries to CAS the cell from the initial state to holding a value, it will fail and find the Request with the callback function instead. It can then provide the value directly to the callback.

A suspender can be cancelled by CASing the Request to a Cancelled state. It should also call Make.cancel_cell (if the CAS succeeds), to allow the cell to be freed. If a resumer's CAS fails because the cell is cancelled, it can retry with a fresh cell.

For efficiency, cells are grouped into segments, which are stored in a linked list. Once all the cells in a segment are cancelled, the whole segment may be freed.

This is based on A formally-verified framework for fair synchronization in kotlin coroutines, Appendix C, which contains more details and examples of use.

This module also adds the Make.resume_all function, which is useful for broadcasting.

module type CELL = sig ... end

The signature for user-defined cell contents.

module Make (Cell : CELL) : sig ... end
\ No newline at end of file +Cells (eio.Eio.Private.Cells)

Module Private.Cells

A lock-free queue-like structure with suspension and cancellation.

This module provides an infinite sequence of atomic cells, which can be used for whatever you like. There are two pointers into this sequence: a suspend (consumer) pointer and a resume (producer) pointer. These are similar to the head and tail pointers in a traditional queue, except that the consumer is also permitted to get ahead of the producer.

To use this as a plain queue, each producer calls Make.next_resume to get the cell at the resume (tail) pointer (and advance it atomically), then stores its value in the cell. Each consumer calls Make.next_suspend to get the next cell at the head of the queue (and advance the suspend pointer).

The consumer/suspender is permitted to get ahead of the producer. In this case, the consumer will CAS the cell from its initial state to a Request state containing a callback to receive the value when it arrives. When a producer later tries to CAS the cell from the initial state to holding a value, it will fail and find the Request with the callback function instead. It can then provide the value directly to the callback.

A suspender can be cancelled by CASing the Request to a Cancelled state. It should also call Make.cancel_cell (if the CAS succeeds), to allow the cell to be freed. If a resumer's CAS fails because the cell is cancelled, it can retry with a fresh cell.

For efficiency, cells are grouped into segments, which are stored in a linked list. Once all the cells in a segment are cancelled, the whole segment may be freed.

This is based on A formally-verified framework for fair synchronization in kotlin coroutines, Appendix C, which contains more details and examples of use.

This module also adds the Make.resume_all function, which is useful for broadcasting.

module type CELL = sig ... end

The signature for user-defined cell contents.

module Make (Cell : CELL) : sig ... end
\ No newline at end of file diff --git a/eio/Eio/Private/Cells/module-type-CELL/index.html b/eio/Eio/Private/Cells/module-type-CELL/index.html index 0ec1be57a..d896db1f5 100644 --- a/eio/Eio/Private/Cells/module-type-CELL/index.html +++ b/eio/Eio/Private/Cells/module-type-CELL/index.html @@ -1,2 +1,2 @@ -CELL (eio.Eio.Private.Cells.CELL)

Module type Cells.CELL

The signature for user-defined cell contents.

type 'a t
val init : 'a t

The value to give newly-allocated cells.

val segment_order : int

The number of bits to use for the offset into the segment.

The number of cells per segment is 2 ** segment_order.

val dump : _ t Fmt.t

Display the cell state for debugging.

\ No newline at end of file +CELL (eio.Eio.Private.Cells.CELL)

Module type Cells.CELL

The signature for user-defined cell contents.

type 'a t
val init : 'a t

The value to give newly-allocated cells.

val segment_order : int

The number of bits to use for the offset into the segment.

The number of cells per segment is 2 ** segment_order.

val dump : _ t Fmt.t

Display the cell state for debugging.

\ No newline at end of file diff --git a/eio/Eio/Private/Ctf/Control/index.html b/eio/Eio/Private/Ctf/Control/index.html index f52df0ff7..47bd54a0a 100644 --- a/eio/Eio/Private/Ctf/Control/index.html +++ b/eio/Eio/Private/Ctf/Control/index.html @@ -1,2 +1,2 @@ -Control (eio.Eio.Private.Ctf.Control)

Module Ctf.Control

type t
val make : timestamper:(log_buffer -> int -> unit) -> log_buffer -> t

make ~timestamper b is a trace buffer that record events in b. In most cases, the Ctf_unix module provides a simpler interface.

val start : t -> unit

start t begins recording events in t.

val stop : t -> unit

stop t stops recording to t (which must be the current trace buffer).

\ No newline at end of file +Control (eio.Eio.Private.Ctf.Control)

Module Ctf.Control

type t
val make : timestamper:(log_buffer -> int -> unit) -> log_buffer -> t

make ~timestamper b is a trace buffer that record events in b. In most cases, the Ctf_unix module provides a simpler interface.

val start : t -> unit

start t begins recording events in t.

val stop : t -> unit

stop t stops recording to t (which must be the current trace buffer).

\ No newline at end of file diff --git a/eio/Eio/Private/Ctf/index.html b/eio/Eio/Private/Ctf/index.html index 2a4ac9b67..ca02333c5 100644 --- a/eio/Eio/Private/Ctf/index.html +++ b/eio/Eio/Private/Ctf/index.html @@ -1,4 +1,4 @@ -Ctf (eio.Eio.Private.Ctf)

Module Private.Ctf

This library is used to write event traces in mirage-profile's CTF format.

type id = private int

Each thread/fiber/promise is identified by a unique ID.

Recording events

Libraries and applications can use these functions to make the traces more useful.

val label : string -> unit

label msg attaches text msg to the current thread.

val note_increase : string -> int -> unit

note_increase counter delta records that counter increased by delta. If delta is negative, this records a decrease.

val note_counter_value : string -> int -> unit

note_counter_value counter value records that counter is now value.

val should_resolve : id -> unit

should_resolve id records that id is expected to resolve, and should be highlighted if it doesn't.

Recording system events

These are normally only called by the scheduler.

type hiatus_reason =
  1. | Wait_for_work
  2. | Suspend
  3. | Hibernate
type event =
  1. | Wait
  2. | Task
  3. | Bind
  4. | Try
  5. | Choose
  6. | Pick
  7. | Join
  8. | Map
  9. | Condition
  10. | On_success
  11. | On_failure
  12. | On_termination
  13. | On_any
  14. | Ignore_result
  15. | Async
  16. | Promise
  17. | Semaphore
  18. | Switch
  19. | Stream
  20. | Mutex
    (*

    Types of threads or other recorded objects.

    *)
val mint_id : unit -> id

mint_id () is a fresh unique id.

val note_created : ?label:string -> id -> event -> unit

note_created t id ty records the creation of id.

val note_read : ?reader:id -> id -> unit

note_read src records that promise src's value was read.

  • parameter reader

    The thread doing the read (default is the current thread).

val note_try_read : id -> unit

note_try_read src records that the current thread wants to read from src (which is not currently ready).

val note_switch : id -> unit

note_switch id records that id is now the current thread.

val note_hiatus : hiatus_reason -> unit

note_hiatus r records that the system will sleep for reason r.

val note_resume : id -> unit

note_resume id records that the system has resumed (used after note_hiatus), and is now running id.

val note_fork : unit -> id

note_fork () records that a new thread has been forked and returns a fresh ID for it.

val note_resolved : id -> ex:exn option -> unit

note_resolved id ~ex records that id is now resolved. If ex = None then id was successful, otherwise it failed with exception ex.

val note_signal : ?src:id -> id -> unit

note_signal ~src dst records that dst was signalled.

  • parameter src

    The thread sending the signal (default is the current thread).

Controlling tracing

type log_buffer = +Ctf (eio.Eio.Private.Ctf)

Module Private.Ctf

This library is used to write event traces in mirage-profile's CTF format.

type id = private int

Each thread/fiber/promise is identified by a unique ID.

Recording events

Libraries and applications can use these functions to make the traces more useful.

val label : string -> unit

label msg attaches text msg to the current thread.

val note_increase : string -> int -> unit

note_increase counter delta records that counter increased by delta. If delta is negative, this records a decrease.

val note_counter_value : string -> int -> unit

note_counter_value counter value records that counter is now value.

val should_resolve : id -> unit

should_resolve id records that id is expected to resolve, and should be highlighted if it doesn't.

Recording system events

These are normally only called by the scheduler.

type hiatus_reason =
  1. | Wait_for_work
  2. | Suspend
  3. | Hibernate
type event =
  1. | Wait
  2. | Task
  3. | Bind
  4. | Try
  5. | Choose
  6. | Pick
  7. | Join
  8. | Map
  9. | Condition
  10. | On_success
  11. | On_failure
  12. | On_termination
  13. | On_any
  14. | Ignore_result
  15. | Async
  16. | Promise
  17. | Semaphore
  18. | Switch
  19. | Stream
  20. | Mutex
    (*

    Types of threads or other recorded objects.

    *)
val mint_id : unit -> id

mint_id () is a fresh unique id.

val note_created : ?label:string -> id -> event -> unit

note_created t id ty records the creation of id.

val note_read : ?reader:id -> id -> unit

note_read src records that promise src's value was read.

  • parameter reader

    The thread doing the read (default is the current thread).

val note_try_read : id -> unit

note_try_read src records that the current thread wants to read from src (which is not currently ready).

val note_switch : id -> unit

note_switch id records that id is now the current thread.

val note_hiatus : hiatus_reason -> unit

note_hiatus r records that the system will sleep for reason r.

val note_resume : id -> unit

note_resume id records that the system has resumed (used after note_hiatus), and is now running id.

val note_fork : unit -> id

note_fork () records that a new thread has been forked and returns a fresh ID for it.

val note_resolved : id -> ex:exn option -> unit

note_resolved id ~ex records that id is now resolved. If ex = None then id was successful, otherwise it failed with exception ex.

val note_signal : ?src:id -> id -> unit

note_signal ~src dst records that dst was signalled.

  • parameter src

    The thread sending the signal (default is the current thread).

Controlling tracing

type log_buffer = (char, Stdlib.Bigarray.int8_unsigned_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t
module Control : sig ... end
\ No newline at end of file diff --git a/eio/Eio/Private/Debug/index.html b/eio/Eio/Private/Debug/index.html index 97396b6db..7fcf9ff6a 100644 --- a/eio/Eio/Private/Debug/index.html +++ b/eio/Eio/Private/Debug/index.html @@ -1,8 +1,8 @@ -Debug (eio.Eio.Private.Debug)

Module Private.Debug

val traceln : +Debug (eio.Eio.Private.Debug)

Module Private.Debug

val traceln : ?__POS__:(string * int * int * int) -> ('a, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> - 'a

Writes trace logging using the current fiber's configured traceln function.

val traceln_mutex : Stdlib.Mutex.t

The mutex used to prevent two domains writing to stderr at once.

This might be useful if you want to write to it directly yourself, e.g. for a log reporter.

val default_traceln : + 'a

Writes trace logging using the current fiber's configured traceln function.

val with_trace_prefix : (Stdlib.Format.formatter -> unit) -> (unit -> 'a) -> 'a

with_trace_prefix fmt fn runs fn () with a traceln that outputs fmt before each message.

val traceln_mutex : Stdlib.Mutex.t

The mutex used to prevent two domains writing to stderr at once.

This might be useful if you want to write to it directly yourself, e.g. for a log reporter.

val default_traceln : ?__POS__:(string * int * int * int) -> ('a, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> 'a

default_traceln is a suitable default implementation for Eio.Std.traceln.

It writes output to stderr, prefixing each line with a "+". If __POS__ is given, it also displays the file and line number from that. It uses traceln_mutex so that only one domain's output is written at a time.

type traceln = {
  1. traceln : 'a. ?__POS__:(string * int * int * int) -> diff --git a/eio/Eio/Private/Dla/index.html b/eio/Eio/Private/Dla/index.html index 0bd6a25e8..34f80ffb0 100644 --- a/eio/Eio/Private/Dla/index.html +++ b/eio/Eio/Private/Dla/index.html @@ -1,2 +1,2 @@ -Dla (eio.Eio.Private.Dla)

    Module Private.Dla

    val prepare_for_await : unit -> Domain_local_await.t
    \ No newline at end of file +Dla (eio.Eio.Private.Dla)

    Module Private.Dla

    val prepare_for_await : unit -> Domain_local_await.t
    \ No newline at end of file diff --git a/eio/Eio/Private/Effects/index.html b/eio/Eio/Private/Effects/index.html index 90b004b3b..87ff67f86 100644 --- a/eio/Eio/Private/Effects/index.html +++ b/eio/Eio/Private/Effects/index.html @@ -1,2 +1,2 @@ -Effects (eio.Eio.Private.Effects)

    Module Private.Effects

    type 'a enqueue = ('a, exn) Stdlib.result -> unit

    A function provided by the scheduler to reschedule a previously-suspended thread.

    type Stdlib.Effect.t +=
    1. | Suspend : (Fiber_context.t -> 'a enqueue -> unit) -> 'a Stdlib.Effect.t
      (*

      Suspend fn is performed when a fiber must be suspended (e.g. because it called Promise.await on an unresolved promise). The effect handler runs fn fiber enqueue in the scheduler context, passing it the suspended fiber's context and a function to resume it. fn should arrange for enqueue to be called once the thread is ready to run again.

      *)
    2. | Fork : Fiber_context.t * (unit -> unit) -> unit Stdlib.Effect.t
      (*

      perform (Fork new_context f) creates a new fiber and runs f in it, with context new_context. f must not raise an exception. See Fiber.fork.

      *)
    3. | Get_context : Fiber_context.t Stdlib.Effect.t
      (*

      perform Get_context immediately returns the current fiber's context (without switching fibers).

      *)
    \ No newline at end of file +Effects (eio.Eio.Private.Effects)

    Module Private.Effects

    type 'a enqueue = ('a, exn) Stdlib.result -> unit

    A function provided by the scheduler to reschedule a previously-suspended thread.

    type Stdlib.Effect.t +=
    1. | Suspend : (Fiber_context.t -> 'a enqueue -> unit) -> 'a Stdlib.Effect.t
      (*

      Suspend fn is performed when a fiber must be suspended (e.g. because it called Promise.await on an unresolved promise). The effect handler runs fn fiber enqueue in the scheduler context, passing it the suspended fiber's context and a function to resume it. fn should arrange for enqueue to be called once the thread is ready to run again.

      *)
    2. | Fork : Fiber_context.t * (unit -> unit) -> unit Stdlib.Effect.t
      (*

      perform (Fork new_context f) creates a new fiber and runs f in it, with context new_context. f must not raise an exception. See Fiber.fork.

      *)
    3. | Get_context : Fiber_context.t Stdlib.Effect.t
      (*

      perform Get_context immediately returns the current fiber's context (without switching fibers).

      *)
    \ No newline at end of file diff --git a/eio/Eio/Private/Fiber_context/index.html b/eio/Eio/Private/Fiber_context/index.html index 8ca5b252f..d5e256fc6 100644 --- a/eio/Eio/Private/Fiber_context/index.html +++ b/eio/Eio/Private/Fiber_context/index.html @@ -1,2 +1,2 @@ -Fiber_context (eio.Eio.Private.Fiber_context)

    Module Private.Fiber_context

    Every fiber has an associated context.

    type t
    val make_root : unit -> t

    Make a new root context for a new domain.

    val destroy : t -> unit

    destroy t removes t from its cancellation context.

    val tid : t -> Ctf.id

    Cancellation

    The Cancel module describes the user's view of cancellation.

    Internally, when the user calls a primitive operation that needs to block the fiber, the Suspend callback effect is performed. This suspends the fiber and calls callback from the scheduler's context, passing it the suspended fiber's context. If the operation can be cancelled, the callback should use set_cancel_fn to register a cancellation function.

    There are two possible outcomes for the operation: it may complete normally, or it may be cancelled. If it is cancelled then the registered cancellation function is called. This function will always be called from the fiber's own domain, but care must be taken if the operation could be completed by another domain at the same time.

    Consider the case of Stream.take, which can be fulfilled by a Stream.add from another domain. We want to ensure that either the item is removed from the stream and returned to the waiting fiber, or that the operation is cancelled and the item is not removed from the stream.

    Therefore, cancelling and completing both need to update an atomic value (with Atomic.compare_and_set) so that only one can succeed. The case where Stream.take succeeds before cancellation:

    1. A fiber calls Suspend and is suspended. The callback sets a cancel function and registers a waiter on the stream.
    2. When another domain has an item, it marks the atomic as finished (making the take uncancellable) and begins resuming the fiber with the new item.
    3. If the taking fiber is cancelled after this, the cancellation must be ignored and the operation will complete successfully. Future operations will fail immediately, however.

    The case of cancellation winning the race:

    1. A fiber calls Suspend and is suspended. The callback sets a cancel function and registers a waiter on the stream.
    2. The taking fiber is cancelled. Its cancellation function is called, which updates the atomic and starts removing the waiter.
    3. If another domain tries to provide an item to the waiter as this is happening, it will try to update the atomic too and fail. The item will be given to the next waiter instead.

    Note: A fiber will only have a cancel function set while it is suspended.

    val cancellation_context : t -> Cancel.t

    cancellation_context t is t's current cancellation context.

    val set_cancel_fn : t -> (exn -> unit) -> unit

    set_cancel_fn t fn sets fn as the fiber's cancel function.

    If t's cancellation context is cancelled, the function is called. It should attempt to make the current operation finish quickly, either with a successful result or by raising the given exception.

    Just before being called, the fiber's cancel function is replaced with ignore so that fn cannot be called twice.

    On success, the cancel function is cleared automatically when Suspend.enter returns, but for single-domain operations you may like to call clear_cancel_fn manually to remove it earlier.

    fn will be called from t's domain (from the fiber that called cancel).

    fn must not switch fibers. If it did, this could happen:

    1. Another suspended fiber in the same cancellation context resumes before its cancel function is called.
    2. It enters a protected block and starts a new operation.
    3. fn returns.
    4. We cancel the protected operation.
    val clear_cancel_fn : t -> unit

    clear_cancel_fn t is set_cancel_fn t ignore.

    This must only be called from the fiber's own domain.

    For single-domain operations, it can be useful to call this manually as soon as the operation succeeds (i.e. when the fiber is added to the run-queue) to prevent the cancel function from being called.

    For operations where another domain may resume the fiber, your cancel function will need to cope with being called after the operation has succeeded. In that case you should not call clear_cancel_fn. The backend will do it automatically just before resuming your fiber.

    val get_error : t -> exn option

    get_error t is Cancel.get_error (cancellation_context t)

    \ No newline at end of file +Fiber_context (eio.Eio.Private.Fiber_context)

    Module Private.Fiber_context

    Every fiber has an associated context.

    type t
    val make_root : unit -> t

    Make a new root context for a new domain.

    val destroy : t -> unit

    destroy t removes t from its cancellation context.

    val tid : t -> Ctf.id

    Cancellation

    The Cancel module describes the user's view of cancellation.

    Internally, when the user calls a primitive operation that needs to block the fiber, the Suspend callback effect is performed. This suspends the fiber and calls callback from the scheduler's context, passing it the suspended fiber's context. If the operation can be cancelled, the callback should use set_cancel_fn to register a cancellation function.

    There are two possible outcomes for the operation: it may complete normally, or it may be cancelled. If it is cancelled then the registered cancellation function is called. This function will always be called from the fiber's own domain, but care must be taken if the operation could be completed by another domain at the same time.

    Consider the case of Stream.take, which can be fulfilled by a Stream.add from another domain. We want to ensure that either the item is removed from the stream and returned to the waiting fiber, or that the operation is cancelled and the item is not removed from the stream.

    Therefore, cancelling and completing both need to update an atomic value (with Atomic.compare_and_set) so that only one can succeed. The case where Stream.take succeeds before cancellation:

    1. A fiber calls Suspend and is suspended. The callback sets a cancel function and registers a waiter on the stream.
    2. When another domain has an item, it marks the atomic as finished (making the take uncancellable) and begins resuming the fiber with the new item.
    3. If the taking fiber is cancelled after this, the cancellation must be ignored and the operation will complete successfully. Future operations will fail immediately, however.

    The case of cancellation winning the race:

    1. A fiber calls Suspend and is suspended. The callback sets a cancel function and registers a waiter on the stream.
    2. The taking fiber is cancelled. Its cancellation function is called, which updates the atomic and starts removing the waiter.
    3. If another domain tries to provide an item to the waiter as this is happening, it will try to update the atomic too and fail. The item will be given to the next waiter instead.

    Note: A fiber will only have a cancel function set while it is suspended.

    val cancellation_context : t -> Cancel.t

    cancellation_context t is t's current cancellation context.

    val set_cancel_fn : t -> (exn -> unit) -> unit

    set_cancel_fn t fn sets fn as the fiber's cancel function.

    If t's cancellation context is cancelled, the function is called. It should attempt to make the current operation finish quickly, either with a successful result or by raising the given exception.

    Just before being called, the fiber's cancel function is replaced with ignore so that fn cannot be called twice.

    On success, the cancel function is cleared automatically when Suspend.enter returns, but for single-domain operations you may like to call clear_cancel_fn manually to remove it earlier.

    fn will be called from t's domain (from the fiber that called cancel).

    fn must not switch fibers. If it did, this could happen:

    1. Another suspended fiber in the same cancellation context resumes before its cancel function is called.
    2. It enters a protected block and starts a new operation.
    3. fn returns.
    4. We cancel the protected operation.
    val clear_cancel_fn : t -> unit

    clear_cancel_fn t is set_cancel_fn t ignore.

    This must only be called from the fiber's own domain.

    For single-domain operations, it can be useful to call this manually as soon as the operation succeeds (i.e. when the fiber is added to the run-queue) to prevent the cancel function from being called.

    For operations where another domain may resume the fiber, your cancel function will need to cope with being called after the operation has succeeded. In that case you should not call clear_cancel_fn. The backend will do it automatically just before resuming your fiber.

    val get_error : t -> exn option

    get_error t is Cancel.get_error (cancellation_context t)

    \ No newline at end of file diff --git a/eio/Eio/Private/Suspend/index.html b/eio/Eio/Private/Suspend/index.html index 807dbd40b..b87f87f24 100644 --- a/eio/Eio/Private/Suspend/index.html +++ b/eio/Eio/Private/Suspend/index.html @@ -1,2 +1,2 @@ -Suspend (eio.Eio.Private.Suspend)

    Module Private.Suspend

    Suspend a fiber and enter the scheduler.

    val enter : (Fiber_context.t -> 'a Effects.enqueue -> unit) -> 'a

    enter fn suspends the calling fiber and calls fn ctx enqueue in the scheduler's context. This should arrange for enqueue to be called when the fiber should be resumed. enqueue is thread-safe and so can be called from another domain or systhread.

    ctx should be used to set a cancellation function. Otherwise, the operation is non-interruptable. If the caller's cancellation context is already cancelled, enter immediately aborts.

    val enter_unchecked : (Fiber_context.t -> 'a Effects.enqueue -> unit) -> 'a

    enter_unchecked is like enter except that it does not perform the initial check that the fiber isn't cancelled (this is useful if you want to do the check yourself, e.g. because you need to unlock a mutex if cancelled).

    \ No newline at end of file +Suspend (eio.Eio.Private.Suspend)

    Module Private.Suspend

    Suspend a fiber and enter the scheduler.

    val enter : (Fiber_context.t -> 'a Effects.enqueue -> unit) -> 'a

    enter fn suspends the calling fiber and calls fn ctx enqueue in the scheduler's context. This should arrange for enqueue to be called when the fiber should be resumed. enqueue is thread-safe and so can be called from another domain or systhread.

    ctx should be used to set a cancellation function. Otherwise, the operation is non-interruptable. If the caller's cancellation context is already cancelled, enter immediately aborts.

    val enter_unchecked : (Fiber_context.t -> 'a Effects.enqueue -> unit) -> 'a

    enter_unchecked is like enter except that it does not perform the initial check that the fiber isn't cancelled (this is useful if you want to do the check yourself, e.g. because you need to unlock a mutex if cancelled).

    \ No newline at end of file diff --git a/eio/Eio/Private/index.html b/eio/Eio/Private/index.html index 9287fbbc2..fd7780a37 100644 --- a/eio/Eio/Private/index.html +++ b/eio/Eio/Private/index.html @@ -1,2 +1,2 @@ -Private (eio.Eio.Private)

    Module Eio.Private

    API for use by the scheduler implementation.

    module Ctf : sig ... end

    This library is used to write event traces in mirage-profile's CTF format.

    module Cells : sig ... end

    A lock-free queue-like structure with suspension and cancellation.

    module Broadcast : sig ... end

    A lock-free queue of waiters that should all be resumed at once.

    module Fiber_context : sig ... end

    Every fiber has an associated context.

    module Effects : sig ... end
    module Suspend : sig ... end

    Suspend a fiber and enter the scheduler.

    module Debug : sig ... end
    module Dla : sig ... end
    \ No newline at end of file +Private (eio.Eio.Private)

    Module Eio.Private

    API for use by the scheduler implementation.

    module Ctf : sig ... end

    This library is used to write event traces in mirage-profile's CTF format.

    module Cells : sig ... end

    A lock-free queue-like structure with suspension and cancellation.

    module Broadcast : sig ... end

    A lock-free queue of waiters that should all be resumed at once.

    module Fiber_context : sig ... end

    Every fiber has an associated context.

    module Effects : sig ... end
    module Suspend : sig ... end

    Suspend a fiber and enter the scheduler.

    module Debug : sig ... end
    module Dla : sig ... end
    \ No newline at end of file diff --git a/eio/Eio/Process/Pi/index.html b/eio/Eio/Process/Pi/index.html new file mode 100644 index 000000000..df1f6dc76 --- /dev/null +++ b/eio/Eio/Process/Pi/index.html @@ -0,0 +1,12 @@ + +Pi (eio.Eio.Process.Pi)

    Module Process.Pi

    Provider Interface

    module type PROCESS = sig ... end
    type Resource.pi +=
    1. | Process : ('t, + (module PROCESS + with type t = 't + and type tag = 'tag), + [> 'tag ty ]) + Resource.pi
    val process : + (module PROCESS with type t = 't and type tag = 'tag) -> + ('t, 'tag ty) Resource.handler
    module type MGR = sig ... end
    type Resource.pi +=
    1. | Mgr : ('t, (module MGR with type t = 't and type tag = 'tag), [> 'tag mgr_ty ]) + Resource.pi
    val mgr : + (module MGR with type t = 't and type tag = 'tag) -> + ('t, 'tag mgr_ty) Resource.handler
    \ No newline at end of file diff --git a/eio/Eio/Process/Pi/module-type-MGR/index.html b/eio/Eio/Process/Pi/module-type-MGR/index.html new file mode 100644 index 000000000..f7f3a1bac --- /dev/null +++ b/eio/Eio/Process/Pi/module-type-MGR/index.html @@ -0,0 +1,16 @@ + +MGR (eio.Eio.Process.Pi.MGR)

    Module type Pi.MGR

    type tag
    type t
    val spawn : + t -> + sw:Switch.t -> + ?cwd:Fs.dir_ty Path.t -> + ?stdin:Flow.source_ty Std.r -> + ?stdout:Flow.sink_ty Std.r -> + ?stderr:Flow.sink_ty Std.r -> + ?env:string array -> + ?executable:string -> + string list -> + tag ty Std.r
    \ No newline at end of file diff --git a/eio/Eio/Process/Pi/module-type-PROCESS/index.html b/eio/Eio/Process/Pi/module-type-PROCESS/index.html new file mode 100644 index 000000000..fda21ed49 --- /dev/null +++ b/eio/Eio/Process/Pi/module-type-PROCESS/index.html @@ -0,0 +1,2 @@ + +PROCESS (eio.Eio.Process.Pi.PROCESS)

    Module type Pi.PROCESS

    type t
    type tag
    val pid : t -> int
    val await : t -> exit_status
    val signal : t -> int -> unit
    \ No newline at end of file diff --git a/eio/Eio/Process/class-mgr/index.html b/eio/Eio/Process/class-mgr/index.html deleted file mode 100644 index 32692e310..000000000 --- a/eio/Eio/Process/class-mgr/index.html +++ /dev/null @@ -1,14 +0,0 @@ - -mgr (eio.Eio.Process.mgr)

    Class Process.mgr

    A process manager capable of spawning new processes.

    method virtual pipe : sw:Eio__core.Switch.t -> - < Eio__.Flow.source - ; Eio__.Flow.close > - * < Eio__.Flow.sink - ; Eio__.Flow.close >
    method virtual spawn : sw:Eio__core.Switch.t -> - ?cwd:Eio__.Fs.dir Eio__.Path.t -> - ?stdin:Eio__.Flow.source -> - ?stdout:Eio__.Flow.sink -> - ?stderr:Eio__.Flow.sink -> - ?env:string array -> - ?executable:string -> - string list -> - t
    \ No newline at end of file diff --git a/eio/Eio/Process/class-t/index.html b/eio/Eio/Process/class-t/index.html deleted file mode 100644 index 70121db98..000000000 --- a/eio/Eio/Process/class-t/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -t (eio.Eio.Process.t)

    Class Process.t

    A process.

    method virtual pid : int
    method virtual await : exit_status
    method virtual signal : int -> unit
    \ No newline at end of file diff --git a/eio/Eio/Process/index.html b/eio/Eio/Process/index.html index e6b3bcfb3..ad5c57fd6 100644 --- a/eio/Eio/Process/index.html +++ b/eio/Eio/Process/index.html @@ -1,35 +1,38 @@ -Process (eio.Eio.Process)

    Module Eio.Process

    Managing child processes.

    Example:

    # Eio_main.run @@ fun env ->
    +Process (eio.Eio.Process)

    Module Eio.Process

    Managing child processes.

    Example:

    # Eio_main.run @@ fun env ->
       let proc_mgr = Eio.Stdenv.process_mgr env in
    -  Eio.Process.parse_out proc_mgr Eio.Buf_read.line ["echo"; "hello"]

    Status and error types

    type exit_status = [
    1. | `Exited of int
      (*

      Process exited with the given return code.

      *)
    2. | `Signaled of int
      (*

      Process was killed by the given signal.

      *)
    ]
    type status = [
    1. | exit_status
    2. | `Stopped of int
      (*

      Process was stopped (paused) by the given signal.

      *)
    ]
    val pp_status : [< status ] Fmt.t
    type error =
    1. | Executable_not_found of string
      (*

      The requested executable does not exist.

      *)
    2. | Child_error of exit_status
      (*

      The process exited with an error status.

      *)
    type Exn.err +=
    1. | E of error
    val err : error -> exn

    err e is Eio.Exn.create (E e)

    val pp_args : string list Fmt.t

    Formats a list of arguments, quoting any that might cause confusion to the reader.

    This is intended for use in error messages and logging.

    Processes

    class virtual t : object ... end

    A process.

    val pid : t -> int

    pid t is the process ID of t.

    val await : t -> exit_status

    await t waits for process t to exit and then reports the status.

    val await_exn : t -> unit

    Like await except an exception is raised if the status is not `Exited 0.

    val signal : t -> int -> unit

    signal t i sends the signal i to process t.

    If the process has already exited then this does nothing (it will not signal a different process, even if the PID has been reused).

    See Sys for the signal numbers.

    Spawning processes

    class virtual mgr : object ... end

    A process manager capable of spawning new processes.

    val spawn : + Eio.Process.parse_out proc_mgr Eio.Buf_read.line ["echo"; "hello"]

    Status and error types

    type exit_status = [
    1. | `Exited of int
      (*

      Process exited with the given return code.

      *)
    2. | `Signaled of int
      (*

      Process was killed by the given signal.

      *)
    ]
    type status = [
    1. | exit_status
    2. | `Stopped of int
      (*

      Process was stopped (paused) by the given signal.

      *)
    ]
    val pp_status : [< status ] Fmt.t
    type error =
    1. | Executable_not_found of string
      (*

      The requested executable does not exist.

      *)
    2. | Child_error of exit_status
      (*

      The process exited with an error status.

      *)
    type Exn.err +=
    1. | E of error
    val err : error -> exn

    err e is Eio.Exn.create (E e)

    val pp_args : string list Fmt.t

    Formats a list of arguments, quoting any that might cause confusion to the reader.

    This is intended for use in error messages and logging.

    Types

    type 'tag ty = [
    1. | `Process
    2. | `Platform of 'tag
    ]
    type 'a t = [> [> `Generic ] ty ] as 'a Std.r

    A process.

    type 'tag mgr_ty = [
    1. | `Process_mgr
    2. | `Platform of 'tag
    ]
    type 'a mgr = 'a Std.r constraint 'a = [> [> `Generic ] mgr_ty ]

    A process manager capable of spawning new processes.

    Processes

    val pid : _ t -> int

    pid t is the process ID of t.

    val await : _ t -> exit_status

    await t waits for process t to exit and then reports the status.

    val await_exn : ?is_success:(int -> bool) -> _ t -> unit

    Like await except an exception is raised if does not return a successful exit status.

    • parameter is_success

      Used to determine if an exit code is successful. Default is Int.equal 0.

    val signal : _ t -> int -> unit

    signal t i sends the signal i to process t.

    If the process has already exited then this does nothing (it will not signal a different process, even if the PID has been reused).

    See Sys for the signal numbers.

    val spawn : sw:Switch.t -> - mgr -> - ?cwd:Fs.dir Path.t -> - ?stdin:Flow.source -> - ?stdout:Flow.sink -> - ?stderr:Flow.sink -> + [> 'tag mgr_ty ] Std.r -> + ?cwd:Fs.dir_ty Path.t -> + ?stdin:_ Flow.source -> + ?stdout:_ Flow.sink -> + ?stderr:_ Flow.sink -> ?env:string array -> ?executable:string -> string list -> - t

    spawn ~sw mgr args creates a new child process that is connected to the switch sw.

    The child process will be sent Sys.sigkill when the switch is released.

    If the flows stdin, stdout and stderr are not backed by file descriptors then this also creates pipes and spawns fibers to copy the data as necessary. If you need more control over file descriptors, see Eio_unix.Process.

    • parameter cwd

      The current working directory of the process (default: same as parent process).

    • parameter stdin

      The flow to attach to the process's standard input (default: same as parent process).

    • parameter stdout

      A flow that the process's standard output goes to (default: same as parent process).

    • parameter stderr

      A flow that the process's standard error goes to (default: same as parent process).

    • parameter env

      The environment for the process (default: same as parent process).

    • parameter executable

      The path of the executable to run. If not given then the first item in args is used, searching $PATH for it if necessary.

    val run : - mgr -> - ?cwd:Fs.dir Path.t -> - ?stdin:Flow.source -> - ?stdout:Flow.sink -> - ?stderr:Flow.sink -> + 'tag ty Std.r

    spawn ~sw mgr args creates a new child process that is connected to the switch sw.

    The child process will be sent Sys.sigkill when the switch is released.

    If the flows stdin, stdout and stderr are not backed by file descriptors then this also creates pipes and spawns fibers to copy the data as necessary. If you need more control over file descriptors, see Eio_unix.Process.

    • parameter cwd

      The current working directory of the process (default: same as parent process).

    • parameter stdin

      The flow to attach to the process's standard input (default: same as parent process).

    • parameter stdout

      A flow that the process's standard output goes to (default: same as parent process).

    • parameter stderr

      A flow that the process's standard error goes to (default: same as parent process).

    • parameter env

      The environment for the process (default: same as parent process).

    • parameter executable

      The path of the executable to run. If not given then the first item in args is used, searching $PATH for it if necessary.

    val run : + _ mgr -> + ?cwd:_ Path.t -> + ?stdin:_ Flow.source -> + ?stdout:_ Flow.sink -> + ?stderr:_ Flow.sink -> + ?is_success:(int -> bool) -> ?env:string array -> ?executable:string -> string list -> - unit

    run does spawn followed by await_exn, with the advantage that if the process fails then the error message includes the command that failed.

    Note: If spawn needed to create extra fibers to copy stdin, etc, then it also waits for those to finish.

    val parse_out : - mgr -> + unit

    run does spawn followed by await_exn, with the advantage that if the process fails then the error message includes the command that failed.

    When is_success is provided, it is called with the exit code to determine whether it indicates success or failure. Without is_success, success requires the process to return an exit code of 0.

    Note: If spawn needed to create extra fibers to copy stdin, etc, then it also waits for those to finish.

    val parse_out : + _ mgr -> 'a Buf_read.parser -> - ?cwd:Fs.dir Path.t -> - ?stdin:Flow.source -> - ?stderr:Flow.sink -> + ?cwd:_ Path.t -> + ?stdin:_ Flow.source -> + ?stderr:_ Flow.sink -> + ?is_success:(int -> bool) -> ?env:string array -> ?executable:string -> string list -> 'a

    parse_out mgr parser args runs args and parses the child's stdout with parser.

    It also waits for the process to finish and checks its exit status is zero.

    Note that parser must consume the entire output of the process (like Buf_read.parse).

    To return all the output as a string, use Buf_read.take_all as the parser.

    This is a convenience wrapper around run, and the optional arguments have the same meanings.

    Pipes

    val pipe : sw:Switch.t -> - mgr -> - < Flow.source ; Flow.close > * < Flow.sink ; Flow.close >

    pipe ~sw mgr creates a pipe backed by the OS.

    The flows can be used by spawn without the need for extra fibers to copy the data. This can be used to connect multiple processes together.

    \ No newline at end of file + _ mgr -> + [ Flow.source_ty | Resource.close_ty ] Std.r + * [ Flow.sink_ty | Resource.close_ty ] Std.r

pipe ~sw mgr creates a pipe backed by the OS.

The flows can be used by spawn without the need for extra fibers to copy the data. This can be used to connect multiple processes together.

module Pi : sig ... end
\ No newline at end of file diff --git a/eio/Eio/Promise/index.html b/eio/Eio/Promise/index.html index 305d8bc9e..54828f0fd 100644 --- a/eio/Eio/Promise/index.html +++ b/eio/Eio/Promise/index.html @@ -1,5 +1,5 @@ -Promise (eio.Eio.Promise)

Module Eio.Promise

A promise is a placeholder for result that will arrive in the future.

Unlike lazy values, you cannot "force" promises; a promise is resolved when the maker of the promise is ready.

Promises are thread-safe and so can be shared between domains and used to communicate between them.

Example:

let promise, resolver = Promise.create () in
+Promise (eio.Eio.Promise)

Module Eio.Promise

A promise is a placeholder for result that will arrive in the future.

Unlike lazy values, you cannot "force" promises; a promise is resolved when the maker of the promise is ready.

Promises are thread-safe and so can be shared between domains and used to communicate between them.

Example:

let promise, resolver = Promise.create () in
 Fiber.both
   (fun () -> traceln "Got %d" (Promise.await promise))
   (fun () -> Promise.resolve resolver 42)
type !+'a t

An 'a t is a promise for a value of type 'a.

type !-'a u

An 'a u is a resolver for a promise of type 'a.

val create : ?label:string -> unit -> 'a t * 'a u

create () is a fresh promise/resolver pair. The promise is initially unresolved.

val create_resolved : 'a -> 'a t

create_resolved x is a promise that is already resolved with result x.

val await : 'a t -> 'a

await t blocks until t is resolved. If t is already resolved then this returns immediately.

val resolve : 'a u -> 'a -> unit

resolve u v resolves u's promise with the value v. Any threads waiting for the result will be added to the run queue.

  • raises Invalid_argument

    if u is already resolved.

val peek : 'a t -> 'a option

peek t is Some v if the promise has been resolved to v, or None otherwise. If the result is None then it may change in future, otherwise it won't. If another domain has access to the resolver then the state may have already changed by the time this call returns.

val is_resolved : 'a t -> bool

is_resolved t is Option.is_some (peek t).

Result promises

type 'a or_exn = ('a, exn) Stdlib.result t
val resolve_ok : ('a, 'b) Stdlib.result u -> 'a -> unit

resolve_ok u x is resolve u (Ok x).

val resolve_error : ('a, 'b) Stdlib.result u -> 'b -> unit

resolve_error u x is resolve u (Error x).

val await_exn : 'a or_exn -> 'a

await_exn t is like await t, but if the result is Error ex then it raises ex.

\ No newline at end of file diff --git a/eio/Eio/Resource/index.html b/eio/Eio/Resource/index.html new file mode 100644 index 000000000..d6e30b60c --- /dev/null +++ b/eio/Eio/Resource/index.html @@ -0,0 +1,8 @@ + +Resource (eio.Eio.Resource)

Module Eio.Resource

Defines the base resource type.

Resources are typically operating-system provided resources such as open files and network sockets. However, they can also be pure OCaml resources (such as mocks) or wrappers (such as an encrypted flow that wraps an unencrypted OS flow).

A resource's type shows which interfaces it supports. For example, a [source | sink] t is a resource that can be used as a source or a sink.

If you are familiar with object types, this is roughly equivalent to the type <source; sink>. We avoid using object types here as some OCaml programmers find them confusing.

Types

type ('t, -'tags) handler

A ('t, 'tags) handler can be used to look up the implementation for a type 't.

'tags is a phantom type to record which interfaces are supported.

Internally, a handler is a set of bindings.

type -'tags t =
  1. | T : ('t * ('t, 'tags) handler) -> 'tags t

A resource is a pair of a value and a handler for it.

Normally there will be convenience functions provided for using resources and you will not need to match on T yourself except when defining a new interface.

Defining new interfaces

These types and functions can be used to define new interfaces that others can implement.

When defining a new interface, you will typically provide:

  • The tags that indicate that the interface is supported (e.g. Flow.source_ty).
  • A convenience type to match all sub-types easily (e.g. Flow.source).
  • Functions allowing users to call the interface (e.g. Flow.single_read).
  • A module to let providers implement the interface (e.g. Flow.Pi).
type ('t, 'iface, 'tag) pi = ..

A provider interface describes an interface that a resource can implement.

  • 't is the type of the resource itself.
  • 'iface is the API that can be requested.
  • 'tag is the tag (or tags) indicating that the interface is supported.

For example, the value Close (of type (fd, fd -> unit, [> `Close]) pi) can be used with a resource backed by an fd, and which offers at least the `Close tag, to request its close function. Often, the API requested will be a module type, but it can be a single function as in this example.

type _ binding =
  1. | H : ('t, 'impl, 'tags) pi * 'impl -> 't binding

A binding H (pi, impl) says to use impl to implement pi.

For example: H (Close, M.close).

val handler : 't binding list -> ('t, _) handler

handler ops is a handler that looks up interfaces using the assoc list ops.

For example shutdown (module Foo) is a handler that handles the Close and Shutdown interfaces for resources of type Foo.t by using the Foo module:

let shutdown (type t) (module X : SHUTDOWN with type t = t) : (t, shutdown_ty) handler =
+  handler [
+    H (Close, X.close);
+    H (Shutdown, (module X));
+  ]

Be sure to give the return type explicitly, as this cannot be inferred.

val bindings : ('t, _) handler -> 't binding list

bindings (handler ops) = ops.

This is useful if you want to extend an interface and you already have a handler for that interface.

val get : ('t, 'tags) handler -> ('t, 'impl, 'tags) pi -> 'impl

get handler iface uses handler to get the implementation of iface.

For example:

let write (Resource.T (t, ops)) bufs =
+  let module X = (val (Resource.get ops Sink)) in
+  X.write t bufs
val get_opt : ('t, _) handler -> ('t, 'impl, _) pi -> 'impl option

get_opt is like get, but the handler need not have a compatible type. Instead, this performs a check at runtime and returns None if the interface is not supported.

Closing

Resources are usually attached to switches and closed automatically when the switch finishes. However, it can be useful to close them sooner in some cases.

type close_ty = [
  1. | `Close
]
type pi +=
  1. | Close : ('t, 't -> unit, [> close_ty ]) pi
val close : [> close_ty ] t -> unit

close t marks the resource as closed. It can no longer be used after this.

If t is already closed then this does nothing (it does not raise an exception).

Note: if an operation is currently in progress when this is called then it is not necessarily cancelled, and any underlying OS resource (such as a file descriptor) might not be closed immediately if other operations are using it. Closing a resource only prevents new operations from starting.

\ No newline at end of file diff --git a/eio/Eio/Semaphore/index.html b/eio/Eio/Semaphore/index.html index 1a90b09c5..d55e65342 100644 --- a/eio/Eio/Semaphore/index.html +++ b/eio/Eio/Semaphore/index.html @@ -1,2 +1,2 @@ -Semaphore (eio.Eio.Semaphore)

Module Eio.Semaphore

A counting semaphore.

The API is based on OCaml's Semaphore.Counting.

The difference is that when waiting for the semaphore this will switch to the next runnable fiber, whereas the stdlib one will block the whole domain.

Semaphores are thread-safe and so can be shared between domains and used to synchronise between them.

type t

The type of counting semaphores.

val make : int -> t

make n returns a new counting semaphore, with initial value n. The initial value n must be nonnegative.

  • raises Invalid_argument

    if n < 0

val release : t -> unit

release t increments the value of semaphore t. If other fibers are waiting on t, the one that has been waiting the longest is resumed.

  • raises Sys_error

    if the value of the semaphore would overflow max_int

val acquire : t -> unit

acquire t blocks the calling fiber until the value of semaphore t is not zero, then atomically decrements the value of t and returns.

val get_value : t -> int

get_value t returns the current value of semaphore t.

\ No newline at end of file +Semaphore (eio.Eio.Semaphore)

Module Eio.Semaphore

A counting semaphore.

The API is based on OCaml's Semaphore.Counting.

The difference is that when waiting for the semaphore this will switch to the next runnable fiber, whereas the stdlib one will block the whole domain.

Semaphores are thread-safe and so can be shared between domains and used to synchronise between them.

type t

The type of counting semaphores.

val make : int -> t

make n returns a new counting semaphore, with initial value n. The initial value n must be nonnegative.

  • raises Invalid_argument

    if n < 0

val release : t -> unit

release t increments the value of semaphore t. If other fibers are waiting on t, the one that has been waiting the longest is resumed.

  • raises Sys_error

    if the value of the semaphore would overflow max_int

val acquire : t -> unit

acquire t blocks the calling fiber until the value of semaphore t is not zero, then atomically decrements the value of t and returns.

val get_value : t -> int

get_value t returns the current value of semaphore t.

\ No newline at end of file diff --git a/eio/Eio/Std/index.html b/eio/Eio/Std/index.html index 47c3a4228..9e07dbd2f 100644 --- a/eio/Eio/Std/index.html +++ b/eio/Eio/Std/index.html @@ -1,5 +1,5 @@ -Std (eio.Eio.Std)

Module Eio.Std

Commonly used standard features. This module is intended to be opened.

module Promise = Promise
module Fiber = Fiber
module Switch = Switch
val traceln : +Std (eio.Eio.Std)

Module Eio.Std

Commonly used standard features. This module is intended to be opened.

module Promise = Promise
module Fiber = Fiber
module Switch = Switch
type 'a r = 'a Resource.t
val traceln : ?__POS__:(string * int * int * int) -> ('a, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> 'a

Same as Eio.traceln.

\ No newline at end of file diff --git a/eio/Eio/Stdenv/index.html b/eio/Eio/Stdenv/index.html index ca7cd420f..56a3a3df5 100644 --- a/eio/Eio/Stdenv/index.html +++ b/eio/Eio/Stdenv/index.html @@ -1,6 +1,6 @@ -Stdenv (eio.Eio.Stdenv)

Module Eio.Stdenv

The standard environment of a process.

All access to the outside world comes from running the event loop, which provides an environment (e.g. an Eio_unix.Stdenv.base).

Example:

let () =
+Stdenv (eio.Eio.Stdenv)

Module Eio.Stdenv

The standard environment of a process.

All access to the outside world comes from running the event loop, which provides an environment (e.g. an Eio_unix.Stdenv.base).

Example:

let () =
   Eio_main.run @@ fun env ->
   Eio.Path.with_open_dir env#fs "/srv/www" @@ fun www ->
   serve_files www
-    ~net:env#net

Standard streams

To use these, see Flow.

val stdin : < stdin : Flow.source as 'a.. > -> 'a
val stdout : < stdout : Flow.sink as 'a.. > -> 'a
val stderr : < stderr : Flow.sink as 'a.. > -> 'a

File-system access

To use these, see Path.

val cwd : < cwd : _ Path.t as 'a.. > -> 'a

cwd t is the current working directory of the process (this may change over time if the process does a "chdir" operation, which is not recommended).

val fs : < fs : _ Path.t as 'a.. > -> 'a

fs t is the process's full access to the filesystem.

Paths can be absolute or relative (to the current working directory). Using relative paths with this is similar to using them with cwd, except that this will follow ".." and symlinks to other parts of the filesystem.

fs is useful for handling paths passed in by the user.

Network

To use this, see Net.

val net : < net : Net.t as 'a.. > -> 'a

net t gives access to the process's network namespace.

Processes

To use this, see Process.

val process_mgr : < process_mgr : Process.mgr as 'a.. > -> 'a

process_mgr t allows you to manage child processes.

Domains (using multiple CPU cores)

To use this, see Domain_manager.

val domain_mgr : < domain_mgr : Domain_manager.t as 'a.. > -> 'a

domain_mgr t allows running code on other cores.

Time

To use this, see Time.

val clock : < clock : Time.clock as 'a.. > -> 'a

clock t is the system clock (used to get the current time and date).

val mono_clock : < mono_clock : Time.Mono.t as 'a.. > -> 'a

mono_clock t is a monotonic clock (used for measuring intervals).

Randomness

val secure_random : < secure_random : Flow.source as 'a.. > -> 'a

secure_random t is an infinite source of random bytes suitable for cryptographic purposes.

Debugging

val debug : < debug : < Debug.t.. > as 'a.. > -> 'a

debug t provides privileged controls for debugging.

val backend_id : < backend_id : string.. > -> string

backend_id t provides the name of the backend being used.

The possible values are the same as the possible values of the "EIO_BACKEND" environment variable used by Eio_main.run.

\ No newline at end of file + ~net:env#net

Standard streams

To use these, see Flow.

val stdin : < stdin : _ Flow.source as 'a.. > -> 'a
val stdout : < stdout : _ Flow.sink as 'a.. > -> 'a
val stderr : < stderr : _ Flow.sink as 'a.. > -> 'a

File-system access

To use these, see Path.

val cwd : < cwd : _ Path.t as 'a.. > -> 'a

cwd t is the current working directory of the process (this may change over time if the process does a "chdir" operation, which is not recommended).

val fs : < fs : _ Path.t as 'a.. > -> 'a

fs t is the process's full access to the filesystem.

Paths can be absolute or relative (to the current working directory). Using relative paths with this is similar to using them with cwd, except that this will follow ".." and symlinks to other parts of the filesystem.

fs is useful for handling paths passed in by the user.

Network

To use this, see Net.

val net : < net : _ Net.t as 'a.. > -> 'a

net t gives access to the process's network namespace.

Processes

To use this, see Process.

val process_mgr : < process_mgr : _ Process.mgr as 'a.. > -> 'a

process_mgr t allows you to manage child processes.

Domains (using multiple CPU cores)

To use this, see Domain_manager.

val domain_mgr : < domain_mgr : _ Domain_manager.t as 'a.. > -> 'a

domain_mgr t allows running code on other cores.

Time

To use this, see Time.

val clock : < clock : _ Time.clock as 'a.. > -> 'a

clock t is the system clock (used to get the current time and date).

val mono_clock : < mono_clock : _ Time.Mono.t as 'a.. > -> 'a

mono_clock t is a monotonic clock (used for measuring intervals).

Randomness

val secure_random : < secure_random : _ Flow.source as 'a.. > -> 'a

secure_random t is an infinite source of random bytes suitable for cryptographic purposes.

Debugging

val debug : < debug : < Debug.t.. > as 'a.. > -> 'a

debug t provides privileged controls for debugging.

val backend_id : < backend_id : string.. > -> string

backend_id t provides the name of the backend being used.

The possible values are the same as the possible values of the "EIO_BACKEND" environment variable used by Eio_main.run.

\ No newline at end of file diff --git a/eio/Eio/Stream/index.html b/eio/Eio/Stream/index.html index 26965e624..bfcb6c8ef 100644 --- a/eio/Eio/Stream/index.html +++ b/eio/Eio/Stream/index.html @@ -1,5 +1,5 @@ -Stream (eio.Eio.Stream)

Module Eio.Stream

A stream/queue.

Reading from an empty queue will wait until an item is available. Writing to a full queue will wait until there is space.

Example:

let t = Stream.create 100 in
+Stream (eio.Eio.Stream)

Module Eio.Stream

A stream/queue.

Reading from an empty queue will wait until an item is available. Writing to a full queue will wait until there is space.

Example:

let t = Stream.create 100 in
 Stream.add t 1;
 Stream.add t 2;
 assert (Stream.take t = 1);
diff --git a/eio/Eio/Switch/index.html b/eio/Eio/Switch/index.html
index fa776274e..e75470369 100644
--- a/eio/Eio/Switch/index.html
+++ b/eio/Eio/Switch/index.html
@@ -1,5 +1,5 @@
 
-Switch (eio.Eio.Switch)

Module Eio.Switch

Grouping fibers and other resources so they can be turned off together.

Many resources in Eio (such as fibers and file handles) require a switch to be provided when they are created. The resource cannot outlive its switch.

If a function wants to create such resources, and was not passed a switch as an argument, it will need to create a switch using run. This doesn't return until all resources attached to it have been freed, preventing the function from leaking resources.

Any function creating resources that outlive it needs to be given a switch by its caller.

Each switch includes its own Cancel.t context. Calling fail cancels all fibers attached to the switch and, once they have exited, reports the error.

Note: this concept is known as a "nursery" or "bundle" in some other systems.

Example:

Switch.run (fun sw ->
+Switch (eio.Eio.Switch)

Module Eio.Switch

Grouping fibers and other resources so they can be turned off together.

Many resources in Eio (such as fibers and file handles) require a switch to be provided when they are created. The resource cannot outlive its switch.

If a function wants to create such resources, and was not passed a switch as an argument, it will need to create a switch using run. This doesn't return until all resources attached to it have been freed, preventing the function from leaking resources.

Any function creating resources that outlive it needs to be given a switch by its caller.

Each switch includes its own Cancel.t context. Calling fail cancels all fibers attached to the switch and, once they have exited, reports the error.

Note: this concept is known as a "nursery" or "bundle" in some other systems.

Example:

Switch.run (fun sw ->
    let flow = Dir.open_in ~sw dir "myfile.txt" in
    ...
 );
diff --git a/eio/Eio/Time/Mono/class-t/index.html b/eio/Eio/Time/Mono/class-t/index.html
deleted file mode 100644
index f41df0c58..000000000
--- a/eio/Eio/Time/Mono/class-t/index.html
+++ /dev/null
@@ -1,2 +0,0 @@
-
-t (eio.Eio.Time.Mono.t)

Class Mono.t

inherit Mtime.t clock_base
\ No newline at end of file diff --git a/eio/Eio/Time/Mono/index.html b/eio/Eio/Time/Mono/index.html index 1fec46554..8dc715418 100644 --- a/eio/Eio/Time/Mono/index.html +++ b/eio/Eio/Time/Mono/index.html @@ -1,2 +1,2 @@ -Mono (eio.Eio.Time.Mono)

Module Time.Mono

Monotonic clocks.

Monotonic clocks are unaffected by corrections to the real-time clock, and so are a better choice for timeouts or measuring intervals, where the absolute time doesn't matter.

A monotonic clock may or may not include time while the computer is suspended.

class virtual t : object ... end
val now : t -> Mtime.t

now t is the current time according to t.

val sleep_until : t -> Mtime.t -> unit

sleep_until t time waits until time before returning.

val sleep : t -> float -> unit

sleep t d waits for d seconds.

val sleep_span : t -> Mtime.span -> unit

sleep_span t d waits for duration d.

\ No newline at end of file +Mono (eio.Eio.Time.Mono)

Module Time.Mono

Monotonic clocks.

Monotonic clocks are unaffected by corrections to the real-time clock, and so are a better choice for timeouts or measuring intervals, where the absolute time doesn't matter.

A monotonic clock may or may not include time while the computer is suspended.

type ty = Mtime.t clock_ty
type 'a t = [> ty ] as 'a Std.r
val now : _ t -> Mtime.t

now t is the current time according to t.

val sleep_until : _ t -> Mtime.t -> unit

sleep_until t time waits until time before returning.

val sleep : _ t -> float -> unit

sleep t d waits for d seconds.

val sleep_span : _ t -> Mtime.span -> unit

sleep_span t d waits for duration d.

\ No newline at end of file diff --git a/eio/Eio/Time/Pi/index.html b/eio/Eio/Time/Pi/index.html new file mode 100644 index 000000000..8ce74fda2 --- /dev/null +++ b/eio/Eio/Time/Pi/index.html @@ -0,0 +1,9 @@ + +Pi (eio.Eio.Time.Pi)

Module Time.Pi

module type CLOCK = sig ... end
type Resource.pi +=
  1. | Clock : ('t, + (module CLOCK + with type t = 't + and type time = 'time), + [> 'time clock_ty ]) + Resource.pi
val clock : + (module CLOCK with type t = 't and type time = 'time) -> + ('t, [> 'time clock_ty ]) Resource.handler
\ No newline at end of file diff --git a/eio/Eio/Time/Pi/module-type-CLOCK/index.html b/eio/Eio/Time/Pi/module-type-CLOCK/index.html new file mode 100644 index 000000000..d69ec7d28 --- /dev/null +++ b/eio/Eio/Time/Pi/module-type-CLOCK/index.html @@ -0,0 +1,2 @@ + +CLOCK (eio.Eio.Time.Pi.CLOCK)

Module type Pi.CLOCK

type t
type time
val now : t -> time
val sleep_until : t -> time -> unit
\ No newline at end of file diff --git a/eio/Eio/Time/Timeout/index.html b/eio/Eio/Time/Timeout/index.html index 52138fc0e..3efe617f1 100644 --- a/eio/Eio/Time/Timeout/index.html +++ b/eio/Eio/Time/Timeout/index.html @@ -1,5 +1,5 @@ -Timeout (eio.Eio.Time.Timeout)

Module Time.Timeout

Timeout values.

type t
val v : Mono.t -> Mtime.Span.t -> t

v clock duration is a timeout of duration, as measured by clock. Internally, this is just the tuple (clock, duration).

val seconds : Mono.t -> float -> t

seconds clock duration is a timeout of duration seconds, as measured by clock.

val none : t

none is an infinite timeout.

val run : +Timeout (eio.Eio.Time.Timeout)

Module Time.Timeout

Timeout values.

type t
val v : _ Mono.t -> Mtime.Span.t -> t

v clock duration is a timeout of duration, as measured by clock. Internally, this is just the tuple (clock, duration).

val seconds : _ Mono.t -> float -> t

seconds clock duration is a timeout of duration seconds, as measured by clock.

val none : t

none is an infinite timeout.

val run : t -> (unit -> ('a, 'e) Stdlib.result) -> ('a, [> `Timeout ] as 'e) Stdlib.result

run t fn runs fn () but cancels it if it takes longer than allowed by timeout t.

val run_exn : t -> (unit -> 'a) -> 'a

run_exn t fn runs fn () but cancels it if it takes longer than allowed by timeout t, raising exception Timeout.

val pp : t Fmt.t

pp formats a timeout as a duration (e.g. "5s"). This is intended for use in error messages and logging and is rounded.

\ No newline at end of file diff --git a/eio/Eio/Time/class-clock/index.html b/eio/Eio/Time/class-clock/index.html deleted file mode 100644 index 545898d0a..000000000 --- a/eio/Eio/Time/class-clock/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -clock (eio.Eio.Time.clock)

Class Time.clock

inherit float clock_base
\ No newline at end of file diff --git a/eio/Eio/Time/class-clock_base/index.html b/eio/Eio/Time/class-clock_base/index.html deleted file mode 100644 index e67320031..000000000 --- a/eio/Eio/Time/class-clock_base/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -clock_base (eio.Eio.Time.clock_base)

Class Time.clock_base

method virtual now : 'a
method virtual sleep_until : 'a -> unit
\ No newline at end of file diff --git a/eio/Eio/Time/index.html b/eio/Eio/Time/index.html index b775d47aa..8c9096a35 100644 --- a/eio/Eio/Time/index.html +++ b/eio/Eio/Time/index.html @@ -1,6 +1,6 @@ -Time (eio.Eio.Time)

Module Eio.Time

Clocks, time, sleeping and timeouts.

class virtual 'a clock_base : object ... end
class virtual clock : object ... end
val now : clock -> float

now t is the current time since 00:00:00 GMT, Jan. 1, 1970 - in seconds - according to t.

val sleep_until : clock -> float -> unit

sleep_until t time waits until the given time is reached.

val sleep : clock -> float -> unit

sleep t d waits for d seconds.

module Mono : sig ... end

Monotonic clocks.

Timeouts

exception Timeout
val with_timeout : - clock -> +Time (eio.Eio.Time)

Module Eio.Time

Clocks, time, sleeping and timeouts.

type 'a clock_ty = [
  1. | `Clock of 'a
]
type 'a clock_base = 'a Std.r constraint 'a = [> _ clock_ty ]
type 'a clock = [> float clock_ty ] as 'a Std.r
val now : _ clock -> float

now t is the current time since 00:00:00 GMT, Jan. 1, 1970 - in seconds - according to t.

val sleep_until : _ clock -> float -> unit

sleep_until t time waits until the given time is reached.

val sleep : _ clock -> float -> unit

sleep t d waits for d seconds.

module Mono : sig ... end

Monotonic clocks.

Timeouts

exception Timeout
val with_timeout : + _ clock -> float -> (unit -> ('a, 'e) Stdlib.result) -> - ('a, [> `Timeout ] as 'e) Stdlib.result

with_timeout clock d fn runs fn () but cancels it after d seconds.

val with_timeout_exn : clock -> float -> (unit -> 'a) -> 'a

with_timeout_exn clock d fn runs fn () but cancels it after d seconds, raising exception Timeout.

module Timeout : sig ... end

Timeout values.

\ No newline at end of file + ('a, [> `Timeout ] as 'e) Stdlib.result

with_timeout clock d fn runs fn () but cancels it after d seconds.

val with_timeout_exn : _ clock -> float -> (unit -> 'a) -> 'a

with_timeout_exn clock d fn runs fn () but cancels it after d seconds, raising exception Timeout.

module Timeout : sig ... end

Timeout values.

module Pi : sig ... end
\ No newline at end of file diff --git a/eio/Eio/index.html b/eio/Eio/index.html index 669a958eb..a69f4f28f 100644 --- a/eio/Eio/index.html +++ b/eio/Eio/index.html @@ -1,5 +1,5 @@ -Eio (eio.Eio)

Module Eio

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

module Switch : sig ... end

Grouping fibers and other resources so they can be turned off together.

module Promise : sig ... end

A promise is a placeholder for result that will arrive in the future.

module Fiber : sig ... end

A fiber is a light-weight thread.

module Semaphore : sig ... end

A counting semaphore.

module Mutex : sig ... end

Mutual exclusion.

module Condition : sig ... end

Waiting for a condition to become true.

module Stream : sig ... end

A stream/queue.

module Cancel : sig ... end

Cancelling fibers.

module Std : sig ... end

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).

module Generic : sig ... end

A base class for objects that can be queried at runtime for extra features.

module Flow : sig ... end

Byte streams.

module Buf_read : sig ... end

Buffered input and parsing

module Buf_write : sig ... end

Buffered output

module Net : sig ... end

Networking.

module Process : sig ... end

Managing child processes.

module Domain_manager : sig ... end

Parallel computation across multiple CPU cores.

module Time : sig ... end

Clocks, time, sleeping and timeouts.

module File : sig ... end

Operations on open files.

module Fs : sig ... end

File-system types.

module Path : sig ... end

Accessing paths on a file-system.

module Debug : sig ... end

Control over debugging.

module Stdenv : sig ... end

The standard environment of a process.

Errors and Debugging

exception Io of Exn.err * Exn.context
val traceln : +Eio (eio.Eio)

Module Eio

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

module Switch : sig ... end

Grouping fibers and other resources so they can be turned off together.

module Promise : sig ... end

A promise is a placeholder for result that will arrive in the future.

module Fiber : sig ... end

A fiber is a light-weight thread.

module Semaphore : sig ... end

A counting semaphore.

module Mutex : sig ... end

Mutual exclusion.

module Condition : sig ... end

Waiting for a condition to become true.

module Stream : sig ... end

A stream/queue.

module Lazy : sig ... end

Delayed evaluation.

module Pool : sig ... end

A pool of resources.

module Cancel : sig ... end

Cancelling fibers.

module Std : sig ... end

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 a provider (Pi) module to allow defining your own implementations.

The system resources are available from the environment argument provided by your event loop (e.g. Eio_main.run).

module Resource : sig ... end

Defines the base resource type.

module Flow : sig ... end

Byte streams.

module Buf_read : sig ... end

Buffered input and parsing

module Buf_write : sig ... end

Buffered output

module Net : sig ... end

Networking.

module Process : sig ... end

Managing child processes.

module Domain_manager : sig ... end

Parallel computation across multiple CPU cores.

module Time : sig ... end

Clocks, time, sleeping and timeouts.

module File : sig ... end

Operations on open files.

module Fs : sig ... end

File-system types.

module Path : sig ... end

Accessing paths on a file-system.

module Debug : sig ... end

Control over debugging.

module Stdenv : sig ... end

The standard environment of a process.

Errors and Debugging

exception Io of Exn.err * Exn.context
val traceln : ?__POS__:(string * int * int * int) -> ('a, Stdlib.Format.formatter, unit, unit) Stdlib.format4 -> 'a

traceln 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;
diff --git a/eio/Eio__core/.dummy b/eio/Eio__core/.dummy
deleted file mode 100644
index e69de29bb..000000000
diff --git a/eio/Eio__core/index.html b/eio/Eio__core/index.html
index 859a888c1..5c00bc83f 100644
--- a/eio/Eio__core/index.html
+++ b/eio/Eio__core/index.html
@@ -1,2 +1,2 @@
 
-Eio__core (eio.Eio__core)

Module Eio__core

\ No newline at end of file +Eio__core (eio.Eio__core)

Module Eio__core

\ No newline at end of file diff --git a/eio/Eio_mock/.dummy b/eio/Eio_mock/.dummy deleted file mode 100644 index e69de29bb..000000000 diff --git a/eio/Eio_mock/Action/index.html b/eio/Eio_mock/Action/index.html index 86d15fff1..5d2775cd2 100644 --- a/eio/Eio_mock/Action/index.html +++ b/eio/Eio_mock/Action/index.html @@ -1,2 +1,2 @@ -Action (eio.Eio_mock.Action)

Module Eio_mock.Action

Actions that can be performed by mock handlers.

type 'a t = [
  1. | `Return of 'a
    (*

    Immediately return a value

    *)
  2. | `Raise of exn
    (*

    Raise an exception

    *)
  3. | `Await of 'a Eio.Promise.or_exn
    (*

    Wait for a promise to resolve

    *)
  4. | `Yield_then of 'a t
    (*

    Call Eio.Fiber.yield, then perform an action

    *)
  5. | `Run of unit -> 'a
    (*

    Run any code you like.

    *)
]
val run : 'a t -> 'a

run t performs action t and returns the result.

val map : ('a -> 'b) -> 'a t -> 'b t

run (map f t) = f (run t).

\ No newline at end of file +Action (eio.Eio_mock.Action)

Module Eio_mock.Action

Actions that can be performed by mock handlers.

type 'a t = [
  1. | `Return of 'a
    (*

    Immediately return a value

    *)
  2. | `Raise of exn
    (*

    Raise an exception

    *)
  3. | `Await of 'a Eio.Promise.or_exn
    (*

    Wait for a promise to resolve

    *)
  4. | `Yield_then of 'a t
    (*

    Call Eio.Fiber.yield, then perform an action

    *)
  5. | `Run of unit -> 'a
    (*

    Run any code you like.

    *)
]
val run : 'a t -> 'a

run t performs action t and returns the result.

val map : ('a -> 'b) -> 'a t -> 'b t

run (map f t) = f (run t).

\ No newline at end of file diff --git a/eio/Eio_mock/Backend/index.html b/eio/Eio_mock/Backend/index.html index 2148112bd..61a86c35e 100644 --- a/eio/Eio_mock/Backend/index.html +++ b/eio/Eio_mock/Backend/index.html @@ -1,2 +1,2 @@ -Backend (eio.Eio_mock.Backend)

Module Eio_mock.Backend

A dummy Eio backend with no actual IO.

This backend does not support the use of multiple domains or systhreads, but the tradeoff is that it can reliably detect deadlock, because if the run queue is empty then it knows that no wake up event can be coming from elsewhere.

exception Deadlock_detected
val run : (unit -> 'a) -> 'a

run fn runs an event loop and then calls fn env within it.

  • raises Deadlock_detected

    if the run queue becomes empty but fn hasn't returned.

\ No newline at end of file +Backend (eio.Eio_mock.Backend)

Module Eio_mock.Backend

A dummy Eio backend with no actual IO.

This backend does not support the use of multiple domains or systhreads, but the tradeoff is that it can reliably detect deadlock, because if the run queue is empty then it knows that no wake up event can be coming from elsewhere.

exception Deadlock_detected
val run : (unit -> 'a) -> 'a

run fn runs an event loop and then calls fn env within it.

  • raises Deadlock_detected

    if the run queue becomes empty but fn hasn't returned.

\ No newline at end of file diff --git a/eio/Eio_mock/Clock/Mono/index.html b/eio/Eio_mock/Clock/Mono/index.html index 64034f52c..e2fe0ba33 100644 --- a/eio/Eio_mock/Clock/Mono/index.html +++ b/eio/Eio_mock/Clock/Mono/index.html @@ -1,5 +1,2 @@ -Mono (eio.Eio_mock.Clock.Mono)

Module Clock.Mono

type t = - < Mtime.t Eio.Time.clock_base - ; advance : unit - ; set_time : Mtime.t -> unit >
val make : unit -> t

make () is a new clock.

The time is initially set to 0.0 and doesn't change except when you call advance or set_time.

val advance : t -> unit

advance t sets the time to the next scheduled event (adding any due fibers to the run queue).

  • raises Invalid_argument

    if nothing is scheduled.

val set_time : t -> Mtime.t -> unit

set_time t time sets the time to time (adding any due fibers to the run queue).

\ No newline at end of file +Mono (eio.Eio_mock.Clock.Mono)

Module Clock.Mono

type t = Mtime.t ty Eio.Std.r
val make : unit -> t

make () is a new clock.

The time is initially set to 0.0 and doesn't change except when you call advance or set_time.

val advance : t -> unit

advance t sets the time to the next scheduled event (adding any due fibers to the run queue).

  • raises Invalid_argument

    if nothing is scheduled.

val set_time : t -> Mtime.t -> unit

set_time t time sets the time to time (adding any due fibers to the run queue).

\ No newline at end of file diff --git a/eio/Eio_mock/Clock/index.html b/eio/Eio_mock/Clock/index.html index 7e8b62cdc..82e6bd1da 100644 --- a/eio/Eio_mock/Clock/index.html +++ b/eio/Eio_mock/Clock/index.html @@ -1,5 +1,2 @@ -Clock (eio.Eio_mock.Clock)

Module Eio_mock.Clock

A mock Eio.Time clock for testing timeouts.

module type S = sig ... end
include S with type time := float
type t = - < float Eio.Time.clock_base - ; advance : unit - ; set_time : float -> unit >
val make : unit -> t

make () is a new clock.

The time is initially set to 0.0 and doesn't change except when you call advance or set_time.

val advance : t -> unit

advance t sets the time to the next scheduled event (adding any due fibers to the run queue).

  • raises Invalid_argument

    if nothing is scheduled.

val set_time : t -> float -> unit

set_time t time sets the time to time (adding any due fibers to the run queue).

module Mono : S with type time := Mtime.t
\ No newline at end of file +Clock (eio.Eio_mock.Clock)

Module Eio_mock.Clock

A mock Eio.Time clock for testing timeouts.

type 'time ty = [
  1. | `Mock
  2. | 'time Eio.Time.clock_ty
]
module type S = sig ... end
include S with type time := float
type t = float ty Eio.Std.r
val make : unit -> t

make () is a new clock.

The time is initially set to 0.0 and doesn't change except when you call advance or set_time.

val advance : t -> unit

advance t sets the time to the next scheduled event (adding any due fibers to the run queue).

  • raises Invalid_argument

    if nothing is scheduled.

val set_time : t -> float -> unit

set_time t time sets the time to time (adding any due fibers to the run queue).

module Mono : S with type time := Mtime.t
\ No newline at end of file diff --git a/eio/Eio_mock/Clock/module-type-S/index.html b/eio/Eio_mock/Clock/module-type-S/index.html index 59cd5d8df..c60e94e62 100644 --- a/eio/Eio_mock/Clock/module-type-S/index.html +++ b/eio/Eio_mock/Clock/module-type-S/index.html @@ -1,5 +1,2 @@ -S (eio.Eio_mock.Clock.S)

Module type Clock.S

type time
type t = - < time Eio.Time.clock_base - ; advance : unit - ; set_time : time -> unit >
val make : unit -> t

make () is a new clock.

The time is initially set to 0.0 and doesn't change except when you call advance or set_time.

val advance : t -> unit

advance t sets the time to the next scheduled event (adding any due fibers to the run queue).

  • raises Invalid_argument

    if nothing is scheduled.

val set_time : t -> time -> unit

set_time t time sets the time to time (adding any due fibers to the run queue).

\ No newline at end of file +S (eio.Eio_mock.Clock.S)

Module type Clock.S

type time
type t = time ty Eio.Std.r
val make : unit -> t

make () is a new clock.

The time is initially set to 0.0 and doesn't change except when you call advance or set_time.

val advance : t -> unit

advance t sets the time to the next scheduled event (adding any due fibers to the run queue).

  • raises Invalid_argument

    if nothing is scheduled.

val set_time : t -> time -> unit

set_time t time sets the time to time (adding any due fibers to the run queue).

\ No newline at end of file diff --git a/eio/Eio_mock/Domain_manager/index.html b/eio/Eio_mock/Domain_manager/index.html new file mode 100644 index 000000000..2d942e885 --- /dev/null +++ b/eio/Eio_mock/Domain_manager/index.html @@ -0,0 +1,2 @@ + +Domain_manager (eio.Eio_mock.Domain_manager)

Module Eio_mock.Domain_manager

A mock Eio.Domain_manager that runs everything in a single domain.

val create : unit -> Eio.Domain_manager.ty Eio.Std.r

create () is a mock domain manager.

When asked to run a new Eio domain, it just runs it in the parent domain. It runs the function in a context where id is a fresh domain ID (assigned sequentially starting from 1).

val run : (Eio.Domain_manager.ty Eio.Std.r -> 'a) -> 'a

run fn runs fn dm, where dm is a new fake domain manager. It also runs with_domain_tracing to display domain IDs in trace output.

fn itself runs with id set to "0".

val id : string Eio.Std.Fiber.key

id is used to get or set the current fake domain's ID.

This is used in traceln output.

val with_domain_tracing : (unit -> 'a) -> 'a

with_domain_tracing fn runs fn () with a modified traceln function that prefixes the current id (if any) to each trace message.

\ No newline at end of file diff --git a/eio/Eio_mock/Flow/index.html b/eio/Eio_mock/Flow/index.html index cd4d23535..e07ab140b 100644 --- a/eio/Eio_mock/Flow/index.html +++ b/eio/Eio_mock/Flow/index.html @@ -1,8 +1,2 @@ -Flow (eio.Eio_mock.Flow)

Module Eio_mock.Flow

Mock Eio.Flow sources and sinks.

type copy_method = [
  1. | `Read_into
    (*

    Use the source's read_into method (the default).

    *)
  2. | `Read_source_buffer
    (*

    Use the Eio.Flow.Read_source_buffer optimisation.

    *)
]
type t = - < Eio.Flow.two_way - ; Eio.Flow.close - ; on_read : string Handler.t - ; on_copy_bytes : int Handler.t - ; set_copy_method : copy_method -> unit - ; attach_to_switch : Eio.Switch.t -> unit >
val make : ?pp:string Fmt.t -> string -> t

make label is a mock Eio flow. It can be used as a source, sink, or two-way flow.

  • parameter pp

    Printer to use to display the data.

val on_read : t -> string Handler.actions -> unit

on_read t actions configures the values to return from the mock's read function.

val on_copy_bytes : t -> int Handler.actions -> unit

on_copy_bytes t actions configures the number of bytes to copy in each iteration.

val set_copy_method : t -> copy_method -> unit

set_copy_method t m configures t to use the given method to read from a source during a copy operation.

\ No newline at end of file +Flow (eio.Eio_mock.Flow)

Module Eio_mock.Flow

Mock Eio.Flow sources and sinks.

type copy_method = [
  1. | `Read_into
    (*

    Use the source's read_into method (the default).

    *)
  2. | `Read_source_buffer
    (*

    Use the Eio.Flow.Read_source_buffer optimisation.

    *)
]
type ty = [ `Generic | `Mock ] Eio.Net.stream_socket_ty
type t = ty Eio.Std.r
val make : ?pp:string Fmt.t -> string -> t

make label is a mock Eio flow. It can be used as a source, sink, or two-way flow.

  • parameter pp

    Printer to use to display the data.

val on_read : t -> string Handler.actions -> unit

on_read t actions configures the values to return from the mock's read function.

val on_copy_bytes : t -> int Handler.actions -> unit

on_copy_bytes t actions configures the number of bytes to copy in each iteration.

val set_copy_method : t -> copy_method -> unit

set_copy_method t m configures t to use the given method to read from a source during a copy operation.

\ No newline at end of file diff --git a/eio/Eio_mock/Handler/index.html b/eio/Eio_mock/Handler/index.html index 7b736ebf6..a6b088b21 100644 --- a/eio/Eio_mock/Handler/index.html +++ b/eio/Eio_mock/Handler/index.html @@ -1,2 +1,2 @@ -Handler (eio.Eio_mock.Handler)

Module Eio_mock.Handler

Control how a mock responds.

This module is mostly useful when writing custom mocks. Individual mocks usually provide convenience wrappers around this.

type 'a t

A handler that provides values of type 'a.

type 'a actions = 'a Action.t list
val make : 'a Action.t -> 'a t

make default_action is a new handler that initially always runs default_action.

val set_handler : 'a t -> (unit -> 'a) -> unit

set_handler t fn sets (replaces) the function to be called whenever the handler is run.

val seq : 'a t -> 'a actions -> unit

seq t actions sets a handler function that performs the next action in actions on each call. When there are no more actions, it runs the default handler.

val run : 'a t -> 'a

run t is used by mocks to run their handlers.

val run_default_action : 'a t -> 'a

run_default_action t runs the default handler passed to make.

\ No newline at end of file +Handler (eio.Eio_mock.Handler)

Module Eio_mock.Handler

Control how a mock responds.

This module is mostly useful when writing custom mocks. Individual mocks usually provide convenience wrappers around this.

type 'a t

A handler that provides values of type 'a.

type 'a actions = 'a Action.t list
val make : 'a Action.t -> 'a t

make default_action is a new handler that initially always runs default_action.

val set_handler : 'a t -> (unit -> 'a) -> unit

set_handler t fn sets (replaces) the function to be called whenever the handler is run.

val seq : 'a t -> 'a actions -> unit

seq t actions sets a handler function that performs the next action in actions on each call. When there are no more actions, it runs the default handler.

val run : 'a t -> 'a

run t is used by mocks to run their handlers.

val run_default_action : 'a t -> 'a

run_default_action t runs the default handler passed to make.

\ No newline at end of file diff --git a/eio/Eio_mock/Net/index.html b/eio/Eio_mock/Net/index.html index 0e00b0255..0a3b90f66 100644 --- a/eio/Eio_mock/Net/index.html +++ b/eio/Eio_mock/Net/index.html @@ -1,16 +1,6 @@ -Net (eio.Eio_mock.Net)

Module Eio_mock.Net

Mock Eio.Net networks and sockets.

type t = - < Eio.Net.t - ; on_listen : Eio.Net.listening_socket Handler.t - ; on_connect : Eio.Net.stream_socket Handler.t - ; on_datagram_socket : Eio.Net.datagram_socket Handler.t - ; on_getaddrinfo : Eio.Net.Sockaddr.t list Handler.t - ; on_getnameinfo : (string * string) Handler.t >
type listening_socket = - < Eio.Net.listening_socket - ; on_accept : (Flow.t * Eio.Net.Sockaddr.stream) Handler.t >
val make : string -> t

make label is a new mock network.

val on_connect : t -> < Eio.Net.stream_socket.. > Handler.actions -> unit

on_connect t actions configures what to do when a client tries to connect somewhere.

val on_listen : t -> Eio.Net.listening_socket Handler.actions -> unit

on_listen t actions configures what to do when a server starts listening for incoming connections.

val on_datagram_socket : - t -> - < Eio.Net.datagram_socket.. > Handler.actions -> - unit

on_datagram_socket t actions configures how to create datagram sockets.

val on_getaddrinfo : t -> Eio.Net.Sockaddr.t list Handler.actions -> unit
val on_getnameinfo : t -> (string * string) Handler.actions -> unit
val listening_socket : string -> listening_socket

listening_socket label can be configured to provide mock connections.

val on_accept : +Net (eio.Eio_mock.Net)

Module Eio_mock.Net

Mock Eio.Net networks and sockets.

type t = [ `Generic | `Mock ] Eio.Net.ty Eio.Std.r
type listening_socket = + [ `Generic | `Mock ] Eio.Net.listening_socket_ty Eio.Std.r
val make : string -> t

make label is a new mock network.

val on_connect : t -> _ Eio.Net.stream_socket Handler.actions -> unit

on_connect t actions configures what to do when a client tries to connect somewhere.

val on_listen : t -> _ Eio.Net.listening_socket Handler.actions -> unit

on_listen t actions configures what to do when a server starts listening for incoming connections.

val on_datagram_socket : t -> _ Eio.Net.datagram_socket Handler.actions -> unit

on_datagram_socket t actions configures how to create datagram sockets.

val on_getaddrinfo : t -> Eio.Net.Sockaddr.t list Handler.actions -> unit
val on_getnameinfo : t -> (string * string) Handler.actions -> unit
val listening_socket : string -> listening_socket

listening_socket label can be configured to provide mock connections.

on_accept socket actions configures how to respond when the server calls "accept".

\ No newline at end of file diff --git a/eio/Eio_mock/index.html b/eio/Eio_mock/index.html index 5ff89acbc..4827edba5 100644 --- a/eio/Eio_mock/index.html +++ b/eio/Eio_mock/index.html @@ -1,5 +1,5 @@ -Eio_mock (eio.Eio_mock)

Module Eio_mock

Mocks for testing.

When testing an Eio program it is often convenient to use mock resources rather than real OS-provided ones. This allows precise control over the test, such as adding delays or simulated faults. You can always just implement the various Eio types directly, but this module provides some convenient pre-built mocks, and some helpers for creating your own mocks.

Mocks typically use Eio.traceln to record how they were used. This output can be recorded and compared against a known-good copy using e.g. ocaml-mdx.

Mocks may require configuration. For example, a source flow needs to know what data to return when the application reads from it. This can be done using the various on_* functions. For example:

let stdin = Eio_mock.Flow.make "stdin" in
+Eio_mock (eio.Eio_mock)

Module Eio_mock

Mocks for testing.

When testing an Eio program it is often convenient to use mock resources rather than real OS-provided ones. This allows precise control over the test, such as adding delays or simulated faults. You can always just implement the various Eio types directly, but this module provides some convenient pre-built mocks, and some helpers for creating your own mocks.

Mocks typically use Eio.traceln to record how they were used. This output can be recorded and compared against a known-good copy using e.g. ocaml-mdx.

Mocks may require configuration. For example, a source flow needs to know what data to return when the application reads from it. This can be done using the various on_* functions. For example:

let stdin = Eio_mock.Flow.make "stdin" in
 let stdout = Eio_mock.Flow.make "stdout" in
 Eio_mock.Flow.on_read stdin [
   `Return "chunk1";
@@ -9,4 +9,4 @@
 Eio.Flow.copy stdin stdout

This will produce:

+stdin: read "chunk1"
 +stdout: wrote "chunk1"
 +stdin: read "chunk2"
-+stdout: wrote "chunk2"

Configuration

module Action : sig ... end

Actions that can be performed by mock handlers.

module Handler : sig ... end

Control how a mock responds.

Pre-defined mocks

module Flow : sig ... end

Mock Eio.Flow sources and sinks.

module Net : sig ... end

Mock Eio.Net networks and sockets.

module Clock : sig ... end

A mock Eio.Time clock for testing timeouts.

Backend for mocks

The mocks can be used with any backend, but if you don't need any IO then you can use this one to avoid a dependency on eio_main.

module Backend : sig ... end

A dummy Eio backend with no actual IO.

Mock errors

type Eio.Exn.Backend.t +=
  1. | Simulated_failure
    (*

    A fake error code you can use for simulated faults.

    *)
\ No newline at end of file ++stdout: wrote "chunk2"

Configuration

module Action : sig ... end

Actions that can be performed by mock handlers.

module Handler : sig ... end

Control how a mock responds.

Pre-defined mocks

module Flow : sig ... end

Mock Eio.Flow sources and sinks.

module Net : sig ... end

Mock Eio.Net networks and sockets.

module Clock : sig ... end

A mock Eio.Time clock for testing timeouts.

module Domain_manager : sig ... end

A mock Eio.Domain_manager that runs everything in a single domain.

Backend for mocks

The mocks can be used with any backend, but if you don't need any IO then you can use this one to avoid a dependency on eio_main.

module Backend : sig ... end

A dummy Eio backend with no actual IO.

Mock errors

type Eio.Exn.Backend.t +=
  1. | Simulated_failure
    (*

    A fake error code you can use for simulated faults.

    *)
\ No newline at end of file diff --git a/eio/Eio_unix/.dummy b/eio/Eio_unix/.dummy deleted file mode 100644 index e69de29bb..000000000 diff --git a/eio/Eio_unix/Ctf/index.html b/eio/Eio_unix/Ctf/index.html index 4d86db698..e08f21c43 100644 --- a/eio/Eio_unix/Ctf/index.html +++ b/eio/Eio_unix/Ctf/index.html @@ -1,2 +1,2 @@ -Ctf (eio.Eio_unix.Ctf)

Module Eio_unix.Ctf

val timestamper : Eio.Private.Ctf.log_buffer -> int -> unit

Uses Mtime_clock to write timestamps.

val mmap_buffer : size:int -> string -> Eio.Private.Ctf.log_buffer

mmap_buffer ~size path initialises file path as an empty buffer for tracing.

val with_tracing : ?size:int -> string -> (unit -> 'a) -> 'a

with_tracing path fn is a convenience function that uses mmap_buffer to create a log buffer, calls Ctf.Control.start to start recording, runs fn, and then stops recording.

\ No newline at end of file +Ctf (eio.Eio_unix.Ctf)

Module Eio_unix.Ctf

val timestamper : Eio.Private.Ctf.log_buffer -> int -> unit

Uses Mtime_clock to write timestamps.

val mmap_buffer : size:int -> string -> Eio.Private.Ctf.log_buffer

mmap_buffer ~size path initialises file path as an empty buffer for tracing.

val with_tracing : ?size:int -> string -> (unit -> 'a) -> 'a

with_tracing path fn is a convenience function that uses mmap_buffer to create a log buffer, calls Ctf.Control.start to start recording, runs fn, and then stops recording.

\ No newline at end of file diff --git a/eio/Eio_unix/Fd/index.html b/eio/Eio_unix/Fd/index.html index b42cd66b2..d5e89b0cf 100644 --- a/eio/Eio_unix/Fd/index.html +++ b/eio/Eio_unix/Fd/index.html @@ -1,8 +1,8 @@ -Fd (eio.Eio_unix.Fd)

Module Eio_unix.Fd

A safe wrapper for Unix.file_descr.

type t

A wrapper around a Unix.file_descr.

Creation

val of_unix : +Fd (eio.Eio_unix.Fd)

Module Eio_unix.Fd

A safe wrapper for Unix.file_descr.

type t

A wrapper around a Unix.file_descr.

Creation

val of_unix : sw:Eio.Std.Switch.t -> ?blocking:bool -> ?seekable:bool -> close_unix:bool -> Unix.file_descr -> - t

of_unix ~sw ~close_unix fd wraps fd.

  • parameter sw

    Close fd automatically when sw is finished.

  • parameter blocking

    Indicates whether fd is in blocking mode. If not given, fd is probed for its blocking state if needed.

  • parameter seekable

    The value to be returned by is_seekable. Defaults to probing if needed.

  • parameter close_unix

    Whether close also closes fd (this should normally be true).

Using FDs

val use : t -> (Unix.file_descr -> 'a) -> if_closed:(unit -> 'a) -> 'a

use t fn ~if_closed calls fn wrapped_fd, ensuring that wrapped_fd will not be closed before fn returns.

If t is already closed, it returns if_closed () instead.

val use_exn : string -> t -> (Unix.file_descr -> 'a) -> 'a

use_exn op t fn calls fn wrapped_fd, ensuring that wrapped_fd will not be closed before fn returns.

If t is already closed, it raises an exception, using op as the name of the failing operation.

val use_exn_list : string -> t list -> (Unix.file_descr list -> 'a) -> 'a

use_exn_list op fds fn calls use_exn on each FD in fds, calling fn wrapped_fds on the results.

Closing

val close : t -> unit

close t marks t as closed, so that use can no longer be used to start new operations.

The wrapped FD will be closed once all current users of the FD have finished (unless close_unix = false).

Has no effect if t is already closed.

val remove : t -> Unix.file_descr option

remove t marks t as closed, so that use can no longer be used to start new operations.

It then waits for all current users of the wrapped FD to finish using it, and then returns the FD.

This operation suspends the calling fiber and so must run from an Eio fiber. It does not allow itself to be cancelled, since it takes ownership of the FD and that would be leaked if it aborted.

Returns None if t is closed by another fiber first.

Flags

val is_blocking : t -> bool

is_blocking t returns the value of blocking passed to of_unix.

If not known, it first probes for it (and if the FD is already closed, returns false).

val is_seekable : t -> bool

is_seekable t returns the value of seekable passed to of_unix.

If not known, it first probes for it (and if the FD is already closed, returns false).

Standard FDs

val stdin : t
val stdout : t
val stderr : t

Printing

val pp : t Fmt.t

Displays the FD number.

\ No newline at end of file + t

of_unix ~sw ~close_unix fd wraps fd.

  • parameter sw

    Close fd automatically when sw is finished.

  • parameter blocking

    Indicates whether fd is in blocking mode. If not given, fd is probed for its blocking state if needed.

  • parameter seekable

    The value to be returned by is_seekable. Defaults to probing if needed.

  • parameter close_unix

    Whether close also closes fd (this should normally be true).

val of_unix_list : sw:Eio.Std.Switch.t -> Unix.file_descr list -> t list

of_unix_list ~sw fds is like List.map (of_unix ~sw ~close_unix:true) fds, except that if sw is off then it closes all the FDs.

Using FDs

val use : t -> (Unix.file_descr -> 'a) -> if_closed:(unit -> 'a) -> 'a

use t fn ~if_closed calls fn wrapped_fd, ensuring that wrapped_fd will not be closed before fn returns.

If t is already closed, it returns if_closed () instead.

val use_exn : string -> t -> (Unix.file_descr -> 'a) -> 'a

use_exn op t fn calls fn wrapped_fd, ensuring that wrapped_fd will not be closed before fn returns.

If t is already closed, it raises an exception, using op as the name of the failing operation.

val use_exn_list : string -> t list -> (Unix.file_descr list -> 'a) -> 'a

use_exn_list op fds fn calls use_exn on each FD in fds, calling fn wrapped_fds on the results.

Closing

val close : t -> unit

close t marks t as closed, so that use can no longer be used to start new operations.

The wrapped FD will be closed once all current users of the FD have finished (unless close_unix = false).

Has no effect if t is already closed.

val remove : t -> Unix.file_descr option

remove t marks t as closed, so that use can no longer be used to start new operations.

It then waits for all current users of the wrapped FD to finish using it, and then returns the FD.

This operation suspends the calling fiber and so must run from an Eio fiber. It does not allow itself to be cancelled, since it takes ownership of the FD and that would be leaked if it aborted.

Returns None if t is closed by another fiber first.

Flags

val is_blocking : t -> bool

is_blocking t returns the value of blocking passed to of_unix.

If not known, it first probes for it (and if the FD is already closed, returns false).

val is_seekable : t -> bool

is_seekable t returns the value of seekable passed to of_unix.

If not known, it first probes for it (and if the FD is already closed, returns false).

Standard FDs

val stdin : t
val stdout : t
val stderr : t

Printing

val pp : t Fmt.t

Displays the FD number.

\ No newline at end of file diff --git a/eio/Eio_unix/Net/Ipaddr/index.html b/eio/Eio_unix/Net/Ipaddr/index.html index f4fc58cf7..4af0d62be 100644 --- a/eio/Eio_unix/Net/Ipaddr/index.html +++ b/eio/Eio_unix/Net/Ipaddr/index.html @@ -1,2 +1,2 @@ -Ipaddr (eio.Eio_unix.Net.Ipaddr)

Module Net.Ipaddr

Convert between Eio.Net.Ipaddr and Unix.inet_addr.

Internally, these are actually the same type, so these are just casts.

val to_unix : [< `V4 | `V6 ] Eio.Net.Ipaddr.t -> Unix.inet_addr
val of_unix : Unix.inet_addr -> Eio.Net.Ipaddr.v4v6
\ No newline at end of file +Ipaddr (eio.Eio_unix.Net.Ipaddr)

Module Net.Ipaddr

Convert between Eio.Net.Ipaddr and Unix.inet_addr.

Internally, these are actually the same type, so these are just casts.

val to_unix : [< `V4 | `V6 ] Eio.Net.Ipaddr.t -> Unix.inet_addr
val of_unix : Unix.inet_addr -> Eio.Net.Ipaddr.v4v6
\ No newline at end of file diff --git a/eio/Eio_unix/Net/class-datagram_socket/index.html b/eio/Eio_unix/Net/class-datagram_socket/index.html deleted file mode 100644 index 1980be36f..000000000 --- a/eio/Eio_unix/Net/class-datagram_socket/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -datagram_socket (eio.Eio_unix.Net.datagram_socket)

Class Net.datagram_socket

\ No newline at end of file diff --git a/eio/Eio_unix/Net/class-stream_socket/index.html b/eio/Eio_unix/Net/class-stream_socket/index.html deleted file mode 100644 index de8a2417b..000000000 --- a/eio/Eio_unix/Net/class-stream_socket/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -stream_socket (eio.Eio_unix.Net.stream_socket)

Class Net.stream_socket

\ No newline at end of file diff --git a/eio/Eio_unix/Net/class-t/index.html b/eio/Eio_unix/Net/class-t/index.html deleted file mode 100644 index da3d1f06a..000000000 --- a/eio/Eio_unix/Net/class-t/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -t (eio.Eio_unix.Net.t)

Class Net.t

inherit Eio.Net.t
method getnameinfo : Eio.Net.Sockaddr.t -> string * string
\ No newline at end of file diff --git a/eio/Eio_unix/Net/index.html b/eio/Eio_unix/Net/index.html index cf570ed3b..230cc7962 100644 --- a/eio/Eio_unix/Net/index.html +++ b/eio/Eio_unix/Net/index.html @@ -1,30 +1,47 @@ -Net (eio.Eio_unix.Net)

Module Eio_unix.Net

Extended network API with support for file descriptors.

Types

These extend the types in Eio.Net with support for file descriptors.

class virtual stream_socket : object ... end
class virtual datagram_socket : object ... end
class virtual t : object ... end

Unix address conversions

Note: OCaml's Unix.sockaddr type considers e.g. TCP port 80 and UDP port 80 to be the same thing, whereas Eio regards them as separate addresses that just happen to have the same representation (a host address and a port number), so we have separate "of_unix" functions for each.

val sockaddr_to_unix : +Net (eio.Eio_unix.Net)

Module Eio_unix.Net

Extended network API with support for file descriptors.

Types

These extend the types in Eio.Net with support for file descriptors.

type stream_socket_ty = [ `Generic | `Unix ] Eio.Net.stream_socket_ty
type datagram_socket_ty = [ `Generic | `Unix ] Eio.Net.datagram_socket_ty
type listening_socket_ty = [ `Generic | `Unix ] Eio.Net.listening_socket_ty
type 'a stream_socket = [> stream_socket_ty ] as 'a Eio.Std.r
type 'a datagram_socket = [> datagram_socket_ty ] as 'a Eio.Std.r
type 'a listening_socket = [> listening_socket_ty ] as 'a Eio.Std.r
type t = [ `Generic | `Unix ] Eio.Net.ty Eio.Std.r

Passing file descriptors

val send_msg : + [> `Platform of [> `Unix ] | `Socket | `Stream ] Eio.Std.r -> + ?fds:Fd.t list -> + Cstruct.t list -> + unit

Like Eio.Flow.write, but allows passing file descriptors (for Unix-domain sockets).

val recv_msg_with_fds : + [> `Platform of [> `Unix ] | `Socket | `Stream ] Eio.Std.r -> + sw:Eio.Std.Switch.t -> + max_fds:int -> + Cstruct.t list -> + int * Fd.t list

Like Eio.Flow.single_read, but also allows receiving file descriptors (for Unix-domain sockets).

  • parameter max_fds

    The maximum number of file descriptors to accept (additional ones will be closed).

val fd : [> `Platform of [> `Unix ] | `Socket ] Eio.Std.r -> Fd.t

fd socket is the underlying FD of socket.

Unix address conversions

Note: OCaml's Unix.sockaddr type considers e.g. TCP port 80 and UDP port 80 to be the same thing, whereas Eio regards them as separate addresses that just happen to have the same representation (a host address and a port number), so we have separate "of_unix" functions for each.

val sockaddr_to_unix : [< Eio.Net.Sockaddr.stream | Eio.Net.Sockaddr.datagram ] -> Unix.sockaddr
val sockaddr_of_unix_stream : Unix.sockaddr -> Eio.Net.Sockaddr.stream
val sockaddr_of_unix_datagram : Unix.sockaddr -> Eio.Net.Sockaddr.datagram
module Ipaddr : sig ... end

Convert between Eio.Net.Ipaddr and Unix.inet_addr.

Creating or importing sockets

val import_socket_stream : sw:Eio.Std.Switch.t -> close_unix:bool -> Unix.file_descr -> - stream_socket

import_socket_stream ~sw ~close_unix:true fd is an Eio flow that uses fd.

It can be cast to e.g. source for a one-way flow. The socket object will be closed when sw finishes.

The close_unix and sw arguments are passed to Fd.of_unix.

val import_socket_datagram : + [ `Unix_fd | stream_socket_ty ] Eio.Std.r

import_socket_stream ~sw ~close_unix:true fd is an Eio flow that uses fd.

It can be cast to e.g. source for a one-way flow. The socket object will be closed when sw finishes.

The close_unix and sw arguments are passed to Fd.of_unix.

val import_socket_datagram : sw:Eio.Std.Switch.t -> close_unix:bool -> Unix.file_descr -> - datagram_socket

import_socket_datagram ~sw ~close_unix:true fd is an Eio datagram socket that uses fd.

The socket object will be closed when sw finishes.

The close_unix and sw arguments are passed to Fd.of_unix.

val socketpair_stream : + [ `Unix_fd | datagram_socket_ty ] Eio.Std.r

import_socket_datagram ~sw ~close_unix:true fd is an Eio datagram socket that uses fd.

The socket object will be closed when sw finishes.

The close_unix and sw arguments are passed to Fd.of_unix.

val socketpair_stream : sw:Eio.Std.Switch.t -> ?domain:Unix.socket_domain -> ?protocol:int -> unit -> - stream_socket * stream_socket

socketpair_stream ~sw () returns a connected pair of flows, such that writes to one can be read by the other.

This creates OS-level resources using socketpair(2). Note that, like all FDs created by Eio, they are both marked as close-on-exec by default.

val socketpair_datagram : + [ `Unix_fd | stream_socket_ty ] Eio.Std.r + * [ `Unix_fd | stream_socket_ty ] Eio.Std.r

socketpair_stream ~sw () returns a connected pair of flows, such that writes to one can be read by the other.

This creates OS-level resources using socketpair(2). Note that, like all FDs created by Eio, they are both marked as close-on-exec by default.

val socketpair_datagram : sw:Eio.Std.Switch.t -> ?domain:Unix.socket_domain -> ?protocol:int -> unit -> - datagram_socket * datagram_socket

socketpair_datagram ~sw () returns a connected pair of flows, such that writes to one can be read by the other.

This creates OS-level resources using socketpair(2). Note that, like all FDs created by Eio, they are both marked as close-on-exec by default.

Private API for backends

val getnameinfo : Eio.Net.Sockaddr.t -> string * string

getnameinfo sockaddr returns domain name and service for sockaddr.

type Stdlib.Effect.t +=
  1. | Import_socket_stream : Eio.Std.Switch.t + [ `Unix_fd | datagram_socket_ty ] Eio.Std.r + * [ `Unix_fd | datagram_socket_ty ] Eio.Std.r

socketpair_datagram ~sw () returns a connected pair of flows, such that writes to one can be read by the other.

This creates OS-level resources using socketpair(2). Note that, like all FDs created by Eio, they are both marked as close-on-exec by default.

Private API for backends

val getnameinfo : Eio.Net.Sockaddr.t -> string * string

getnameinfo sockaddr returns domain name and service for sockaddr.

type Stdlib.Effect.t +=
  1. | Import_socket_stream : Eio.Std.Switch.t * bool - * Unix.file_descr -> stream_socket Stdlib.Effect.t
  2. | Import_socket_datagram : Eio.Std.Switch.t + * Unix.file_descr -> [ `Unix_fd | stream_socket_ty ] Eio.Std.r + Stdlib.Effect.t
  3. | Import_socket_datagram : Eio.Std.Switch.t * bool - * Unix.file_descr -> datagram_socket Stdlib.Effect.t
  4. | Socketpair_stream : Eio.Switch.t + * Unix.file_descr -> [ `Unix_fd | datagram_socket_ty ] Eio.Std.r + Stdlib.Effect.t
  5. | Socketpair_stream : Eio.Switch.t * Unix.socket_domain - * int -> (stream_socket * stream_socket) Stdlib.Effect.t
  6. | Socketpair_datagram : Eio.Switch.t + * int -> ([ `Unix_fd | stream_socket_ty ] Eio.Std.r + * [ `Unix_fd | stream_socket_ty ] Eio.Std.r) + Stdlib.Effect.t
  7. | Socketpair_datagram : Eio.Switch.t * Unix.socket_domain - * int -> (datagram_socket * datagram_socket) Stdlib.Effect.t
\ No newline at end of file + * int -> ([ `Unix_fd | datagram_socket_ty ] Eio.Std.r + * [ `Unix_fd | datagram_socket_ty ] Eio.Std.r) + Stdlib.Effect.t
\ No newline at end of file diff --git a/eio/Eio_unix/Pi/index.html b/eio/Eio_unix/Pi/index.html new file mode 100644 index 000000000..bc4e5833d --- /dev/null +++ b/eio/Eio_unix/Pi/index.html @@ -0,0 +1,13 @@ + +Pi (eio.Eio_unix.Pi)

Module Eio_unix.Pi

module type STREAM_SOCKET = sig ... end
type Eio.Resource.pi +=
  1. | Stream_socket : ('t, + (module STREAM_SOCKET + with type t = 't), + [> `Platform of [> `Unix ] | `Socket | `Stream ]) + Eio.Resource.pi
module type FLOW = sig ... end
val flow_handler : + (module FLOW with type t = 't and type tag = 'tag) -> + ('t, [ `Unix_fd | 'tag Eio.Net.stream_socket_ty | Eio.File.rw_ty ]) + Eio.Resource.handler
module type DATAGRAM_SOCKET = sig ... end
val datagram_handler : + (module DATAGRAM_SOCKET with type t = 't and type tag = 'tag) -> + ('t, [ `Unix_fd | 'tag Eio.Net.datagram_socket_ty ]) Eio.Resource.handler
module type LISTENING_SOCKET = sig ... end
val listening_socket_handler : + (module LISTENING_SOCKET with type t = 't and type tag = 'tag) -> + ('t, [ `Unix_fd | 'tag Eio.Net.listening_socket_ty ]) Eio.Resource.handler
\ No newline at end of file diff --git a/eio/Eio_unix/Pi/module-type-DATAGRAM_SOCKET/index.html b/eio/Eio_unix/Pi/module-type-DATAGRAM_SOCKET/index.html new file mode 100644 index 000000000..d389b948c --- /dev/null +++ b/eio/Eio_unix/Pi/module-type-DATAGRAM_SOCKET/index.html @@ -0,0 +1,2 @@ + +DATAGRAM_SOCKET (eio.Eio_unix.Pi.DATAGRAM_SOCKET)

Module type Pi.DATAGRAM_SOCKET

include Eio.Net.Pi.DATAGRAM_SOCKET
type tag
include Eio.Flow.Pi.SHUTDOWN
type t
val shutdown : t -> Eio.Flow.shutdown_command -> unit
val send : t -> ?dst:Eio.Net.Sockaddr.datagram -> Cstruct.t list -> unit
val recv : t -> Cstruct.t -> Eio.Net.Sockaddr.datagram * int
val close : t -> unit
val fd : t -> Fd.t
\ No newline at end of file diff --git a/eio/Eio_unix/Pi/module-type-FLOW/index.html b/eio/Eio_unix/Pi/module-type-FLOW/index.html new file mode 100644 index 000000000..cb0900b5f --- /dev/null +++ b/eio/Eio_unix/Pi/module-type-FLOW/index.html @@ -0,0 +1,7 @@ + +FLOW (eio.Eio_unix.Pi.FLOW)

Module type Pi.FLOW

include Eio.File.Pi.WRITE
include Eio.Flow.Pi.SINK
type t
include Eio.File.Pi.READ with type t := t
include Eio.Flow.Pi.SOURCE with type t := t
val pread : t -> file_offset:Optint.Int63.t -> Cstruct.t list -> int
val stat : t -> Eio.File.Stat.t
val pwrite : t -> file_offset:Optint.Int63.t -> Cstruct.t list -> int
include STREAM_SOCKET with type t := t
include Eio.Net.Pi.STREAM_SOCKET with type t := t
type tag
include Eio.Flow.Pi.SHUTDOWN with type t := t
val shutdown : t -> Eio.Flow.shutdown_command -> unit
include Eio.Flow.Pi.SOURCE with type t := t
val read_methods : t Eio.Flow.read_method list
val single_read : t -> Cstruct.t -> int
include Eio.Flow.Pi.SINK with type t := t
val single_write : t -> Cstruct.t list -> int
val copy : t -> src:_ Eio.Flow.source -> unit

copy t ~src allows for optimising copy operations.

If you have no optimisations, you can use simple_copy to implement this using single_write.

val close : t -> unit
val send_msg : t -> fds:Fd.t list -> Cstruct.t list -> int
val recv_msg_with_fds : + t -> + sw:Eio.Std.Switch.t -> + max_fds:int -> + Cstruct.t list -> + int * Fd.t list
val fd : t -> Fd.t
\ No newline at end of file diff --git a/eio/Eio_unix/Pi/module-type-LISTENING_SOCKET/index.html b/eio/Eio_unix/Pi/module-type-LISTENING_SOCKET/index.html new file mode 100644 index 000000000..40c726e26 --- /dev/null +++ b/eio/Eio_unix/Pi/module-type-LISTENING_SOCKET/index.html @@ -0,0 +1,5 @@ + +LISTENING_SOCKET (eio.Eio_unix.Pi.LISTENING_SOCKET)

Module type Pi.LISTENING_SOCKET

include Eio.Net.Pi.LISTENING_SOCKET
type t
type tag
val close : t -> unit
val fd : t -> Fd.t
\ No newline at end of file diff --git a/eio/Eio_unix/Pi/module-type-STREAM_SOCKET/index.html b/eio/Eio_unix/Pi/module-type-STREAM_SOCKET/index.html new file mode 100644 index 000000000..c35d37960 --- /dev/null +++ b/eio/Eio_unix/Pi/module-type-STREAM_SOCKET/index.html @@ -0,0 +1,7 @@ + +STREAM_SOCKET (eio.Eio_unix.Pi.STREAM_SOCKET)

Module type Pi.STREAM_SOCKET

include Eio.Net.Pi.STREAM_SOCKET
type tag
include Eio.Flow.Pi.SHUTDOWN
type t
val shutdown : t -> Eio.Flow.shutdown_command -> unit
include Eio.Flow.Pi.SOURCE with type t := t
val read_methods : t Eio.Flow.read_method list
val single_read : t -> Cstruct.t -> int
include Eio.Flow.Pi.SINK with type t := t
val single_write : t -> Cstruct.t list -> int
val copy : t -> src:_ Eio.Flow.source -> unit

copy t ~src allows for optimising copy operations.

If you have no optimisations, you can use simple_copy to implement this using single_write.

val close : t -> unit
val send_msg : t -> fds:Fd.t list -> Cstruct.t list -> int
val recv_msg_with_fds : + t -> + sw:Eio.Std.Switch.t -> + max_fds:int -> + Cstruct.t list -> + int * Fd.t list
val fd : t -> Fd.t
\ No newline at end of file diff --git a/eio/Eio_unix/Private/Rcfd/index.html b/eio/Eio_unix/Private/Rcfd/index.html index fd63c3a2e..b9ce2d151 100644 --- a/eio/Eio_unix/Private/Rcfd/index.html +++ b/eio/Eio_unix/Private/Rcfd/index.html @@ -1,2 +1,2 @@ -Rcfd (eio.Eio_unix.Private.Rcfd)

Module Private.Rcfd

A safe wrapper around Unix.file_descr.

When FDs are shared between domains, there is the risk that one domain will try to use an FD just as another domain is closing it. Then this can happen:

  1. Domain A decides to write to FD 3, which it shares with domain B.
  2. Domain B closes FD 3.
  3. Domain C opens a new file, getting assigned FD 3 by the OS.
  4. Domain A writes to FD 3, corrupting domain C's file.

This would break modularity, since the fibers in domains A and C may have no connection with each other.

To prevent this, we keep a ref-count, tracking how many fibers are using the FD. Wrap uses of the FD in use to ensure that it won't be closed while you're using it.

Calling close while one or more operations are still in progress marks the wrapper as closing (so that no futher operations can start); the last operation to finish will close the underlying FD.

type t
val make : Unix.file_descr -> t

let t = make fd wraps fd.

t takes ownership of fd. The caller is responsible for ensuring that close (or remove) is called at least once in the future.

val use : if_closed:(unit -> 'a) -> t -> (Unix.file_descr -> 'a) -> 'a

use t fn ~if_closed calls fn fd, preventing fd from being closed until fn returns.

if_closed () is used if t is closed before we can increment the ref-count. use can be used in parallel from multiple domains at the same time.

This operation is lock-free and can be used safely from signal handlers, etc.

val is_open : t -> bool

is_open t returns true until t has been marked as closing, after which it returns false.

This is mostly useful inside the callback of use, to test whether another fiber has started closing t (in which case you may decide to stop early).

val close : t -> bool

close t marks t as closed and arranges for its FD to be closed.

If there are calls to use in progress, the last one to finish will close the underlying FD. Note that this function returns without waiting for the close to happen in that case.

Returns true after successfully marking t as closing, or false if it was already marked.

If you need to wait until the underlying FD is closed, use remove and then close the FD yourself instead.

val remove : t -> Unix.file_descr option

remove t closes t and returns the FD.

It immediately marks t as closing (so no further operations can start) and then waits until there are no further users.

This operation suspends the calling fiber and so must run from an Eio fiber. It does not allow itself to be cancelled, since it takes ownership of the FD and that would be leaked if it aborted.

If another fiber marks t as closing before remove can, it returns None immediately.

val peek : t -> Unix.file_descr

peek t returns the file-descriptor without updating the ref-count.

You must ensure that t isn't closed while using the result. This is a dangerous operation and may be removed in the future.

If t was closed, it instead raises an exception (if you're not sure when t might get closed, you shouldn't be using this function).

val pp : t Fmt.t

Displays the FD number.

\ No newline at end of file +Rcfd (eio.Eio_unix.Private.Rcfd)

Module Private.Rcfd

A safe wrapper around Unix.file_descr.

When FDs are shared between domains, there is the risk that one domain will try to use an FD just as another domain is closing it. Then this can happen:

  1. Domain A decides to write to FD 3, which it shares with domain B.
  2. Domain B closes FD 3.
  3. Domain C opens a new file, getting assigned FD 3 by the OS.
  4. Domain A writes to FD 3, corrupting domain C's file.

This would break modularity, since the fibers in domains A and C may have no connection with each other.

To prevent this, we keep a ref-count, tracking how many fibers are using the FD. Wrap uses of the FD in use to ensure that it won't be closed while you're using it.

Calling close while one or more operations are still in progress marks the wrapper as closing (so that no futher operations can start); the last operation to finish will close the underlying FD.

type t
val make : Unix.file_descr -> t

let t = make fd wraps fd.

t takes ownership of fd. The caller is responsible for ensuring that close (or remove) is called at least once in the future.

val use : if_closed:(unit -> 'a) -> t -> (Unix.file_descr -> 'a) -> 'a

use t fn ~if_closed calls fn fd, preventing fd from being closed until fn returns.

if_closed () is used if t is closed before we can increment the ref-count. use can be used in parallel from multiple domains at the same time.

This operation is lock-free and can be used safely from signal handlers, etc.

val is_open : t -> bool

is_open t returns true until t has been marked as closing, after which it returns false.

This is mostly useful inside the callback of use, to test whether another fiber has started closing t (in which case you may decide to stop early).

val close : t -> bool

close t marks t as closed and arranges for its FD to be closed.

If there are calls to use in progress, the last one to finish will close the underlying FD. Note that this function returns without waiting for the close to happen in that case.

Returns true after successfully marking t as closing, or false if it was already marked.

If you need to wait until the underlying FD is closed, use remove and then close the FD yourself instead.

val remove : t -> Unix.file_descr option

remove t closes t and returns the FD.

It immediately marks t as closing (so no further operations can start) and then waits until there are no further users.

This operation suspends the calling fiber and so must run from an Eio fiber. It does not allow itself to be cancelled, since it takes ownership of the FD and that would be leaked if it aborted.

If another fiber marks t as closing before remove can, it returns None immediately.

val peek : t -> Unix.file_descr

peek t returns the file-descriptor without updating the ref-count.

You must ensure that t isn't closed while using the result. This is a dangerous operation and may be removed in the future.

If t was closed, it instead raises an exception (if you're not sure when t might get closed, you shouldn't be using this function).

val pp : t Fmt.t

Displays the FD number.

\ No newline at end of file diff --git a/eio/Eio_unix/Private/index.html b/eio/Eio_unix/Private/index.html index dc8f67957..62a2ed9bd 100644 --- a/eio/Eio_unix/Private/index.html +++ b/eio/Eio_unix/Private/index.html @@ -1,2 +1,3 @@ -Private (eio.Eio_unix.Private)

Module Eio_unix.Private

API for Eio backends only.

type Stdlib.Effect.t +=
  1. | Await_readable : Unix.file_descr -> unit Stdlib.Effect.t
  2. | Await_writable : Unix.file_descr -> unit Stdlib.Effect.t
  3. | Get_monotonic_clock : Eio.Time.Mono.t Stdlib.Effect.t
  4. | Pipe : Eio.Switch.t -> (source * sink) Stdlib.Effect.t
    (*

    See pipe

    *)
module Rcfd : sig ... end

A safe wrapper around Unix.file_descr.

module Fork_action = Private.Fork_action
\ No newline at end of file +Private (eio.Eio_unix.Private)

Module Eio_unix.Private

API for Eio backends only.

type Stdlib.Effect.t +=
  1. | Await_readable : Unix.file_descr -> unit Stdlib.Effect.t
  2. | Await_writable : Unix.file_descr -> unit Stdlib.Effect.t
  3. | Get_monotonic_clock : Eio.Time.Mono.ty Eio.Std.r Stdlib.Effect.t
  4. | Pipe : Eio.Switch.t -> (source_ty Eio.Std.r * sink_ty Eio.Std.r) + Stdlib.Effect.t
    (*

    See pipe

    *)
module Rcfd : sig ... end

A safe wrapper around Unix.file_descr.

module Fork_action = Private.Fork_action
\ No newline at end of file diff --git a/eio/Eio_unix/Process/Make_mgr/argument-1-X/index.html b/eio/Eio_unix/Process/Make_mgr/argument-1-X/index.html new file mode 100644 index 000000000..a1937616f --- /dev/null +++ b/eio/Eio_unix/Process/Make_mgr/argument-1-X/index.html @@ -0,0 +1,10 @@ + +X (eio.Eio_unix.Process.Make_mgr.X)

Parameter Make_mgr.X

type t
val spawn_unix : + t -> + sw:Eio.Std.Switch.t -> + ?cwd:Eio.Fs.dir_ty Eio.Path.t -> + env:string array -> + fds:(int * Fd.t * Private.Fork_action.blocking) list -> + executable:string -> + string list -> + ty Eio.Std.r
\ No newline at end of file diff --git a/eio/Eio_unix/Process/Make_mgr/index.html b/eio/Eio_unix/Process/Make_mgr/index.html new file mode 100644 index 000000000..1710c2d36 --- /dev/null +++ b/eio/Eio_unix/Process/Make_mgr/index.html @@ -0,0 +1,26 @@ + +Make_mgr (eio.Eio_unix.Process.Make_mgr)

Module Process.Make_mgr

Parameters

module X : sig ... end

Signature

include Eio.Process.Pi.MGR + with type t = X.t + with type tag = [ `Generic | `Unix ]
type tag = [
  1. | `Generic
  2. | `Unix
]
type t = X.t
val spawn : + t -> + sw:Eio.Switch.t -> + ?cwd:Eio.Fs.dir_ty Eio.Path.t -> + ?stdin:Eio.Flow.source_ty Eio.Std.r -> + ?stdout:Eio.Flow.sink_ty Eio.Std.r -> + ?stderr:Eio.Flow.sink_ty Eio.Std.r -> + ?env:string array -> + ?executable:string -> + string list -> + tag Eio.Process.ty Eio.Std.r
val spawn_unix : + t -> + sw:Eio.Std.Switch.t -> + ?cwd:Eio.Fs.dir_ty Eio.Path.t -> + env:string array -> + fds:(int * Fd.t * Private.Fork_action.blocking) list -> + executable:string -> + string list -> + ty Eio.Std.r
\ No newline at end of file diff --git a/eio/Eio_unix/Process/Pi/index.html b/eio/Eio_unix/Process/Pi/index.html new file mode 100644 index 000000000..630ac8e75 --- /dev/null +++ b/eio/Eio_unix/Process/Pi/index.html @@ -0,0 +1,4 @@ + +Pi (eio.Eio_unix.Process.Pi)

Module Process.Pi

module type MGR = sig ... end
type Eio.Resource.pi +=
  1. | Mgr_unix : ('t, (module MGR with type t = 't), [> mgr_ty ]) Eio.Resource.pi
val mgr_unix : + (module MGR with type t = 't and type tag = 'tag) -> + ('t, 'tag Eio.Process.mgr_ty) Eio.Resource.handler
\ No newline at end of file diff --git a/eio/Eio_unix/Process/Pi/module-type-MGR/index.html b/eio/Eio_unix/Process/Pi/module-type-MGR/index.html new file mode 100644 index 000000000..c460347f1 --- /dev/null +++ b/eio/Eio_unix/Process/Pi/module-type-MGR/index.html @@ -0,0 +1,24 @@ + +MGR (eio.Eio_unix.Process.Pi.MGR)

Module type Pi.MGR

include Eio.Process.Pi.MGR
type tag
type t
val spawn : + t -> + sw:Eio.Switch.t -> + ?cwd:Eio.Fs.dir_ty Eio.Path.t -> + ?stdin:Eio.Flow.source_ty Eio.Std.r -> + ?stdout:Eio.Flow.sink_ty Eio.Std.r -> + ?stderr:Eio.Flow.sink_ty Eio.Std.r -> + ?env:string array -> + ?executable:string -> + string list -> + tag Eio.Process.ty Eio.Std.r
val spawn_unix : + t -> + sw:Eio.Std.Switch.t -> + ?cwd:Eio.Fs.dir_ty Eio.Path.t -> + env:string array -> + fds:(int * Fd.t * Private.Fork_action.blocking) list -> + executable:string -> + string list -> + ty Eio.Std.r
\ No newline at end of file diff --git a/eio/Eio_unix/Process/class-mgr/index.html b/eio/Eio_unix/Process/class-mgr/index.html deleted file mode 100644 index 369cd4b67..000000000 --- a/eio/Eio_unix/Process/class-mgr/index.html +++ /dev/null @@ -1,17 +0,0 @@ - -mgr (eio.Eio_unix.Process.mgr)

Class Process.mgr

method virtual spawn_unix : sw:Eio.Std.Switch.t -> - ?cwd:Eio.Fs.dir Eio.Path.t -> - env:string array -> - fds:(int * Eio_unix__.Fd.t * Eio_unix__Fork_action.blocking) list -> - executable:string -> - string list -> - Eio.Process.t
method spawn : sw:Eio.Std.Switch.t -> - ?cwd:Eio.Fs.dir Eio.Path.t -> - ?stdin:Eio.Flow.source -> - ?stdout:Eio.Flow.sink -> - ?stderr:Eio.Flow.sink -> - ?env:string array -> - ?executable:string -> - string list -> - Eio.Process.t

The default implementation uses spawn_unix.

\ No newline at end of file diff --git a/eio/Eio_unix/Process/index.html b/eio/Eio_unix/Process/index.html index 513b6e018..5b77be1e5 100644 --- a/eio/Eio_unix/Process/index.html +++ b/eio/Eio_unix/Process/index.html @@ -1,10 +1,12 @@ -Process (eio.Eio_unix.Process)

Module Eio_unix.Process

Spawning child processes with extra control.

This extends the Eio.Process API with more control over file-descriptors.

class virtual mgr : object ... end
val spawn_unix : +Process (eio.Eio_unix.Process)

Module Eio_unix.Process

Spawning child processes with extra control.

This extends the Eio.Process API with more control over file-descriptors.

Types

These extend the types in Eio.Process with support for file descriptors.

type ty = [ `Generic | `Unix ] Eio.Process.ty
type 'a t = [> ty ] as 'a Eio.Std.r
type mgr_ty = [ `Generic | `Unix ] Eio.Process.mgr_ty
type 'a mgr = [> mgr_ty ] as 'a Eio.Std.r
module Pi : sig ... end
module Make_mgr + (X : sig ... end) : + Pi.MGR with type t = X.t and type tag = [ `Generic | `Unix ]
val spawn_unix : sw:Eio.Std.Switch.t -> - mgr -> - ?cwd:Eio.Fs.dir Eio.Path.t -> + _ mgr -> + ?cwd:Eio.Fs.dir_ty Eio.Path.t -> fds:(int * Fd.t * Private.Fork_action.blocking) list -> ?env:string array -> ?executable:string -> string list -> - Eio.Process.t

spawn_unix ~sw mgr ~fds args spawns a child process running the command args.

The arguments are as for Eio.Process.spawn, except that it takes a list of FD mappings for Fork_action.inherit_fds directly, rather than just flows for the standard streams.

val sigchld : Eio.Condition.t

If an Eio backend installs a SIGCHLD handler, the handler will broadcast on this condition.

This allows non-Eio libraries (such as Lwt) to share its signal handler.

Note: Not all backends install a handler (e.g. eio_linux uses process descriptors instead), so be sure to call install_sigchld_handler if you need to use this.

val install_sigchld_handler : unit -> unit

install_sigchld_handler () sets the signal handler for SIGCHLD to broadcast sigchld.

\ No newline at end of file + ty Eio.Std.r

spawn_unix ~sw mgr ~fds args spawns a child process running the command args.

The arguments are as for Eio.Process.spawn, except that it takes a list of FD mappings for Fork_action.inherit_fds directly, rather than just flows for the standard streams.

val sigchld : Eio.Condition.t

If an Eio backend installs a SIGCHLD handler, the handler will broadcast on this condition.

This allows non-Eio libraries (such as Lwt) to share its signal handler.

Note: Not all backends install a handler (e.g. eio_linux uses process descriptors instead), so be sure to call install_sigchld_handler if you need to use this.

val install_sigchld_handler : unit -> unit

install_sigchld_handler () sets the signal handler for SIGCHLD to broadcast sigchld.

\ No newline at end of file diff --git a/eio/Eio_unix/Resource/index.html b/eio/Eio_unix/Resource/index.html index 672b73aad..4173a3a43 100644 --- a/eio/Eio_unix/Resource/index.html +++ b/eio/Eio_unix/Resource/index.html @@ -1,2 +1,2 @@ -Resource (eio.Eio_unix.Resource)

Module Eio_unix.Resource

Eio resources backed by an OS file descriptor.

type t = < fd : Fd.t >

Resources that have FDs are sub-types of t.

val fd : < t.. > -> Fd.t

fd t returns the FD being wrapped by a resource.

type Eio.Generic.ty +=
  1. | FD : Fd.t Eio.Generic.ty
    (*

    Resources that wrap FDs can handle this in their probe method to expose the FD.

    *)
val fd_opt : Eio.Generic.t -> Fd.t option

fd_opt t returns the FD being wrapped by a generic resource, if any.

This just probes t using FD.

\ No newline at end of file +Resource (eio.Eio_unix.Resource)

Module Eio_unix.Resource

Eio resources backed by an OS file descriptor.

type 'a t = [> `Unix_fd ] as 'a Eio.Resource.t

Resources that have FDs are tagged with `Unix_fd.

type Eio.Resource.pi +=
  1. | T : ('t, 't -> Fd.t, [> `Unix_fd ]) Eio.Resource.pi
val fd : _ t -> Fd.t

fd t returns the FD being wrapped by a resource.

val fd_opt : _ Eio.Resource.t -> Fd.t option

fd_opt t returns the FD being wrapped by a generic resource, if any.

This just probes t using FD.

\ No newline at end of file diff --git a/eio/Eio_unix/Stdenv/index.html b/eio/Eio_unix/Stdenv/index.html index 915664702..ced817276 100644 --- a/eio/Eio_unix/Stdenv/index.html +++ b/eio/Eio_unix/Stdenv/index.html @@ -1,15 +1,15 @@ -Stdenv (eio.Eio_unix.Stdenv)

Module Eio_unix.Stdenv

The set of resources provided to a process on a Unix-compatible system.

type base = - < stdin : source - ; stdout : sink - ; stderr : sink - ; net : Eio.Net.t - ; domain_mgr : Eio.Domain_manager.t - ; process_mgr : Process.mgr - ; clock : Eio.Time.clock - ; mono_clock : Eio.Time.Mono.t - ; fs : Eio.Fs.dir Eio.Path.t - ; cwd : Eio.Fs.dir Eio.Path.t - ; secure_random : Eio.Flow.source +Stdenv (eio.Eio_unix.Stdenv)

Module Eio_unix.Stdenv

The set of resources provided to a process on a Unix-compatible system.

type base = + < stdin : source_ty Eio.Std.r + ; stdout : sink_ty Eio.Std.r + ; stderr : sink_ty Eio.Std.r + ; net : [ `Unix | `Generic ] Eio.Net.ty Eio.Std.r + ; domain_mgr : Eio.Domain_manager.ty Eio.Std.r + ; process_mgr : Process.mgr_ty Eio.Std.r + ; clock : float Eio.Time.clock_ty Eio.Std.r + ; mono_clock : Eio.Time.Mono.ty Eio.Std.r + ; fs : Eio.Fs.dir_ty Eio.Path.t + ; cwd : Eio.Fs.dir_ty Eio.Path.t + ; secure_random : Eio.Flow.source_ty Eio.Std.r ; debug : Eio.Debug.t ; backend_id : string >

The common set of features provided by all traditional operating systems (BSDs, Linux, Mac, Windows).

You can use the functions in Eio.Stdenv to access these fields if you prefer.

\ No newline at end of file diff --git a/eio/Eio_unix/index.html b/eio/Eio_unix/index.html index 2436b9035..4c148ce39 100644 --- a/eio/Eio_unix/index.html +++ b/eio/Eio_unix/index.html @@ -1,2 +1,2 @@ -Eio_unix (eio.Eio_unix)

Module Eio_unix

Extension of Eio for integration with OCaml's Unix module.

Note that OCaml's Unix module is not safe, and therefore care must be taken when using these functions. For example, it is possible to leak file descriptors this way, or to use them after they've been closed, allowing one module to corrupt a file belonging to an unrelated module.

type Eio.Exn.Backend.t +=
  1. | Unix_error of Unix.error * string * string
    (*

    Wrapper for embedding Unix.Unix_error errors.

    *)
module Fd : sig ... end

A safe wrapper for Unix.file_descr.

module Resource : sig ... end

Eio resources backed by an OS file descriptor.

module Net : sig ... end

Extended network API with support for file descriptors.

type socket = Net.stream_socket
val await_readable : Unix.file_descr -> unit

await_readable fd blocks until fd is readable (or has an error).

val await_writable : Unix.file_descr -> unit

await_writable fd blocks until fd is writable (or has an error).

val sleep : float -> unit

sleep d sleeps for d seconds, allowing other fibers to run. This is can be useful for debugging (e.g. to introduce delays to trigger a race condition) without having to plumb Eio.Stdenv.mono_clock through your code. It can also be used in programs that don't care about tracking determinism.

val run_in_systhread : (unit -> 'a) -> 'a

run_in_systhread fn runs the function fn in a newly created system thread (a Thread.t). This allows blocking calls to be made non-blocking.

val pipe : Eio.Std.Switch.t -> source * sink

pipe sw returns a connected pair of flows src and sink. Data written to sink can be read from src. Note that, like all FDs created by Eio, they are both marked as close-on-exec by default.

module Process : sig ... end

Spawning child processes with extra control.

module Stdenv : sig ... end

The set of resources provided to a process on a Unix-compatible system.

module Private : sig ... end

API for Eio backends only.

module Ctf : sig ... end
\ No newline at end of file +Eio_unix (eio.Eio_unix)

Module Eio_unix

Extension of Eio for integration with OCaml's Unix module.

Note that OCaml's Unix module is not safe, and therefore care must be taken when using these functions. For example, it is possible to leak file descriptors this way, or to use them after they've been closed, allowing one module to corrupt a file belonging to an unrelated module.

type Eio.Exn.Backend.t +=
  1. | Unix_error of Unix.error * string * string
    (*

    Wrapper for embedding Unix.Unix_error errors.

    *)
module Fd : sig ... end

A safe wrapper for Unix.file_descr.

module Resource : sig ... end

Eio resources backed by an OS file descriptor.

module Net : sig ... end

Extended network API with support for file descriptors.

type source_ty = [
  1. | `Unix_fd
  2. | Eio.Resource.close_ty
  3. | Eio.Flow.source_ty
]
type sink_ty = [
  1. | `Unix_fd
  2. | Eio.Resource.close_ty
  3. | Eio.Flow.sink_ty
]
type 'a source = [> source_ty ] as 'a Eio.Std.r
type 'a sink = [> sink_ty ] as 'a Eio.Std.r
val await_readable : Unix.file_descr -> unit

await_readable fd blocks until fd is readable (or has an error).

val await_writable : Unix.file_descr -> unit

await_writable fd blocks until fd is writable (or has an error).

val sleep : float -> unit

sleep d sleeps for d seconds, allowing other fibers to run. This is can be useful for debugging (e.g. to introduce delays to trigger a race condition) without having to plumb Eio.Stdenv.mono_clock through your code. It can also be used in programs that don't care about tracking determinism.

val run_in_systhread : (unit -> 'a) -> 'a

run_in_systhread fn runs the function fn in a newly created system thread (a Thread.t). This allows blocking calls to be made non-blocking.

pipe sw returns a connected pair of flows src and sink. Data written to sink can be read from src. Note that, like all FDs created by Eio, they are both marked as close-on-exec by default.

module Process : sig ... end

Spawning child processes with extra control.

module Stdenv : sig ... end

The set of resources provided to a process on a Unix-compatible system.

module Private : sig ... end

API for Eio backends only.

module Ctf : sig ... end
module Pi : sig ... end
\ No newline at end of file diff --git a/eio/Eio_utils/.dummy b/eio/Eio_utils/.dummy deleted file mode 100644 index e69de29bb..000000000 diff --git a/eio/Eio_utils/Lf_queue/index.html b/eio/Eio_utils/Lf_queue/index.html index 58c7279b1..a6fd5ee0d 100644 --- a/eio/Eio_utils/Lf_queue/index.html +++ b/eio/Eio_utils/Lf_queue/index.html @@ -1,2 +1,2 @@ -Lf_queue (eio.Eio_utils.Lf_queue)

Module Eio_utils.Lf_queue

A lock-free multi-producer, single-consumer, thread-safe queue without support for cancellation. This makes a good data structure for a scheduler's run queue.

type 'a t

A queue of items of type 'a.

exception Closed
val create : unit -> 'a t

create () is a new empty queue.

val push : 'a t -> 'a -> unit

push t x adds x to the tail of the queue. This can be used safely by multiple producer domains, in parallel with the other operations.

  • raises Closed

    if t is closed.

val push_head : 'a t -> 'a -> unit

push_head t x inserts x at the head of the queue. This can only be used by the consumer (if run in parallel with pop, the item might be skipped).

  • raises Closed

    if t is closed and empty.

val pop : 'a t -> 'a option

pop t removes the head item from t and returns it. Returns None if t is currently empty.

  • raises Closed

    if t has been closed and is empty.

val is_empty : 'a t -> bool

is_empty t is true if calling pop would return None.

  • raises Closed

    if t has been closed and is empty.

val close : 'a t -> unit

close t marks t as closed, preventing any further items from being pushed.

\ No newline at end of file +Lf_queue (eio.Eio_utils.Lf_queue)

Module Eio_utils.Lf_queue

A lock-free multi-producer, single-consumer, thread-safe queue without support for cancellation. This makes a good data structure for a scheduler's run queue.

type 'a t

A queue of items of type 'a.

exception Closed
val create : unit -> 'a t

create () is a new empty queue.

val push : 'a t -> 'a -> unit

push t x adds x to the tail of the queue. This can be used safely by multiple producer domains, in parallel with the other operations.

  • raises Closed

    if t is closed.

val push_head : 'a t -> 'a -> unit

push_head t x inserts x at the head of the queue. This can only be used by the consumer (if run in parallel with pop, the item might be skipped).

  • raises Closed

    if t is closed and empty.

val pop : 'a t -> 'a option

pop t removes the head item from t and returns it. Returns None if t is currently empty.

  • raises Closed

    if t has been closed and is empty.

val is_empty : 'a t -> bool

is_empty t is true if calling pop would return None.

  • raises Closed

    if t has been closed and is empty.

val close : 'a t -> unit

close t marks t as closed, preventing any further items from being pushed.

\ No newline at end of file diff --git a/eio/Eio_utils/Suspended/index.html b/eio/Eio_utils/Suspended/index.html index 69c4283f4..2942f0912 100644 --- a/eio/Eio_utils/Suspended/index.html +++ b/eio/Eio_utils/Suspended/index.html @@ -1,2 +1,2 @@ -Suspended (eio.Eio_utils.Suspended)

Module Eio_utils.Suspended

A suspended fiber with its context.

module Ctf = Eio.Private.Ctf
type 'a t = {
  1. fiber : Eio.Private.Fiber_context.t;
  2. k : ('a, [ `Exit_scheduler ]) Stdlib.Effect.Deep.continuation;
}
val tid : 'a t -> Eio.Private.Ctf.id
val continue : 'a t -> 'b -> [ `Exit_scheduler ]
val discontinue : 'a t -> exn -> [ `Exit_scheduler ]
\ No newline at end of file +Suspended (eio.Eio_utils.Suspended)

Module Eio_utils.Suspended

A suspended fiber with its context.

module Ctf = Eio.Private.Ctf
type 'a t = {
  1. fiber : Eio.Private.Fiber_context.t;
  2. k : ('a, [ `Exit_scheduler ]) Stdlib.Effect.Deep.continuation;
}
val tid : 'a t -> Eio.Private.Ctf.id
val continue : 'a t -> 'b -> [ `Exit_scheduler ]
val discontinue : 'a t -> exn -> [ `Exit_scheduler ]
\ No newline at end of file diff --git a/eio/Eio_utils/Zzz/Key/index.html b/eio/Eio_utils/Zzz/Key/index.html index c29092b27..251b142fe 100644 --- a/eio/Eio_utils/Zzz/Key/index.html +++ b/eio/Eio_utils/Zzz/Key/index.html @@ -1,2 +1,2 @@ -Key (eio.Eio_utils.Zzz.Key)

Module Zzz.Key

A handle to a registered timer.

type t
\ No newline at end of file +Key (eio.Eio_utils.Zzz.Key)

Module Zzz.Key

A handle to a registered timer.

type t
\ No newline at end of file diff --git a/eio/Eio_utils/Zzz/index.html b/eio/Eio_utils/Zzz/index.html index 2b5df7270..2e21e8080 100644 --- a/eio/Eio_utils/Zzz/index.html +++ b/eio/Eio_utils/Zzz/index.html @@ -1,5 +1,5 @@ -Zzz (eio.Eio_utils.Zzz)

Module Eio_utils.Zzz

A set of timers.

module Key : sig ... end

A handle to a registered timer.

type t

A set of timers (implemented as a priority queue).

val create : unit -> t

create () is a fresh empty queue.

val add : t -> Mtime.t -> unit Suspended.t -> Key.t

add t time thread adds a new event, due at time, and returns its ID. You must use Eio.Private.Fiber_context.set_cancel_fn on thread before calling pop. Your cancel function should call remove (in addition to resuming thread).

val remove : t -> Key.t -> unit

remove t key removes an event previously added with add.

val pop : +Zzz (eio.Eio_utils.Zzz)

Module Eio_utils.Zzz

A set of timers.

module Key : sig ... end

A handle to a registered timer.

type t

A set of timers (implemented as a priority queue).

val create : unit -> t

create () is a fresh empty queue.

val add : t -> Mtime.t -> unit Suspended.t -> Key.t

add t time thread adds a new event, due at time, and returns its ID. You must use Eio.Private.Fiber_context.set_cancel_fn on thread before calling pop. Your cancel function should call remove (in addition to resuming thread).

val remove : t -> Key.t -> unit

remove t key removes an event previously added with add.

val pop : t -> now:Mtime.t -> [ `Due of unit Suspended.t | `Wait_until of Mtime.t | `Nothing ]

pop ~now t removes and returns the earliest thread due by now. It also clears the thread's cancel function. If no thread is due yet, it returns the time the earliest thread becomes due.

\ No newline at end of file diff --git a/eio/Eio_utils/index.html b/eio/Eio_utils/index.html index e0329ab68..2c8bbbc88 100644 --- a/eio/Eio_utils/index.html +++ b/eio/Eio_utils/index.html @@ -1,2 +1,2 @@ -Eio_utils (eio.Eio_utils)

Module Eio_utils

Utilities for implementing Eio event loops.

These aren't intended for users of Eio.

module Lf_queue : sig ... end

A lock-free multi-producer, single-consumer, thread-safe queue without support for cancellation. This makes a good data structure for a scheduler's run queue.

module Suspended : sig ... end

A suspended fiber with its context.

module Zzz : sig ... end

A set of timers.

\ No newline at end of file +Eio_utils (eio.Eio_utils)

Module Eio_utils

Utilities for implementing Eio event loops.

These aren't intended for users of Eio.

module Lf_queue : sig ... end

A lock-free multi-producer, single-consumer, thread-safe queue without support for cancellation. This makes a good data structure for a scheduler's run queue.

module Suspended : sig ... end

A suspended fiber with its context.

module Zzz : sig ... end

A set of timers.

\ No newline at end of file diff --git a/eio/index.html b/eio/index.html index f1b28a6c0..3550f8053 100644 --- a/eio/index.html +++ b/eio/index.html @@ -1,2 +1,2 @@ -index (eio.index)

eio index

Library eio

The entry point of this library is the module: Eio.

Library eio.core

The entry point of this library is the module: Eio__core.

Library eio.mock

The entry point of this library is the module: Eio_mock.

Library eio.unix

The entry point of this library is the module: Eio_unix.

Library eio.utils

The entry point of this library is the module: Eio_utils.

\ No newline at end of file +index (eio.index)

eio index

Library eio

The entry point of this library is the module: Eio.

Library eio.core

The entry point of this library is the module: Eio__core.

Library eio.mock

The entry point of this library is the module: Eio_mock.

Library eio.unix

The entry point of this library is the module: Eio_unix.

Library eio.utils

The entry point of this library is the module: Eio_utils.

\ No newline at end of file diff --git a/eio_linux/Eio_linux/.dummy b/eio_linux/Eio_linux/.dummy deleted file mode 100644 index e69de29bb..000000000 diff --git a/eio_linux/Eio_linux/Low_level/Process/index.html b/eio_linux/Eio_linux/Low_level/Process/index.html index 2679b8a69..6e09a3b06 100644 --- a/eio_linux/Eio_linux/Low_level/Process/index.html +++ b/eio_linux/Eio_linux/Low_level/Process/index.html @@ -1,2 +1,2 @@ -Process (eio_linux.Eio_linux.Low_level.Process)

Module Low_level.Process

type t

A child process.

module Fork_action = Eio_unix.Private.Fork_action

Setup actions to perform in the child process.

val spawn : sw:Eio.Std.Switch.t -> Fork_action.t list -> t

spawn ~sw actions forks a child process, which executes actions. The last action should be Fork_action.execve.

You will typically want to do Promise.await (exit_status child) after this.

  • parameter sw

    The child will be sent Sys.sigkill if sw finishes.

val signal : t -> int -> unit

signal t x sends signal x to t.

This is similar to doing Unix.kill t.pid x, except that it ensures no signal is sent after t has been reaped.

val pid : t -> int
val exit_status : t -> Unix.process_status Eio.Std.Promise.t

exit_status t is a promise for the process's exit status.

\ No newline at end of file +Process (eio_linux.Eio_linux.Low_level.Process)

Module Low_level.Process

type t

A child process.

module Fork_action = Eio_unix.Private.Fork_action

Setup actions to perform in the child process.

val spawn : sw:Eio.Std.Switch.t -> Fork_action.t list -> t

spawn ~sw actions forks a child process, which executes actions. The last action should be Fork_action.execve.

You will typically want to do Promise.await (exit_status child) after this.

  • parameter sw

    The child will be sent Sys.sigkill if sw finishes.

val signal : t -> int -> unit

signal t x sends signal x to t.

This is similar to doing Unix.kill t.pid x, except that it ensures no signal is sent after t has been reaped.

val pid : t -> int
val exit_status : t -> Unix.process_status Eio.Std.Promise.t

exit_status t is a promise for the process's exit status.

\ No newline at end of file diff --git a/eio_linux/Eio_linux/Low_level/index.html b/eio_linux/Eio_linux/Low_level/index.html index 1737d2ff1..13e1c47a6 100644 --- a/eio_linux/Eio_linux/Low_level/index.html +++ b/eio_linux/Eio_linux/Low_level/index.html @@ -1,5 +1,5 @@ -Low_level (eio_linux.Eio_linux.Low_level)

Module Eio_linux.Low_level

Low-level API for using uring directly.

val noop : unit -> unit

noop () performs a uring noop. This is only useful for benchmarking.

Time functions

val sleep_until : Mtime.t -> unit

sleep_until time blocks until the current time is time.

Fixed-buffer memory allocation functions

The size of the fixed buffer is set when calling run, which attempts to allocate a fixed buffer. However, that may fail due to resource limits.

val alloc_fixed : unit -> Uring.Region.chunk option

Allocate a chunk of memory from the fixed buffer.

Warning: The memory is NOT zeroed out.

Passing such memory to Linux can be faster than using normal memory, in certain cases. There is a limited amount of such memory, and this will return None if none is available at present.

val alloc_fixed_or_wait : unit -> Uring.Region.chunk

Like alloc_fixed, but if there are no chunks available then it waits until one is.

val free_fixed : Uring.Region.chunk -> unit
val with_chunk : fallback:(unit -> 'a) -> (Uring.Region.chunk -> 'a) -> 'a

with_chunk ~fallback fn runs fn chunk with a freshly allocated chunk and then frees it.

If no chunks are available, it runs fallback () instead.

File manipulation functions

val openat2 : +Low_level (eio_linux.Eio_linux.Low_level)

Module Eio_linux.Low_level

Low-level API for using uring directly.

val noop : unit -> unit

noop () performs a uring noop. This is only useful for benchmarking.

Time functions

val sleep_until : Mtime.t -> unit

sleep_until time blocks until the current time is time.

Fixed-buffer memory allocation functions

The size of the fixed buffer is set when calling run, which attempts to allocate a fixed buffer. However, that may fail due to resource limits.

val alloc_fixed : unit -> Uring.Region.chunk option

Allocate a chunk of memory from the fixed buffer.

Warning: The memory is NOT zeroed out.

Passing such memory to Linux can be faster than using normal memory, in certain cases. There is a limited amount of such memory, and this will return None if none is available at present.

val alloc_fixed_or_wait : unit -> Uring.Region.chunk

Like alloc_fixed, but if there are no chunks available then it waits until one is.

val free_fixed : Uring.Region.chunk -> unit
val with_chunk : fallback:(unit -> 'a) -> (Uring.Region.chunk -> 'a) -> 'a

with_chunk ~fallback fn runs fn chunk with a freshly allocated chunk and then frees it.

If no chunks are available, it runs fallback () instead.

File manipulation functions

val openat2 : sw:Eio.Std.Switch.t -> ?seekable:bool -> access:[ `R | `W | `RW ] -> diff --git a/eio_linux/Eio_linux/index.html b/eio_linux/Eio_linux/index.html index 439e2e89a..4ab252a98 100644 --- a/eio_linux/Eio_linux/index.html +++ b/eio_linux/Eio_linux/index.html @@ -1,5 +1,5 @@ -Eio_linux (eio_linux.Eio_linux)

Module Eio_linux

Eio backend using Linux's io_uring.

You will normally not use this module directly. Instead, use Eio_main.run to start an event loop and then use the API in the Eio module.

However, it is possible to use this module directly if you only want to support recent versions of Linux.

type fd := Eio_unix.Fd.t

Eio API

type source = Eio_unix.source
type sink = Eio_unix.sink
type stdenv = Eio_unix.Stdenv.base

Main Loop

val run : +Eio_linux (eio_linux.Eio_linux)

Module Eio_linux

Eio backend using Linux's io_uring.

You will normally not use this module directly. Instead, use Eio_main.run to start an event loop and then use the API in the Eio module.

However, it is possible to use this module directly if you only want to support recent versions of Linux.

type fd := Eio_unix.Fd.t

Main Loop

type stdenv = Eio_unix.Stdenv.base
val run : ?queue_depth:int -> ?n_blocks:int -> ?block_size:int -> diff --git a/eio_linux/index.html b/eio_linux/index.html index d69f86df0..925ecb29f 100644 --- a/eio_linux/index.html +++ b/eio_linux/index.html @@ -1,2 +1,2 @@ -index (eio_linux.index)

eio_linux index

Library eio_linux

The entry point of this library is the module: Eio_linux.

\ No newline at end of file +index (eio_linux.index)

eio_linux index

Library eio_linux

The entry point of this library is the module: Eio_linux.

\ No newline at end of file diff --git a/eio_main/Eio_main/.dummy b/eio_main/Eio_main/.dummy deleted file mode 100644 index e69de29bb..000000000 diff --git a/eio_main/Eio_main/index.html b/eio_main/Eio_main/index.html index 3180843f4..53eb2b7c5 100644 --- a/eio_main/Eio_main/index.html +++ b/eio_main/Eio_main/index.html @@ -1,2 +1,2 @@ -Eio_main (eio_main.Eio_main)

Module Eio_main

Select a suitable event loop for Eio.

val run : (Eio_unix.Stdenv.base -> 'a) -> 'a

run fn runs an event loop and then calls fn env within it.

env provides access to the process's environment (file-system, network, etc). env itself and the resources inside it can be shared safely between Eio domains.

When fn ends, the event loop finishes.

This should be called once, at the entry point of an application. It must not be called by libraries. Doing so would force the library to depend on Unix (making it unusable from unikernels or browsers), prevent the user from choosing their own event loop, and prevent using the library with other Eio libraries.

run will select an appropriate event loop for the current platform. On many systems, it will use Eio_posix.run.

On recent-enough versions of Linux, it will use Eio_linux.run. You can override this by setting the $EIO_BACKEND environment variable to either "linux", "posix" or "windows".

\ No newline at end of file +Eio_main (eio_main.Eio_main)

Module Eio_main

Select a suitable event loop for Eio.

val run : (Eio_unix.Stdenv.base -> 'a) -> 'a

run fn runs an event loop and then calls fn env within it.

env provides access to the process's environment (file-system, network, etc). env itself and the resources inside it can be shared safely between Eio domains.

When fn ends, the event loop finishes.

This should be called once, at the entry point of an application. It must not be called by libraries. Doing so would force the library to depend on Unix (making it unusable from unikernels or browsers), prevent the user from choosing their own event loop, and prevent using the library with other Eio libraries.

run will select an appropriate event loop for the current platform. On many systems, it will use Eio_posix.run.

On recent-enough versions of Linux, it will use Eio_linux.run. You can override this by setting the $EIO_BACKEND environment variable to either "linux", "posix" or "windows".

\ No newline at end of file diff --git a/eio_main/index.html b/eio_main/index.html index 69d25c193..2b25d6efa 100644 --- a/eio_main/index.html +++ b/eio_main/index.html @@ -1,2 +1,2 @@ -index (eio_main.index)

eio_main index

Library eio_main

The entry point of this library is the module: Eio_main.

\ No newline at end of file +index (eio_main.index)

eio_main index

Library eio_main

The entry point of this library is the module: Eio_main.

\ No newline at end of file diff --git a/eio_posix/Eio_posix/.dummy b/eio_posix/Eio_posix/.dummy deleted file mode 100644 index e69de29bb..000000000 diff --git a/eio_posix/Eio_posix/Low_level/Open_flags/index.html b/eio_posix/Eio_posix/Low_level/Open_flags/index.html index 7150247df..adaaedbd4 100644 --- a/eio_posix/Eio_posix/Low_level/Open_flags/index.html +++ b/eio_posix/Eio_posix/Low_level/Open_flags/index.html @@ -1,2 +1,2 @@ -Open_flags (eio_posix.Eio_posix.Low_level.Open_flags)

Module Low_level.Open_flags

type t
val rdonly : t
val rdwr : t
val wronly : t
val append : t
val creat : t
val directory : t
val dsync : t option
val excl : t
val noctty : t
val nofollow : t
val sync : t
val trunc : t
val resolve_beneath : t option
val path : t option
val empty : t
val (+) : t -> t -> t
\ No newline at end of file +Open_flags (eio_posix.Eio_posix.Low_level.Open_flags)

Module Low_level.Open_flags

type t
val rdonly : t
val rdwr : t
val wronly : t
val append : t
val creat : t
val directory : t
val dsync : t option
val excl : t
val noctty : t
val nofollow : t
val sync : t
val trunc : t
val resolve_beneath : t option
val path : t option
val empty : t
val (+) : t -> t -> t
\ No newline at end of file diff --git a/eio_posix/Eio_posix/Low_level/Process/index.html b/eio_posix/Eio_posix/Low_level/Process/index.html index 5680b145f..f510e9e47 100644 --- a/eio_posix/Eio_posix/Low_level/Process/index.html +++ b/eio_posix/Eio_posix/Low_level/Process/index.html @@ -1,2 +1,2 @@ -Process (eio_posix.Eio_posix.Low_level.Process)

Module Low_level.Process

type t

A child process.

module Fork_action = Eio_unix.Private.Fork_action

Setup actions to perform in the child process.

val spawn : sw:Eio.Std.Switch.t -> Fork_action.t list -> t

spawn ~sw actions forks a child process, which executes actions. The last action should be Fork_action.execve.

You will typically want to do Promise.await (exit_status child) after this.

  • parameter sw

    The child will be sent Sys.sigkill if sw finishes.

val signal : t -> int -> unit

signal t x sends signal x to t.

This is similar to doing Unix.kill t.pid x, except that it ensures no signal is sent after t has been reaped.

val pid : t -> int
val exit_status : t -> Unix.process_status Eio.Std.Promise.t

exit_status t is a promise for the process's exit status.

\ No newline at end of file +Process (eio_posix.Eio_posix.Low_level.Process)

Module Low_level.Process

type t

A child process.

module Fork_action = Eio_unix.Private.Fork_action

Setup actions to perform in the child process.

val spawn : sw:Eio.Std.Switch.t -> Fork_action.t list -> t

spawn ~sw actions forks a child process, which executes actions. The last action should be Fork_action.execve.

You will typically want to do Promise.await (exit_status child) after this.

  • parameter sw

    The child will be sent Sys.sigkill if sw finishes.

val signal : t -> int -> unit

signal t x sends signal x to t.

This is similar to doing Unix.kill t.pid x, except that it ensures no signal is sent after t has been reaped.

val pid : t -> int
val exit_status : t -> Unix.process_status Eio.Std.Promise.t

exit_status t is a promise for the process's exit status.

\ No newline at end of file diff --git a/eio_posix/Eio_posix/Low_level/index.html b/eio_posix/Eio_posix/Low_level/index.html index 818ea680e..b3824b2b2 100644 --- a/eio_posix/Eio_posix/Low_level/index.html +++ b/eio_posix/Eio_posix/Low_level/index.html @@ -1,10 +1,20 @@ -Low_level (eio_posix.Eio_posix.Low_level)

Module Eio_posix.Low_level

Low-level API for making POSIX calls directly.

This module provides an effects-based API for calling POSIX functions.

Normally it's better to use the cross-platform Eio APIs instead, which uses these functions automatically where appropriate.

These functions mostly copy the POSIX APIs directly, except that:

  1. They suspend the calling fiber instead of returning EAGAIN or similar.
  2. They handle EINTR by automatically restarting the call.
  3. They wrap Unix.file_descr in Fd, to avoid use-after-close bugs.
  4. They attach new FDs to switches, to avoid resource leaks.
type fd := Eio_unix.Fd.t
val await_readable : fd -> unit
val await_writable : fd -> unit
val sleep_until : Mtime.t -> unit
val read : fd -> bytes -> int -> int -> int
val write : fd -> bytes -> int -> int -> int
val socket : +Low_level (eio_posix.Eio_posix.Low_level)

Module Eio_posix.Low_level

Low-level API for making POSIX calls directly.

This module provides an effects-based API for calling POSIX functions.

Normally it's better to use the cross-platform Eio APIs instead, which uses these functions automatically where appropriate.

These functions mostly copy the POSIX APIs directly, except that:

  1. They suspend the calling fiber instead of returning EAGAIN or similar.
  2. They handle EINTR by automatically restarting the call.
  3. They wrap Unix.file_descr in Fd, to avoid use-after-close bugs.
  4. They attach new FDs to switches, to avoid resource leaks.
type fd := Eio_unix.Fd.t
val await_readable : fd -> unit
val await_writable : fd -> unit
val sleep_until : Mtime.t -> unit
val read : fd -> bytes -> int -> int -> int
val write : fd -> bytes -> int -> int -> int
val socket : sw:Eio.Std.Switch.t -> Unix.socket_domain -> Unix.socket_type -> int -> - fd
val connect : fd -> Unix.sockaddr -> unit
val accept : sw:Eio.Std.Switch.t -> fd -> fd * Unix.sockaddr
val shutdown : fd -> Unix.shutdown_command -> unit
val recv_msg : fd -> Cstruct.t array -> Unix.sockaddr * int
val send_msg : fd -> ?dst:Unix.sockaddr -> Cstruct.t array -> int
val getrandom : Cstruct.t -> unit
val fstat : fd -> Unix.LargeFile.stats
val lstat : string -> Unix.LargeFile.stats
val realpath : string -> string
val mkdir : ?dirfd:fd -> mode:int -> string -> unit
val rename : ?old_dir:fd -> string -> ?new_dir:fd -> string -> unit
val readdir : string -> string array
val readv : fd -> Cstruct.t array -> int
val writev : fd -> Cstruct.t array -> int
val preadv : file_offset:Optint.Int63.t -> fd -> Cstruct.t array -> int
val pwritev : file_offset:Optint.Int63.t -> fd -> Cstruct.t array -> int
val pipe : sw:Eio.Std.Switch.t -> fd * fd
module Open_flags : sig ... end
val openat : + fd
val connect : fd -> Unix.sockaddr -> unit
val accept : sw:Eio.Std.Switch.t -> fd -> fd * Unix.sockaddr
val shutdown : fd -> Unix.shutdown_command -> unit
val recv_msg : fd -> Cstruct.t array -> Unix.sockaddr * int
val recv_msg_with_fds : + sw:Eio.Std.Switch.t -> + max_fds:int -> + fd -> + Cstruct.t array -> + Unix.sockaddr * int * fd list
val send_msg : + fd -> + ?fds:fd list -> + ?dst:Unix.sockaddr -> + Cstruct.t array -> + int
val getrandom : Cstruct.t -> unit
val fstat : fd -> Unix.LargeFile.stats
val lstat : string -> Unix.LargeFile.stats
val realpath : string -> string
val mkdir : ?dirfd:fd -> mode:int -> string -> unit
val rename : ?old_dir:fd -> string -> ?new_dir:fd -> string -> unit
val readdir : string -> string array
val readv : fd -> Cstruct.t array -> int
val writev : fd -> Cstruct.t array -> int
val preadv : file_offset:Optint.Int63.t -> fd -> Cstruct.t array -> int
val pwritev : file_offset:Optint.Int63.t -> fd -> Cstruct.t array -> int
val pipe : sw:Eio.Std.Switch.t -> fd * fd
module Open_flags : sig ... end
val openat : ?dirfd:fd -> sw:Eio.Std.Switch.t -> mode:int -> diff --git a/eio_posix/Eio_posix/index.html b/eio_posix/Eio_posix/index.html index 556ed5c25..1c23c003d 100644 --- a/eio_posix/Eio_posix/index.html +++ b/eio_posix/Eio_posix/index.html @@ -1,2 +1,2 @@ -Eio_posix (eio_posix.Eio_posix)

Module Eio_posix

Fallback Eio backend for POSIX systems.

type stdenv = Eio_unix.Stdenv.base

The type of the standard set of resources available on POSIX systems.

val run : (stdenv -> 'a) -> 'a

run main runs an event loop and calls main stdenv inside it.

For portable code, you should use Eio_main.run instead, which will call this for you if appropriate.

module Low_level : sig ... end

Low-level API for making POSIX calls directly.

\ No newline at end of file +Eio_posix (eio_posix.Eio_posix)

Module Eio_posix

Fallback Eio backend for POSIX systems.

type stdenv = Eio_unix.Stdenv.base

The type of the standard set of resources available on POSIX systems.

val run : (stdenv -> 'a) -> 'a

run main runs an event loop and calls main stdenv inside it.

For portable code, you should use Eio_main.run instead, which will call this for you if appropriate.

module Low_level : sig ... end

Low-level API for making POSIX calls directly.

\ No newline at end of file diff --git a/eio_posix/index.html b/eio_posix/index.html index 7b90817e9..f903af782 100644 --- a/eio_posix/index.html +++ b/eio_posix/index.html @@ -1,2 +1,2 @@ -index (eio_posix.index)

eio_posix index

Library eio_posix

The entry point of this library is the module: Eio_posix.

\ No newline at end of file +index (eio_posix.index)

eio_posix index

Library eio_posix

The entry point of this library is the module: Eio_posix.

\ No newline at end of file diff --git a/eio_windows/index.html b/eio_windows/index.html index 3bda19958..343d8d67e 100644 --- a/eio_windows/index.html +++ b/eio_windows/index.html @@ -1,2 +1,2 @@ -index (eio_windows.index)

eio_windows index

\ No newline at end of file +index (eio_windows.index)

eio_windows index

\ No newline at end of file diff --git a/index.html b/index.html index 373a00b5b..aacefbd83 100644 --- a/index.html +++ b/index.html @@ -11,11 +11,11 @@

OCaml package documentation

    -
  1. eio v0.11
  2. -
  3. eio_linux v0.11
  4. -
  5. eio_main v0.11
  6. -
  7. eio_posix v0.11
  8. -
  9. eio_windows v0.11
  10. +
  11. eio v0.11-43-gad7149d
  12. +
  13. eio_linux v0.11-43-gad7149d
  14. +
  15. eio_main v0.11-43-gad7149d
  16. +
  17. eio_posix v0.11-43-gad7149d
  18. +
  19. eio_windows v0.11-43-gad7149d