Commit 729928e7 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Use MemoryIdler in SaturatingSemaphore

Summary:
[Folly] Use `MemoryIdler` in `SaturatingSemaphore`.

As is used in `Baton`.

And merge the two invocations of `futexWait` and `futexWaitUntil` - `futexWaitUntil` also tests for the max-deadline internally.

Reviewed By: djwatson

Differential Revision: D6720045

fbshipit-source-id: a48187a6c866dbf99bb5c7283e0288b939bef2e5
parent 9938799b
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <folly/Likely.h> #include <folly/Likely.h>
#include <folly/detail/Futex.h> #include <folly/detail/Futex.h>
#include <folly/detail/MemoryIdler.h>
#include <folly/portability/Asm.h> #include <folly/portability/Asm.h>
#include <folly/synchronization/WaitOptions.h> #include <folly/synchronization/WaitOptions.h>
...@@ -304,11 +305,7 @@ FOLLY_NOINLINE bool SaturatingSemaphore<MayBlock, Atom>::tryWaitSlow( ...@@ -304,11 +305,7 @@ FOLLY_NOINLINE bool SaturatingSemaphore<MayBlock, Atom>::tryWaitSlow(
continue; continue;
} }
} }
if (deadline == std::chrono::time_point<Clock, Duration>::max()) { detail::MemoryIdler::futexWaitUntil(state_, BLOCKED, deadline);
state_.futexWait(BLOCKED);
} else {
state_.futexWaitUntil(BLOCKED, deadline);
}
} }
} }
asm_volatile_pause(); asm_volatile_pause();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment