package fuseau

  1. Overview
  2. Docs

Module Fuseau.ChanSource

Basic channels

Sourcetype 'a t

Basic channel for values of type 'a

Sourceval is_empty : _ t -> bool
Sourceval size : _ t -> int

Current number of items in the channel

Sourceval create : ?max_size:int -> unit -> 'a t

New channel.

  • parameter max_size

    if specified, writers will block when trying to push into a channel

Sourceexception Closed
Sourceval close : _ t -> unit

Close the channel. Calls to receive_exn will still succeed as long as items remain in the channel, until the channel is entirely drained; then they fail with Closed.

Sourceval receive : 'a t -> 'a option

receive c receives an item from c. Suspends if the channel is empty but not closed. Returns None if the channel is empty and closed.

Sourceval receive_exn : 'a t -> 'a

receive_exn c receives an item from the channel. Suspends if the channel is empty and non-closed.

  • raises Closed

    if the channel is empty and closed

Sourceval send : 'a t -> 'a -> unit

send c x sends x over the channel c. This might suspend the current fiber if the channel is full.

Sourceval ev_send : 'a t -> 'a -> unit Event.t

ev_send c x is an event that sends x into c when there is room for it

Sourceval ev_receive : 'a t -> 'a Event.t

ev_receive c is an event that resolves by receiving a value x from c when c is non empty

OCaml

Innovation. Community. Security.