Moonpool.Chan
Channels.
The channels have bounded size. Push/pop return futures or can use effects to provide an await
-friendly version.
The channels became bounded since @0.7 .
val create : max_size:int -> unit -> 'a t
Create a channel.
val try_push : 'a t -> 'a -> bool
try_push chan x
pushes x
into chan
. This does not block. Returns true
if it succeeded in pushing.
val try_pop : 'a t -> 'a option
try_pop chan
pops and return an element if one is available immediately. Otherwise it returns None
.
val close : _ t -> unit
Close the channel. Further push and pop calls will fail. This is idempotent.
val push : 'a t -> 'a -> unit
Push the value into the channel, suspending the current task if the channel is currently full.
val pop : 'a t -> 'a
Pop an element. This might suspend the current task if the channel is currently empty.