projects
/
libcds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Uses unique_ptr for Threads
[libcds.git]
/
test
/
stress
/
misc
/
rwlock_driver.cpp
diff --git
a/test/stress/misc/rwlock_driver.cpp
b/test/stress/misc/rwlock_driver.cpp
index 2c61d440e4a75c3e563db772e35d177f98aafb95..548d16a9d95466978d3a8eea92abf0e628abc93b 100644
(file)
--- a/
test/stress/misc/rwlock_driver.cpp
+++ b/
test/stress/misc/rwlock_driver.cpp
@@
-5,6
+5,7
@@
#include <cds/sync/rwlock.h>
#include <cds_test/stress_test.h>
#include <iostream>
#include <cds/sync/rwlock.h>
#include <cds_test/stress_test.h>
#include <iostream>
+#include <memory>
#include <thread>
using namespace std;
#include <thread>
using namespace std;
@@
-17,8
+18,8
@@
static size_t s_nRWLockPassCount = 200000;
typedef cds_others::RWLock RWLock;
class RWLockTest : public cds_test::stress_fixture {
protected:
typedef cds_others::RWLock RWLock;
class RWLockTest : public cds_test::stress_fixture {
protected:
- static
in
t sum;
- static
in
t x;
+ static
size_
t sum;
+ static
size_
t x;
static RWLock *rwlock;
static void SetUpTestCase() {
static RWLock *rwlock;
static void SetUpTestCase() {
@@
-58,20
+59,20
@@
protected:
}
};
}
};
-
in
t RWLockTest::x;
-
in
t RWLockTest::sum;
+
size_
t RWLockTest::x;
+
size_
t RWLockTest::sum;
RWLock *RWLockTest::rwlock;
TEST_F(RWLockTest, BasicLockUnlock) {
rwlock = new RWLock();
RWLock *RWLockTest::rwlock;
TEST_F(RWLockTest, BasicLockUnlock) {
rwlock = new RWLock();
-
in
t num_threads = s_nRWLockThreadCount;
+
size_
t num_threads = s_nRWLockThreadCount;
for (int write_percentage = 5; write_percentage < 40; write_percentage += 5) {
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 (size_t i = 0; i < num_threads; i++) {
threads[i] = std::thread(ReaderWriterThread, write_percentage);
}
- for (
in
t i = 0; i < num_threads; i++) {
+ for (
size_
t i = 0; i < num_threads; i++) {
threads[i].join();
}
}
threads[i].join();
}
}