24 auto& waitList = *waitListLock;
26 auto testVal =
tokens_.load(std::memory_order_acquire);
31 if (waitList.empty()) {
34 CHECK(
tokens_.compare_exchange_strong(
35 testVal, testVal + 1, std::memory_order_relaxed));
38 waitList.front()->post();
45 auto oldVal =
tokens_.load(std::memory_order_acquire);
52 }
while (!
tokens_.compare_exchange_weak(
55 std::memory_order_release,
56 std::memory_order_acquire));
65 auto& waitList = *waitListLock;
67 auto testVal =
tokens_.load(std::memory_order_acquire);
72 waitList.push(&waitBaton);
81 auto oldVal =
tokens_.load(std::memory_order_acquire);
90 }
while (!
tokens_.compare_exchange_weak(
93 std::memory_order_release,
94 std::memory_order_acquire));
—— Concurrent Priority Queue Implementation ——
std::atomic< int64_t > tokens_
size_t getCapacity() const
folly::Synchronized< std::queue< folly::fibers::Baton * > > waitList_