3 #include <cds/gc/dhp.h>
5 #include <cds/misc/barrier.h>
6 #include <cds_test/stress_test.h>
16 typedef cds_others::SpinBarrier Barrier;
18 static size_t s_nBarrierThreadCount = 2;
19 static size_t s_nBarrierPassCount = 100000000;
21 class BarrierTest : public cds_test::stress_fixture {
23 static Barrier *barrier;
26 static void SetUpTestCase() {
27 cds_test::config const &cfg = get_config("Misc");
28 GetConfig(BarrierPassCount);
29 GetConfig(BarrierThreadCount);
32 static void Thread() {
33 for (size_t i = 0; i < s_nBarrierPassCount; i++) {
34 if (barrier->wait()) {
41 Barrier *BarrierTest::barrier;
42 size_t BarrierTest::count;
44 TEST_F(BarrierTest, Wait) {
45 barrier = new Barrier(s_nBarrierThreadCount);
46 std::vector<std::thread> threads;
47 for (size_t i = 0; i < s_nBarrierThreadCount; i++) {
48 threads.push_back(std::thread(Thread));
51 for (size_t i = 0; i < s_nBarrierThreadCount; i++) {
54 EXPECT_EQ(count, s_nBarrierPassCount);