ligo/lib_stdlib_lwt/lwt_dropbox.mli
Grégoire Henry b6449cae87 Jbuilder: split src/utils/ in multiple OPAM packages
* `lib_stdlib`: basic extended OCaml stdlib and generic data structures

* `lib_data_encoding`: almost independant 'Data_encoding'
* `lib_error_monad`: almost independant 'Error_monad'

* `lib_stdlib_lwt`: extended Lwt library
* `lib_crypto`: all the crypto stuff (hashing, signing, cryptobox).

* `lib_base`:
  - basic type definitions (Block_header, Operation, ...)
  - a module `TzPervasives` to bind them all and to be the
    single module opened everywhere.

In the process, I splitted `Tezos_data` and `Hash` in multiple
submodules, thus removing a lot of `-open`.

The following two modules may not have found their place yet:
- Base58 (currently in `lib_crypto`)
- Cli_entries (currently in `lib_stdlib_lwt`)
2017-12-04 16:05:54 +01:00

47 lines
1.9 KiB
OCaml

(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2017. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
(** A 'dropbox' with a single element. *)
type 'a t
(** Type of dropbox holding a value of type ['a] *)
val create: unit -> 'a t
(** Create an empty dropbox. *)
val put: 'a t -> 'a -> unit
(** Put an element inside the dropbox. If the dropbox was already
containing an element, the old element is replaced by the new one.
The function might return [Closed] if the dropbox has been closed
with [close]. *)
val take: 'a t -> 'a Lwt.t
(** Wait until the dropbox contains an element, then returns the elements.
The elements is removed from the dropbox. The function might return
[Closed] if the dropbox is empty and closed. *)
val take_with_timeout: float -> 'a t -> 'a option Lwt.t
(** Like [take] except that it returns [None] after [timeout seconds]
if the dropbox is still empty. *)
val peek: 'a t -> 'a option
(** Read the current element of the dropbox without removing it. It
immediatly returns [None] if the dropbox is empty. *)
exception Closed
(** The exception returned when trying to access a 'closed' dropbox. *)
val close: 'a t -> unit
(** Close the dropox. It terminates all the waiting reader with the
exception [Closed]. All further read or write will also immediatly
fail with [Closed], except if the dropbox is not empty when
[close] is called. In that can, a single (and last) [take] will
succeed. *)