Changes RigtorpSPSC test case
authorPeizhao Ou <peizhaoo@uci.edu>
Mon, 29 Jan 2018 23:50:09 +0000 (15:50 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Mon, 29 Jan 2018 23:50:09 +0000 (15:50 -0800)
test/stress/sequential/sequential-misc/rigtorp_spsc_driver.cpp

index 0fee179..ef3380a 100644 (file)
@@ -14,6 +14,8 @@ protected:
   static size_t s_nRigtorpSPSCQueueEnqueueStride;
   static size_t s_nRigtorpSPSCQueueCapacity;
 
+  rigtorp::SPSCQueue<size_t>* q;
+
   static void SetUpTestCase() {
     cds_test::config const &cfg = get_config("SequentialMisc");
     GetConfigExpected(RigtorpSPSCQueuePassCount, 10000);
@@ -25,7 +27,8 @@ protected:
   }
 
   void test() {
-    rigtorp::SPSCQueue<size_t> q(s_nRigtorpSPSCQueueCapacity);
+    std::unique_ptr<rigtorp::SPSCQueue<size_t>> q(
+        new rigtorp::SPSCQueue<size_t>(s_nRigtorpSPSCQueueCapacity));
     size_t nNo = 0;
     size_t push_sum = 0;
     size_t pop_sum = 0;
@@ -34,15 +37,15 @@ protected:
       size_t curr_push_count = std::min(s_nRigtorpSPSCQueuePassCount - nNo,
                                         s_nRigtorpSPSCQueueEnqueueStride);
       for (size_t i = 0; i < curr_push_count; i++) {
-        q.push(nNo);
+        q->push(nNo);
         push_sum += nNo;
         ++nNo;
       }
 
       size_t* res = nullptr;
-      while ((res = q.front())) {
+      while ((res = q->front())) {
         pop_sum += *res;
-        q.pop();
+        q->pop();
       }
       EXPECT_EQ(pop_sum, push_sum);
       push_sum = 0;