26 #include <glog/logging.h> 119 template <
bool MayBlock,
template <
typename>
class Atom = std::atomic>
142 return state_.load(std::memory_order_acquire) ==
READY;
147 state_.store(
NOTREADY, std::memory_order_relaxed);
153 state_.store(
READY, std::memory_order_release);
171 template <
typename Clock,
typename Duration>
173 const std::chrono::time_point<Clock, Duration>& deadline,
182 template <
class Rep,
class Period>
184 const std::chrono::duration<Rep, Period>& duration,
196 if (
LIKELY(state_.compare_exchange_strong(
199 std::memory_order_release,
200 std::memory_order_relaxed))) {
208 template <
typename Clock,
typename Duration>
210 const std::chrono::time_point<Clock, Duration>& deadline,
219 template <
bool MayBlock,
template <
typename>
class Atom>
224 if (state_.compare_exchange_strong(
227 std::memory_order_release,
228 std::memory_order_relaxed)) {
232 if (before ==
READY) {
258 std::atomic_thread_fence(std::memory_order_seq_cst);
259 before = state_.load(std::memory_order_relaxed);
260 if (before ==
READY) {
266 if (state_.compare_exchange_strong(
269 std::memory_order_release,
270 std::memory_order_relaxed)) {
278 template <
bool MayBlock,
template <
typename>
class Atom>
279 template <
typename Clock,
typename Duration>
281 const std::chrono::time_point<Clock, Duration>& deadline,
303 auto before = state_.load(std::memory_order_relaxed);
305 !state_.compare_exchange_strong(
308 std::memory_order_relaxed,
309 std::memory_order_relaxed)) {
310 if (before ==
READY) {
312 std::atomic_thread_fence(std::memory_order_acquire);
FOLLY_ALWAYS_INLINE bool ready() const noexcept
static FutexResult futexWaitUntil(Futex &fut, uint32_t expected, Deadline const &deadline, uint32_t waitMask=-1, IdleTime const &idleTimeout=defaultIdleTimeout.load(std::memory_order_acquire), size_t stackToRetain=kDefaultStackToRetain, float timeoutVariationFrac=0.5)
FOLLY_ALWAYS_INLINE void wait(const WaitOptions &opt=wait_options()) noexcept
spin_result spin_yield_until(std::chrono::time_point< Clock, Duration > const &deadline, F f)
#define FOLLY_ALWAYS_INLINE
std::chrono::steady_clock::time_point now()
Atom< std::uint32_t > Futex
FOLLY_ALWAYS_INLINE void postFastWaiterMayBlock() noexcept
detail::Futex< Atom > state_
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
bool tryWaitSlow(const std::chrono::time_point< Clock, Duration > &deadline, const WaitOptions &opt) noexcept
static FOLLY_ALWAYS_INLINE WaitOptions wait_options()
FOLLY_ALWAYS_INLINE void post() noexcept
FOLLY_ALWAYS_INLINE bool try_wait_until(const std::chrono::time_point< Clock, Duration > &deadline, const WaitOptions &opt=wait_options()) noexcept
constexpr SaturatingSemaphore() noexcept
FOLLY_ALWAYS_INLINE bool try_wait_for(const std::chrono::duration< Rep, Period > &duration, const WaitOptions &opt=wait_options()) noexcept
FOLLY_ALWAYS_INLINE bool try_wait() noexcept
void postSlowWaiterMayBlock(uint32_t before) noexcept
spin_result spin_pause_until(std::chrono::time_point< Clock, Duration > const &deadline, WaitOptions const &opt, F f)
int futexWake(const Futex *futex, int count, uint32_t wakeMask)