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

Function TestMultipleThreadsCASIncDec

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

Source from the content-addressed store, hash-verified

147
148template<typename T>
149static void TestMultipleThreadsCASIncDec() {
150 thread_group increments, decrements;
151 vector<int> ops;
152 ops.push_back(10);
153 ops.push_back(10000);
154 vector<int> num_threads;
155 num_threads.push_back(4);
156 num_threads.push_back(8);
157 num_threads.push_back(16);
158
159 for (vector<int>::iterator thrit = num_threads.begin(); thrit != num_threads.end();
160 ++thrit) {
161 for (vector<int>::iterator opit = ops.begin(); opit != ops.end(); ++opit) {
162 AtomicInt<T> ai(0);
163 for (int i = 0; i < *thrit; ++i) {
164 increments.add_thread(new thread(CASIncrementThread<T>, i, *opit, &ai));
165 decrements.add_thread(new thread(CASDecrementThread<T>, i, *opit, &ai));
166 }
167 increments.join_all();
168 decrements.join_all();
169 EXPECT_EQ(ai.Load(), 0);
170 }
171 }
172}
173
174TEST(AtomicTest, MultipleThreadsCASIncDec) {
175 TestMultipleThreadsCASIncDec<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