MCPcopy Create free account
hub / github.com/apache/impala / TestMultipleThreadsIncDec

Function TestMultipleThreadsIncDec

be/src/common/atomic-test.cc:85–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83
84template<typename T>
85static void TestMultipleThreadsIncDec() {
86 thread_group increments, decrements;
87 vector<int> ops;
88 ops.push_back(1000);
89 ops.push_back(10000);
90 vector<int> num_threads;
91 num_threads.push_back(4);
92 num_threads.push_back(8);
93 num_threads.push_back(16);
94
95 for (vector<int>::iterator thrit = num_threads.begin(); thrit != num_threads.end();
96 ++thrit) {
97 for (vector<int>::iterator opit = ops.begin(); opit != ops.end(); ++opit) {
98 AtomicInt<T> ai(0);
99 for (int i = 0; i < *thrit; ++i) {
100 increments.add_thread(new thread(IncrementThread<T>, i, *opit, &ai));
101 decrements.add_thread(new thread(DecrementThread<T>, i, *opit, &ai));
102 }
103 increments.join_all();
104 decrements.join_all();
105 EXPECT_EQ(ai.Load(), 0);
106 }
107 }
108}
109
110TEST(AtomicTest, MultipleThreadsIncDec) {
111 TestMultipleThreadsIncDec<int32_t>();

Callers

nothing calls this directly

Calls 4

push_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
LoadMethod · 0.45

Tested by

no test coverage detected