Use MemoryIdler in SaturatingSemaphore
[folly.git] / folly / synchronization / SaturatingSemaphore.h
index 8d40b85067719171c1f70f29ebdc0b678a705c5a..bc0eba659ad6785e7bef92ab3f59afce0aef7705 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <folly/Likely.h>
 #include <folly/detail/Futex.h>
+#include <folly/detail/MemoryIdler.h>
 #include <folly/portability/Asm.h>
 #include <folly/synchronization/WaitOptions.h>
 
@@ -304,11 +305,7 @@ FOLLY_NOINLINE bool SaturatingSemaphore<MayBlock, Atom>::tryWaitSlow(
             continue;
           }
         }
-        if (deadline == std::chrono::time_point<Clock, Duration>::max()) {
-          state_.futexWait(BLOCKED);
-        } else {
-          state_.futexWaitUntil(BLOCKED, deadline);
-        }
+        detail::MemoryIdler::futexWaitUntil(state_, BLOCKED, deadline);
       }
     }
     asm_volatile_pause();