Fix spurious wakeups in ThreadManager test sleep
The ThreadManager load test used Monitor::wait() to sleep, which can return early on spurious wakeups. That occasionally produced zero-duration tasks and tripped the `delta > 0` assertion in CI. Switching the test helper to `std::this_thread::sleep_for` makes the sleep deterministic and stops the intermittent assertion failure.
diff --git a/lib/cpp/test/concurrency/ThreadManagerTests.h b/lib/cpp/test/concurrency/ThreadManagerTests.h
index b33fc27..d0494ec 100644
--- a/lib/cpp/test/concurrency/ThreadManagerTests.h
+++ b/lib/cpp/test/concurrency/ThreadManagerTests.h
@@ -27,6 +27,8 @@
#include <set>
#include <iostream>
#include <stdint.h>
+#include <chrono>
+#include <thread>
namespace apache {
namespace thrift {
@@ -42,16 +44,7 @@
}
static void sleep_(int64_t millisec) {
- Monitor _sleep;
- Synchronized s(_sleep);
-
- try {
- _sleep.wait(millisec);
- } catch (TimedOutException&) {
- ;
- } catch (...) {
- assert(0);
- }
+ std::this_thread::sleep_for(std::chrono::milliseconds(millisec));
}
class ThreadManagerTests {