37 template <
typename Tag>
48 std::atomic<int64_t>
inc_[2];
49 std::atomic<int64_t>
dec_[2];
54 inc_[0].
load(std::memory_order_relaxed), std::memory_order_relaxed);
56 inc_[1].
load(std::memory_order_relaxed), std::memory_order_relaxed);
59 dec_[0].
load(std::memory_order_relaxed), std::memory_order_relaxed);
61 dec_[1].
load(std::memory_order_relaxed), std::memory_order_relaxed);
62 ints_->
waiting_.store(0, std::memory_order_release);
85 auto&
c = int_cache_->inc_[epoch];
86 auto val =
c.load(std::memory_order_relaxed);
87 c.store(
val + 1, std::memory_order_relaxed);
98 auto&
c = int_cache_->dec_[epoch];
99 auto val =
c.load(std::memory_order_relaxed);
100 c.store(
val + 1, std::memory_order_relaxed);
103 if (
waiting_.load(std::memory_order_acquire)) {
104 waiting_.store(0, std::memory_order_release);
110 int64_t full = -orphan_dec_[epoch].load(std::memory_order_relaxed);
122 full -=
i.dec_[epoch].load(std::memory_order_relaxed);
131 for (
auto&
i : accessor) {
132 full +=
i.inc_[epoch].load(std::memory_order_relaxed);
136 return full + orphan_inc_[epoch].load(std::memory_order_relaxed);
146 waiting_.store(1, std::memory_order_release);
155 waiting_.store(0, std::memory_order_relaxed);
163 int_cache_->dec_[0].store(0, std::memory_order_relaxed);
164 int_cache_->dec_[1].store(0, std::memory_order_relaxed);
165 int_cache_->inc_[0].store(0, std::memory_order_relaxed);
166 int_cache_->inc_[1].store(0, std::memory_order_relaxed);
168 orphan_inc_[0].store(0, std::memory_order_relaxed);
169 orphan_inc_[1].store(0, std::memory_order_relaxed);
170 orphan_dec_[0].store(0, std::memory_order_relaxed);
171 orphan_dec_[1].store(0, std::memory_order_relaxed);
175 template <
typename Tag>
FOLLY_ALWAYS_INLINE void decrement(uint8_t epoch)
constexpr Integer(ThreadCachedInts *ints) noexcept
void reset(T *newPtr=nullptr)
#define FOLLY_ALWAYS_INLINE
static thread_local Integer * int_cache_
void asymmetricHeavyBarrier(AMBFlags flags)
Atom< std::uint32_t > Futex
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
FutexResult futexWait(const Futex *futex, uint32_t expected, uint32_t waitMask)
folly::ThreadLocalPtr< Integer, Tag > cs_
FOLLY_ALWAYS_INLINE void increment(uint8_t epoch)
std::atomic< int64_t > orphan_dec_[2]
folly::detail::Futex waiting_
Accessor accessAllThreads() const
FOLLY_ALWAYS_INLINE void asymmetricLightBarrier()
void waitForZero(uint8_t phase)
std::atomic< int64_t > dec_[2]
std::atomic< int64_t > orphan_inc_[2]
int64_t readFull(uint8_t epoch)
int futexWake(const Futex *futex, int count, uint32_t wakeMask)
std::atomic< int64_t > inc_[2]