mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-07 18:37:56 -05:00
fix bounded queue: try_pop should drain a closed queue
This commit is contained in:
parent
0eb27174f0
commit
374a67c97a
1 changed files with 7 additions and 5 deletions
|
|
@ -47,11 +47,13 @@ end = struct
|
|||
|
||||
let try_pop (self : 'a t) : 'a BQ.pop_result =
|
||||
UM.protect self.mutex @@ fun () ->
|
||||
(* first, try to pop the queue. We want to drain it even if it's closed. *)
|
||||
try `Item (Queue.pop self.q)
|
||||
with Queue.Empty ->
|
||||
if self.closed then
|
||||
`Closed
|
||||
else (
|
||||
try `Item (Queue.pop self.q) with Queue.Empty -> `Empty
|
||||
)
|
||||
else
|
||||
`Empty
|
||||
|
||||
let push_while_not_full ~high_watermark (self : 'a t) (xs : 'a list) :
|
||||
push_res =
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue