package fuseau

  1. Overview
  2. Docs

Basic channels

type 'a t

Basic channel for values of type 'a

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

Current number of items in the channel

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

New channel.

  • parameter max_size

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

exception Closed
val 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.

val 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.

val 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

val 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.

val 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

val 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


Innovation. Community. Security.