#include <cds/sync/rwlock.h>
#include <cds_test/stress_test.h>
#include <iostream>
+#include <memory>
#include <thread>
using namespace std;
typedef cds_others::RWLock RWLock;
class RWLockTest : public cds_test::stress_fixture {
protected:
- static int sum;
- static int x;
+ static size_t sum;
+ static size_t x;
static RWLock *rwlock;
static void SetUpTestCase() {
}
};
-int RWLockTest::x;
-int RWLockTest::sum;
+size_t RWLockTest::x;
+size_t RWLockTest::sum;
RWLock *RWLockTest::rwlock;
TEST_F(RWLockTest, BasicLockUnlock) {
rwlock = new RWLock();
- int num_threads = s_nRWLockThreadCount;
+ size_t num_threads = s_nRWLockThreadCount;
for (int write_percentage = 5; write_percentage < 40; write_percentage += 5) {
- std::thread *threads = new std::thread[num_threads];
+ std::unique_ptr<std::thread[]> threads(new std::thread[num_threads]);
for (size_t i = 0; i < num_threads; i++) {
threads[i] = std::thread(ReaderWriterThread, write_percentage);
}
- for (int i = 0; i < num_threads; i++) {
+ for (size_t i = 0; i < num_threads; i++) {
threads[i].join();
}
}