diff --git a/util/thread_status_util_debug.cc b/util/thread_status_util_debug.cc index b91bc4ee3..94b19f3d2 100644 --- a/util/thread_status_util_debug.cc +++ b/util/thread_status_util_debug.cc @@ -20,10 +20,11 @@ void ThreadStatusUtil::TEST_SetStateDelay( states_delay[state].store(micro, std::memory_order_relaxed); } -void ThreadStatusUtil::TEST_StateDelay( - const ThreadStatus::StateType state) { - Env::Default()->SleepForMicroseconds( - states_delay[state].load(std::memory_order_relaxed)); +void ThreadStatusUtil::TEST_StateDelay(const ThreadStatus::StateType state) { + auto delay = states_delay[state].load(std::memory_order_relaxed); + if (delay > 0) { + Env::Default()->SleepForMicroseconds(delay); + } } #endif // !NDEBUG