24 : size_(n), controlBlock_(allocateControlBlock()) {}
28 auto prev = block->valueAndReaderCount.load(std::memory_order_relaxed);
35 folly::make_exception_wrapper<std::runtime_error>(
"Barrier destroyed"));
44 throw_exception<std::bad_alloc>();
51 for (i = 0; i <
size_; ++
i) {
56 p[i - 1].~BoolPromise();
67 p[
i - 1].~BoolPromise();
81 auto prev = block->valueAndReaderCount.fetch_add(
82 kReader + 1, std::memory_order_acquire);
85 DCHECK_LT(prevValue,
size_);
86 auto future = p[prevValue].getFuture();
88 if (prevValue + 1 ==
size_) {
101 block->valueAndReaderCount.fetch_sub(
kReader, std::memory_order_acq_rel);
static constexpr uint64_t kReaderShift
folly::Future< bool > wait()
static constexpr uint64_t kReader
folly::Promise< bool > BoolPromise
—— Concurrent Priority Queue Implementation ——
static size_t controlBlockSize(size_t n)
std::atomic< ControlBlock * > controlBlock_
static BoolPromise * promises(ControlBlock *cb)
ControlBlock * allocateControlBlock()
static constexpr uint64_t kValueMask
void freeControlBlock(ControlBlock *b)