2 #include <cds/misc/RigtorpSPSCQueue.h>
3 #include <cds_test/stress_test.h>
11 class rigtorpSPSCQueueTest : public cds_test::stress_fixture {
13 static size_t s_nRigtorpSPSCQueuePassCount;
14 static size_t s_nRigtorpSPSCQueueEnqueueStride;
15 static size_t s_nRigtorpSPSCQueueCapacity;
17 static void SetUpTestCase() {
18 cds_test::config const &cfg = get_config("SequentialMisc");
19 GetConfigExpected(RigtorpSPSCQueuePassCount, 10000);
20 GetConfigExpected(RigtorpSPSCQueueEnqueueStride, 1024);
21 GetConfigExpected(RigtorpSPSCQueueCapacity, 2048);
22 if (s_nRigtorpSPSCQueueCapacity <= s_nRigtorpSPSCQueueEnqueueStride) {
23 s_nRigtorpSPSCQueueCapacity = 2 * s_nRigtorpSPSCQueueEnqueueStride;
28 rigtorp::SPSCQueue<size_t> q(s_nRigtorpSPSCQueueCapacity);
33 while (nNo < s_nRigtorpSPSCQueuePassCount) {
34 size_t curr_push_count = std::min(s_nRigtorpSPSCQueuePassCount - nNo,
35 s_nRigtorpSPSCQueueEnqueueStride);
36 for (size_t i = 0; i < curr_push_count; i++) {
42 size_t* res = nullptr;
43 while ((res = q.front())) {
47 EXPECT_EQ(pop_sum, push_sum);
54 size_t rigtorpSPSCQueueTest::s_nRigtorpSPSCQueuePassCount;
55 size_t rigtorpSPSCQueueTest::s_nRigtorpSPSCQueueEnqueueStride;
56 size_t rigtorpSPSCQueueTest::s_nRigtorpSPSCQueueCapacity;
58 TEST_F(rigtorpSPSCQueueTest, PushPop) {