package eio

  1. Overview
  2. Docs
On This Page
  1. Closing
Effect-based direct-style IO API for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

eio-0.11.tbz
sha256=0c33742074562631677886f4fe4a02f9672cec94297ff85c2ed854db5baa71aa
sha512=590843cb5fb3906fd5ab9911d29206172d164a53c48e635871a23c95d4cdce8ae0999480471187fdddee8c9c523148911ca140feabde6a826c317671a3b33090

doc/eio/Eio/Generic/index.html

Module Eio.GenericSource

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

Sourcetype 'a ty = ..

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

Sourceclass type t = object ... end
Sourceval 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.

Sourceclass type close = object ... end
Sourceval 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.