package moonpool
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=c4a1f974200530ab7f6014de3a369fdbb260ff454183640f32e51ba3fec51b15
sha512=865daabb96e3d60f88ecee9fc9030dad8b257fff4121b404e882d8a8d6687b737beb6e22366f52eb14e770dfab28b326853a1d3d883fa19bbd791d8450b40f8b
doc/moonpool/Moonpool/Bounded_queue/index.html
Module Moonpool.Bounded_queue
Source
A blocking queue of finite size.
This queue, while still using locks underneath (like the regular blocking queue) should be enough for usage under reasonable contention.
The bounded size is helpful whenever some form of backpressure is desirable: if the queue is used to communicate between producer(s) and consumer(s), the consumer(s) can limit the rate at which producer(s) send new work down their way. Whenever the queue is full, means that producer(s) will have to wait before pushing new work.
A bounded queue.
push q x
pushes x
at the end of the queue. If q
is full, this will block until there is room for x
.
try_push q x
attempts to push x
into q
, but abandons if it cannot acquire q
or if q
is full.
pop q
pops the first element off q
. It blocks if q
is empty, until some element becomes available.
try_pop ~force_lock q
tries to pop the first element, or returns None
if no element is available or if it failed to acquire q
.
transfer bq q2
transfers all elements currently available in bq
into local queue q2
, and clears bq
, atomically. It blocks if bq
is empty.
See Bb_queue.transfer
for more details.
to_iter q
returns an iterator over all items in the queue. This might not terminate if q
is never closed.