package octez-distributed-internal

  1. Overview
  2. Docs
type 'a t

The monadic light weight thread type returning value 'a.

type 'a stream

An unbounded stream holding values of 'a.

type input_channel

A type to represent a non-blocking input channel

type output_channel

A type to represent a non-blocking output channel

type server

A type to represent a server

exception Timeout

Exception raised by timeout operation

type level =
  1. | Debug
  2. | Info
  3. | Warning
  4. | Error
    (*

    Type to represent levels of a log message.

    *)
val lib_name : string

The name of the implementation, for logging purposes.

val lib_version : string

The version implementation, for logging purposes.

val lib_description : string

A description of the implementation (e.g., the url of the code repository ), for logging purposes.

val return : 'a -> 'a t

return v creates a light weight thread returning v.

val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

bind t f is a thread which first waits for the thread t to terminate and then, if the thread succeeds, behaves as the application of function f to the return value of t. If the thread t fails, bind t f also fails, with the same exception.

val fail : exn -> 'a t

fail e is a thread that fails with the exception e.

val catch : (unit -> 'a t) -> (exn -> 'a t) -> 'a t

catch t f is a thread that behaves as the thread t () if this thread succeeds. If the thread t () fails with some exception, catch t f behaves as the application of f to this exception.

val async : (unit -> unit t) -> unit

async f starts a thread without waiting for the result.

val create_stream : unit -> 'a stream * ('a option -> unit)

create () returns a new stream and a push function.

val get : 'a stream -> 'a option t

get st removes and returns the first element of the stream, if any. Will block if the stream is empty.

val stream_append : 'a stream -> 'a stream -> 'a stream

stream_append s1 s2 returns a stream which returns all elements of s1, then all elements of s2.

val close_input : input_channel -> unit t

close ch closes the given channel immediately.

val close_output : output_channel -> unit t

close ch closes the given channel. It performs all pending actions, flushes it and closes it.

val read_value : input_channel -> 'a t

read_value ic reads a marshalled value from ic.

val write_value : output_channel -> ?flags:Marshal.extern_flags list -> 'a -> unit t

write_value oc ?flags x marshals the value x to oc.

val open_connection : Unix.sockaddr -> (input_channel * output_channel) t

open_connection addr opens a connection to the given address and returns two channels for using it.

val establish_server : ?backlog:int -> Unix.sockaddr -> (Unix.sockaddr -> (input_channel * output_channel) -> unit t) -> server t

establish_server ?backlog sockaddr f creates a server which will listen for incoming connections. New connections are passed to f. Note that f must not raise any exception. Backlog is the argument passed to Lwt_unix.listen.

val shutdown_server : server -> unit t

shutdown_server server will shutdown server.

val log : level -> (unit -> string) -> unit t

log level message_formatter logs a message at the specified level using the formatter provided.

val sleep : float -> unit t

sleep d is a thread that remains suspended for d seconds and then terminates.

val timeout : float -> 'a t

timeout d is a thread that remains suspended for d seconds and then fails with ​Distributed.Nonblock_io.Timeout.

val pick : 'a t list -> 'a t

pick l behaves as the first thread in l to terminate. If several threads are already terminated, one is chosen at random. Cancels all sleeping threads when one terminates.

val at_exit : (unit -> unit t) -> unit

at_exit fn will call fn on program exit.

OCaml

Innovation. Community. Security.