package eio_linux

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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.

module FD : sig ... end

Wrap Unix.file_descr to track whether it has been closed.

Eio API

type has_fd = < fd : FD.t >
type source = < Eio.Flow.source ; Eio.Flow.close ; has_fd >
type sink = < Eio.Flow.sink ; Eio.Flow.close ; has_fd >
type stdenv = < stdin : source ; stdout : sink ; stderr : sink ; net : Eio.Net.t ; domain_mgr : Eio.Domain_manager.t ; clock : Eio.Time.clock ; fs : Eio.Fs.dir Eio.Path.t ; cwd : Eio.Fs.dir Eio.Path.t ; secure_random : Eio.Flow.source ; debug : Eio.Debug.t >
val get_fd : < has_fd.. > -> FD.t
val get_fd_opt : Eio.Generic.t -> FD.t option
val pipe : Eio.Std.Switch.t -> source * sink

pipe sw is a source-sink pair (r, w), where data written to w can be read from r. It is implemented as a Unix pipe.

Main Loop

val run : ?queue_depth:int -> ?n_blocks:int -> ?block_size:int -> ?polling_timeout:int -> ?fallback:([ `Msg of string ] -> 'a) -> (stdenv -> 'a) -> 'a

Run an event loop using io_uring.

Uses Uring.create to create the io_uring, and Uring.set_fixed_buffer to set a block_size * n_blocks fixed buffer.

Note that if Linux resource limits prevent the requested fixed buffer from being allocated then run will continue without one (and log a warning).

For portable code, you should use Eio_main.run instead, which will use this automatically if running on Linux with a recent-enough kernel version.

  • parameter fallback

    Call this instead if io_uring is not available for some reason. The argument is a message describing the problem (for logging). The default simply raises an exception.

Low-level API

module Low_level : sig ... end

Low-level API for using uring directly.

OCaml

Innovation. Community. Security.