package async_unix

  1. Overview
  2. Docs
Monadic concurrency library

Install

Dune Dependency

Authors

Maintainers

Sources

async_unix-v0.13.0.tar.gz
sha256=6ad4b4271b1a28150e2e6ddddcdc7e6df2c144c3221be3fa64d400e9500ebe9c
md5=1f150e28eeca17ebf3ff65641132c26d

doc/async_unix.thread_safe_pipe/Thread_safe_pipe/index.html

Module Thread_safe_pipe

A thread-safe pipe is a thread-safe interface to the write end of a normal Async.Pipe. All operations except for create must be called from threads outside Async, while create can be called from inside or outside Async.

For Pipe functions that return a unit Deferred.t, the analog in Thread_safe_pipe blocks.

For documentation of wakeup_scheduler, see the Thread_safe module.

type 'a t

The writer end of the pipe.

val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a t -> Ppx_sexp_conv_lib.Sexp.t
val create : unit -> 'a Async_kernel.Pipe.Reader.t * 'a t

create () returns a reader end, which must be used inside Async, and a writer end, which must be used outside Async. create can be called inside or outside Async.

All the following functions must be called outside Async. They behave as their counterpart in the Pipe module.

val pushback : _ t -> unit

pushback writer blocks the current thread until the pipe is empty or closed.

module Written_or_closed : sig ... end
module If_closed : sig ... end

Functions that write elements to the pipe take an If_closed.t argument to specify how to deal with the possibility that the pipe is closed.

val transfer_in_without_pushback : ?wakeup_scheduler:bool -> 'a t -> from:'a Core.Queue.t -> if_closed:'b If_closed.t -> 'b

transfer_in_without_pushback' and write_without_pushback transfer the element(s) into the pipe and return immediately.

val write_without_pushback : ?wakeup_scheduler:bool -> 'a t -> 'a -> if_closed:'b If_closed.t -> 'b
val transfer_in : 'a t -> from:'a Core.Queue.t -> if_closed:'b If_closed.t -> 'b

transfer_in and write transfer the element(s) into the pipe and block the current thread until the pipe is empty or closed (like pushback).

val write : 'a t -> 'a -> if_closed:'b If_closed.t -> 'b
val close : _ t -> unit
val is_closed : _ t -> bool
val closed : _ t -> unit

closed writer blocks the current thread until the pipe is closed.

OCaml

Innovation. Community. Security.