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

Function add_with_mutex

test/bthread_rwlock_unittest.cpp:299–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297
298template <bool Reader>
299void* add_with_mutex(void* void_arg) {
300 auto args = (PerfArgs*)void_arg;
301 args->ready = true;
302 butil::Timer t;
303 while (!g_stopped) {
304 if (g_started) {
305 break;
306 }
307 bthread_usleep(10);
308 }
309 t.start();
310 while (!g_stopped) {
311 if (Reader) {
312 bthread_rwlock_rdlock(args->rw);
313 } else {
314 bthread_rwlock_wrlock(args->rw);
315 }
316 ++args->counter;
317 bthread_rwlock_unlock(args->rw);
318 }
319 t.stop();
320 args->elapse_ns = t.n_elapsed();
321 return NULL;
322}
323
324int g_prof_name_counter = 0;
325

Callers

nothing calls this directly

Calls 7

bthread_usleepFunction · 0.85
bthread_rwlock_rdlockFunction · 0.85
bthread_rwlock_wrlockFunction · 0.85
bthread_rwlock_unlockFunction · 0.85
n_elapsedMethod · 0.80
startMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected