+ // maximum number of items in the queue.
+ size_t capacity() const {
+ return size_ - 1;
+ }
+
private:
char pad0_[CacheLocality::kFalseSharingRange];
const uint32_t size_;
private:
char pad0_[CacheLocality::kFalseSharingRange];
const uint32_t size_;
EXPECT_FALSE(queue.write(3));
EXPECT_EQ(queue.sizeGuess(), 2);
}
EXPECT_FALSE(queue.write(3));
EXPECT_EQ(queue.sizeGuess(), 2);
}
+
+TEST(PCQ, Capacity) {
+ folly::ProducerConsumerQueue<int> queue(3);
+ EXPECT_EQ(queue.capacity(), 2); // PCQ max size is buffer size - 1.
+}