MCPcopy Create free account
hub / github.com/apache/brpc / DBDMultiBthread

Function DBDMultiBthread

test/brpc_load_balancer_unittest.cpp:162–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160
161template <typename DBD>
162void DBDMultiBthread() {
163 DBD d;
164 d.Modify(AddN, 1);
165 {
166 typename DBD::ScopedPtr ptr;
167 ASSERT_EQ(0, d.Read(&ptr));
168 ASSERT_EQ(1, ptr->x);
169 }
170
171 bthread_t tids[10000];
172 for (size_t i = 0; i < ARRAY_SIZE(tids); ++i) {
173 ASSERT_EQ(0, bthread_start_urgent(&tids[i], NULL, DBDBthread<DBD>, &d));
174 }
175
176 // Modify during reading.
177 int64_t start = butil::cpuwide_time_ms();
178 while (butil::cpuwide_time_ms() - start < 10 * 1000) {
179 d.Modify(AddN, 1);
180 typename DBD::ScopedPtr ptr;
181 d.Read(&ptr);
182 usleep(100 * 1000);
183 }
184 exitFlag = true;
185 for (size_t i = 0; i < ARRAY_SIZE(tids); ++i) {
186 ASSERT_EQ(0, bthread_join(tids[i], NULL));
187 }
188}
189
190// Deadlock, only for test.
191// TEST_F(LoadBalancerTest, doubly_buffered_data_multi_bthread) {

Callers

nothing calls this directly

Calls 5

bthread_start_urgentFunction · 0.85
cpuwide_time_msFunction · 0.85
bthread_joinFunction · 0.85
ModifyMethod · 0.80
ReadMethod · 0.45

Tested by

no test coverage detected