3 #include <cds/gc/dhp.h>
5 #include <cds/misc/barrier.h>
6 #include <cds_test/stress_test.h>
15 typedef cds_others::SpinBarrier Barrier;
17 static size_t s_nBarrierThreadCount = 6;
18 static size_t s_nBarrierPassCount = 100000000;
20 class BarrierTest : public cds_test::stress_fixture {
22 static Barrier *barrier;
25 static void SetUpTestCase() {
26 cds_test::config const &cfg = get_config("Misc");
27 GetConfig(BarrierPassCount);
28 GetConfig(BarrierThreadCount);
31 static void TearDownTestCase() {
32 if (count != s_nBarrierPassCount) {
33 cout << "Incorrect" << endl;
37 static void Thread() {
38 for (ullong i = 0; i < s_nBarrierPassCount; i++) {
39 if (barrier->wait()) {
46 Barrier *BarrierTest::barrier;
47 size_t BarrierTest::count;
49 TEST_F(BarrierTest, Wait) {
50 barrier = new Barrier(s_nBarrierThreadCount);
51 std::unique_ptr<std::thread[]> threads(new std::thread[s_nBarrierThreadCount]);
52 for (size_t i = 0; i < s_nBarrierThreadCount; i++) {
53 threads[i] = std::thread(Thread);
56 for (size_t i = 0; i < s_nBarrierThreadCount; i++) {