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

Function read_thread

test/bthread_rwlock_unittest.cpp:406–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404
405
406void* read_thread(void* arg) {
407 const size_t N = 10000;
408#ifdef CHECK_RWLOCK
409 pthread_rwlock_t* lock = (pthread_rwlock_t*)arg;
410#else
411 pthread_mutex_t* lock = (pthread_mutex_t*)arg;
412#endif
413 const long t1 = butil::cpuwide_time_ns();
414 for (size_t i = 0; i < N; ++i) {
415#ifdef CHECK_RWLOCK
416 pthread_rwlock_rdlock(lock);
417 pthread_rwlock_unlock(lock);
418#else
419 pthread_mutex_lock(lock);
420 pthread_mutex_unlock(lock);
421#endif
422 }
423 const long t2 = butil::cpuwide_time_ns();
424 return new long((t2 - t1)/N);
425}
426
427void* write_thread(void*) {
428 return NULL;

Callers

nothing calls this directly

Calls 3

cpuwide_time_nsFunction · 0.85
pthread_mutex_lockFunction · 0.85
pthread_mutex_unlockFunction · 0.85

Tested by

no test coverage detected