diff options
-rw-r--r-- | src/mongo/db/stats/resource_consumption_metrics_test.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mongo/db/stats/resource_consumption_metrics_test.cpp b/src/mongo/db/stats/resource_consumption_metrics_test.cpp index 3b14309fd08..4598e411b71 100644 --- a/src/mongo/db/stats/resource_consumption_metrics_test.cpp +++ b/src/mongo/db/stats/resource_consumption_metrics_test.cpp @@ -601,9 +601,15 @@ TEST_F(ResourceConsumptionMetricsTest, CpuNanos) { // Helper to busy wait. auto spinFor = [&](Milliseconds millis) { - auto deadline = Date_t::now().toDurationSinceEpoch() + millis; - while (Date_t::now().toDurationSinceEpoch() < deadline) { + AtomicWord<bool> mayJoin{false}; + stdx::thread blocker([&] { + sleepFor(millis); + mayJoin.store(true); + }); + while (!mayJoin.load()) { + // Busy wait for the blocker thread. } + blocker.join(); }; { |