From 71026f9692be5ef7d8eccdb7617b98e2989ef9c1 Mon Sep 17 00:00:00 2001 From: Filip Tibell <filip.tibell@gmail.com> Date: Tue, 13 Feb 2024 11:10:44 +0100 Subject: [PATCH] Fix missed items in thread queue --- lib/queue.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/queue.rs b/lib/queue.rs index eb10928..aabb259 100644 --- a/lib/queue.rs +++ b/lib/queue.rs @@ -60,7 +60,12 @@ impl ThreadQueue { #[inline] pub async fn wait_for_item(&self) { if self.queue.is_empty() { - self.event.listen().await; + let listener = self.event.listen(); + // NOTE: Need to check again, we could have gotten + // new queued items while creating our listener + if self.queue.is_empty() { + listener.await; + } } }