mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-05 19:00:33 -05:00
add Chan.pop_await
This commit is contained in:
parent
12df71c3ab
commit
68e744290b
2 changed files with 18 additions and 0 deletions
|
|
@ -182,3 +182,12 @@ let close (self : _ t) : unit =
|
|||
do
|
||||
Domain_.relax ()
|
||||
done
|
||||
|
||||
[@@@ifge 5.0]
|
||||
|
||||
let pop_await self =
|
||||
match try_pop self with
|
||||
| Some x -> x
|
||||
| None -> Fut.await @@ pop self
|
||||
|
||||
[@@@endif]
|
||||
|
|
|
|||
|
|
@ -41,3 +41,12 @@ val pop_block_exn : 'a t -> 'a
|
|||
val close : _ t -> unit
|
||||
(** Close the channel. Further push and pop calls will fail.
|
||||
This is idempotent. *)
|
||||
|
||||
[@@@ifge 5.0]
|
||||
|
||||
val pop_await : 'a t -> 'a
|
||||
(** Like {!pop} but suspends the current thread until an element is
|
||||
available. See {!Fut.await} for more details.
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
[@@@endif]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue