31 auto curr_waiter =
waiter_.load();
39 throw std::logic_error(
"Some waiter is already waiting on this Baton.");
41 }
while (!
waiter_.compare_exchange_weak(
42 curr_waiter, reinterpret_cast<intptr_t>(&waiter)));
50 auto timeoutFunc = [
this, &timeoutHandler] {
76 waiter =
waiter_.load(std::memory_order_acquire);
86 throw std::logic_error(
"Thread baton can't have timeout status");
89 throw std::logic_error(
"Other thread is already waiting on this baton");
91 throw std::logic_error(
"Other waiter is already waiting on this baton");
97 "isn't this assert clearer than an uninitialized variable warning?");
132 waiter =
waiter_.load(std::memory_order_relaxed);
142 throw std::logic_error(
"Thread baton can't have timeout status");
145 throw std::logic_error(
"Other thread is already waiting on this baton");
147 throw std::logic_error(
"Other waiter is already waiting on this baton");
159 assert(new_value ==
POSTED);
167 }
while (!
waiter_.compare_exchange_weak(waiter, new_value));
194 assert(fiberManager_ !=
nullptr);
195 assert(timeoutFunc_ !=
nullptr);
196 assert(timeoutPtr_ == 0);
198 if (timeout.count() > 0) {
200 fiberManager_->timeoutManager_->registerTimeout(timeoutFunc_, timeout);
206 fiberManager_->timeoutManager_->cancel(timeoutPtr_);
static constexpr intptr_t NO_WAITER
static constexpr intptr_t POSTED
FutexResult futexWaitUntil(const Futex< MockAtom > *futex, std::uint32_t expected, std::chrono::time_point< Clock, Duration > const &deadline, uint32_t waitMask)
static FutexResult futexWait(Futex &fut, uint32_t expected, uint32_t waitMask=-1, IdleTime const &idleTimeout=defaultIdleTimeout.load(std::memory_order_acquire), size_t stackToRetain=kDefaultStackToRetain, float timeoutVariationFrac=0.5)
static constexpr intptr_t TIMEOUT
struct folly::fibers::Baton::@51::@53 futex_
std::chrono::steady_clock::time_point now()
—— Concurrent Priority Queue Implementation ——
std::atomic< intptr_t > waiter_
static constexpr intptr_t THREAD_WAITING
void scheduleTimeout(TimeoutController::Duration timeoutMs)
std::function< void()> timeoutFunc_
FiberManager * fiberManager_
bool timedWaitThread(TimeoutController::Duration timeout)
FutexResult futexWaitUntil(const Futex *futex, uint32_t expected, std::chrono::time_point< Clock, Duration > const &deadline, uint32_t waitMask)
void setWaiter(Waiter &waiter)
folly::detail::Futex futex
static FiberManager * getFiberManagerUnsafe()
void postHelper(intptr_t new_value)
bool spinWaitForEarlyPost()
int futexWake(const Futex *futex, int count, uint32_t wakeMask)
void asm_volatile_pause()