From 0b3cdc30e5f940185fc5b3902ccf9931a22d14f6 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 2 Aug 2024 16:05:33 -0700 Subject: [PATCH] Fixing multithreaded test At some point I broke this test without realizing it. If you were lucky, the test passed immediatly. If you were unlucky, integer underflow meant the test would never finish. Thankfully after fixing the logic issue with tracking outstanding work, the test still passes -- thanks in part to this being tested in other environments pretty thoroughly at this point. --- tests/multithreaded.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/multithreaded.rs b/tests/multithreaded.rs index fe7c5f5..5afb163 100644 --- a/tests/multithreaded.rs +++ b/tests/multithreaded.rs @@ -37,6 +37,7 @@ fn round_robin() { .0 .send(Command::Enqueue(Root::new(WorkUnit::default(), &guard))) .expect("worker disconnected early"); + outstanding.push_one(); } drop(guard); @@ -76,7 +77,7 @@ fn thread_worker( if queue.items.is_empty() { next_thread .send(Command::Work) - .expect("next thread disconnted"); + .expect("next thread disconnected"); } else { let work = match queue.items[0].as_root(&guard) { Some(work) => { @@ -119,6 +120,10 @@ impl OutstandingWork { fn complete_one(&self) { self.0.fetch_sub(1, Ordering::Acquire); } + + fn push_one(&self) { + self.0.fetch_add(1, Ordering::Acquire); + } } struct WorkUnit {