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 =
|
let try_pop (self : 'a t) : 'a BQ.pop_result =
|
||||||
UM.protect self.mutex @@ fun () ->
|
UM.protect self.mutex @@ fun () ->
|
||||||
if self.closed then
|
(* first, try to pop the queue. We want to drain it even if it's closed. *)
|
||||||
`Closed
|
try `Item (Queue.pop self.q)
|
||||||
else (
|
with Queue.Empty ->
|
||||||
try `Item (Queue.pop self.q) with Queue.Empty -> `Empty
|
if self.closed then
|
||||||
)
|
`Closed
|
||||||
|
else
|
||||||
|
`Empty
|
||||||
|
|
||||||
let push_while_not_full ~high_watermark (self : 'a t) (xs : 'a list) :
|
let push_while_not_full ~high_watermark (self : 'a t) (xs : 'a list) :
|
||||||
push_res =
|
push_res =
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue