55 }
while (!
globalCount_.compare_exchange_weak(value, value + 1));
84 std::array<TLRefCount*, 1> ptrs{{
this}};
88 template <
typename Container>
89 static void useGlobal(
const Container& refCountPtrs) {
90 #ifdef FOLLY_SANITIZE_THREAD 93 if (refCountPtrs.size() > 1) {
94 for (
auto refCountPtr : refCountPtrs) {
95 refCountPtr->useGlobal();
101 std::vector<std::unique_lock<std::mutex>> lgs_;
102 for (
auto refCountPtr : refCountPtrs) {
103 lgs_.emplace_back(refCountPtr->globalMutex_);
110 for (
auto refCountPtr : refCountPtrs) {
111 std::weak_ptr<void> collectGuardWeak = refCountPtr->collectGuard_;
114 refCountPtr->collectGuard_.reset();
116 while (!collectGuardWeak.expired()) {
117 auto accessor = refCountPtr->localCount_.accessAllThreads();
118 for (
auto&
count : accessor) {
149 std::lock_guard<std::mutex> lg(collectMutex_);
155 collectCount_ = count_.load();
156 refCount_.globalCount_.fetch_add(collectCount_);
178 auto count = count_.load(std::memory_order_relaxed) + delta;
179 count_.store(
count, std::memory_order_relaxed);
184 std::lock_guard<std::mutex> lg(collectMutex_);
189 if (collectCount_ !=
count) {
folly::ThreadLocal< LocalRefCount, TLRefCount > localCount_
static void useGlobal(const Container &refCountPtrs)
void asymmetricHeavyBarrier(AMBFlags flags)
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
void useGlobal() noexcept
LocalRefCount(TLRefCount &refCount)
std::shared_ptr< void > collectGuard_
std::atomic< int64_t > globalCount_
std::shared_ptr< void > collectGuard_
FOLLY_ALWAYS_INLINE void asymmetricLightBarrier()
std::atomic< Int > AtomicInt
Future< std::vector< typename std::iterator_traits< InputIterator >::value_type::value_type > > collect(InputIterator first, InputIterator last)
Int operator++() noexcept
std::atomic< State > state_
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
Int operator--() noexcept