package async_unix

  1. Overview
  2. Docs
Monadic concurrency library

Install

Dune Dependency

Authors

Maintainers

Sources

async_unix-v0.16.0.tar.gz
sha256=a6a86202acea433b5c739ac20190a9a364da9d9eb7ebd402f517b8c58983839b

doc/async_unix.thread_safe_pipe/Thread_safe_pipe/If_closed/index.html

Module Thread_safe_pipe.If_closedSource

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.

The alternatives are to Raise on a closed pipe, or Return a variant indicating whether the pipe is closed. This allows lightweight syntax for calls that want to raise if the pipe is closed:

  write t a ~if_closed:Raise 

It also allows lightweight syntax for calls that want to match on whether the pipe was closed:

  match write t a ~if_closed:Return with
  | Closed  -> ...
  | Written -> ... 

Returning a variant is essential when one wants to distinguish a closed pipe from other errors. Also, since pipe-writing functions acquire the Async lock, it would be incorrect (due to races) to check is_closed prior to the lock acquisition.

Sourcetype 'a t =
  1. | Raise : unit t
  2. | Return : Written_or_closed.t t
OCaml

Innovation. Community. Security.