Uses unique_ptr for Threads
[libcds.git] / test / stress / misc / barrier_driver.cpp
index 438d033a88798b1949ebe1d4f9525ffa4de4093c..3ffe5aec36de10dbf483b1f16d436ecd59664e80 100644 (file)
@@ -5,6 +5,7 @@
 #include <cds/sync/barrier.h>
 #include <cds_test/stress_test.h>
 #include <iostream>
+#include <memory>
 #include <thread>
 
 using namespace std;
@@ -19,7 +20,7 @@ static size_t s_nBarrierPassCount = 100000000;
 class BarrierTest : public cds_test::stress_fixture {
 protected:
   static Barrier *barrier;
-  static int count;
+  static size_t count;
 
   static void SetUpTestCase() {
     cds_test::config const &cfg = get_config("Misc");
@@ -43,16 +44,16 @@ protected:
 };
 
 Barrier *BarrierTest::barrier;
-int BarrierTest::count;
+size_t BarrierTest::count;
 
 TEST_F(BarrierTest, Wait) {
   barrier = new Barrier(s_nBarrierThreadCount);
-  std::thread *threads = new std::thread[s_nBarrierThreadCount];
-  for (int i = 0; i < s_nBarrierThreadCount; i++) {
+  std::unique_ptr<std::thread[]> threads(new std::thread[s_nBarrierThreadCount]);
+  for (size_t i = 0; i < s_nBarrierThreadCount; i++) {
     threads[i] = std::thread(Thread);
   }
 
-  for (int i = 0; i < s_nBarrierThreadCount; i++) {
+  for (size_t i = 0; i < s_nBarrierThreadCount; i++) {
     threads[i].join();
   }
 }