38 assert(
Baton(NO_WAITER).
futex_.futex == static_cast<uint32_t>(NO_WAITER));
45 assert(
futex_.futex.is_lock_free());
52 if (!fm || !fm->activeFiber_) {
57 return waitFiber(*fm, std::forward<F>(mainContextFunc));
63 auto f = [
this, &mainContextFunc, &waiter](
Fiber& fiber)
mutable {
74 template <
typename Rep,
typename Period,
typename F>
76 const std::chrono::duration<Rep, Period>& timeout,
77 F&& mainContextFunc) {
80 if (!fm || !fm->activeFiber_) {
86 bool canceled =
false;
87 auto timeoutFunc = [&baton, &canceled]()
mutable {
93 fm->timeoutManager_->registerTimeout(std::ref(timeoutFunc), timeout);
95 waitFiber(*fm, static_cast<F&&>(mainContextFunc));
100 fm->timeoutManager_->cancel(
id);
106 template <
typename Clock,
typename Duration,
typename F>
108 const std::chrono::time_point<Clock, Duration>& deadline,
109 F&& mainContextFunc) {
113 return try_wait_for(deadline -
now, static_cast<F&&>(mainContextFunc));
static constexpr intptr_t NO_WAITER
static constexpr intptr_t POSTED
folly::Function< void(Fiber &)> awaitFunc_
static constexpr intptr_t TIMEOUT
struct folly::fibers::Baton::@51::@53 futex_
std::chrono::steady_clock::time_point now()
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
std::atomic< intptr_t > waiter_
Single-threaded task execution engine.
static constexpr intptr_t THREAD_WAITING
Fiber object used by FiberManager to execute tasks.
std::chrono::milliseconds Duration
void preempt(State state)
void setFiber(Fiber &fiber)
bool timedWaitThread(TimeoutController::Duration timeout)
void setWaiter(Waiter &waiter)
static FiberManager * getFiberManagerUnsafe()
bool try_wait_until(const std::chrono::time_point< Clock, Duration > &deadline)
void waitFiber(FiberManager &fm, F &&mainContextFunc)
bool try_wait_for(const std::chrono::duration< Rep, Period > &timeout)