27 #include <type_traits> 57 throw std::bad_alloc();
68 while (readIndex != endIndex) {
70 if (++readIndex ==
size_) {
79 template <
class...
Args>
81 auto const currentWrite =
writeIndex_.load(std::memory_order_relaxed);
82 auto nextRecord = currentWrite + 1;
83 if (nextRecord ==
size_) {
86 if (nextRecord !=
readIndex_.load(std::memory_order_acquire)) {
87 new (&
records_[currentWrite])
T(std::forward<Args>(recordArgs)...);
88 writeIndex_.store(nextRecord, std::memory_order_release);
98 auto const currentRead =
readIndex_.load(std::memory_order_relaxed);
99 if (currentRead ==
writeIndex_.load(std::memory_order_acquire)) {
104 auto nextRecord = currentRead + 1;
105 if (nextRecord ==
size_) {
110 readIndex_.store(nextRecord, std::memory_order_release);
117 auto const currentRead =
readIndex_.load(std::memory_order_relaxed);
118 if (currentRead ==
writeIndex_.load(std::memory_order_acquire)) {
127 auto const currentRead =
readIndex_.load(std::memory_order_relaxed);
128 assert(currentRead !=
writeIndex_.load(std::memory_order_acquire));
130 auto nextRecord = currentRead + 1;
131 if (nextRecord ==
size_) {
135 readIndex_.store(nextRecord, std::memory_order_release);
139 return readIndex_.load(std::memory_order_acquire) ==
144 auto nextRecord =
writeIndex_.load(std::memory_order_acquire) + 1;
145 if (nextRecord ==
size_) {
148 if (nextRecord !=
readIndex_.load(std::memory_order_acquire)) {
161 int ret =
writeIndex_.load(std::memory_order_acquire) -
char pad1_[hardware_destructive_interference_size-sizeof(AtomicIndex)]
constexpr detail::Map< Move > move
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
constexpr std::size_t hardware_destructive_interference_size
constexpr auto size(C const &c) -> decltype(c.size())
ProducerConsumerQueue(const ProducerConsumerQueue &)=delete
std::atomic< unsigned int > AtomicIndex
static const char *const value
ProducerConsumerQueue & operator=(const ProducerConsumerQueue &)=delete
folly::std enable_if::typetoAppendDelimStrImpl const Delimiter, const Tv, Tgtresult sizeof(Ts) >
bool write(Args &&...recordArgs)
char pad0_[hardware_destructive_interference_size]
ProducerConsumerQueue(uint32_t size)