3 #include <cds/gc/dhp.h>
5 #include <cds/sync/barrier.h>
6 #include <cds_test/stress_test.h>
14 typedef cds_others::SpinBarrier Barrier;
16 static size_t s_nBarrierThreadCount = 6;
17 static size_t s_nBarrierPassCount = 100000000;
19 class BarrierTest : public cds_test::stress_fixture {
21 static Barrier *barrier;
24 static void SetUpTestCase() {
25 cds_test::config const &cfg = get_config("Misc");
26 GetConfig(BarrierPassCount);
27 GetConfig(BarrierThreadCount);
30 static void TearDownTestCase() {
31 if (count != s_nBarrierPassCount) {
32 cout << "Incorrect" << endl;
36 static void Thread() {
37 for (ullong i = 0; i < s_nBarrierPassCount; i++) {
38 if (barrier->wait()) {
45 Barrier *BarrierTest::barrier;
46 int BarrierTest::count;
48 TEST_F(BarrierTest, Wait) {
49 barrier = new Barrier(s_nBarrierThreadCount);
50 std::thread *threads = new std::thread[s_nBarrierThreadCount];
51 for (int i = 0; i < s_nBarrierThreadCount; i++) {
52 threads[i] = std::thread(Thread);
55 for (int i = 0; i < s_nBarrierThreadCount; i++) {