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

Function ThreadKeyPerfFunc

test/thread_key_unittest.cpp:328–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326};
327
328void* ThreadKeyPerfFunc(void* void_arg) {
329 auto args = (ThreadKeyPerfArgs*)void_arg;
330 args->ready = true;
331 std::unique_ptr<int> data(new int(1));
332 if (args->is_pthread_key) {
333 pthread_setspecific(args->pthread_key, (void*)data.get());
334 } else {
335 butil::thread_setspecific(*args->thread_key, (void*)data.get());
336 }
337 butil::Timer t;
338 while (!g_stopped) {
339 if (g_started) {
340 break;
341 }
342 bthread_usleep(10);
343 }
344 t.start();
345 while (!g_stopped) {
346 if (args->is_pthread_key) {
347 pthread_getspecific(args->pthread_key);
348 } else {
349 butil::thread_getspecific(*args->thread_key);
350 }
351 ++args->counter;
352 }
353 t.stop();
354 args->elapse_ns = t.n_elapsed();
355 return NULL;
356}
357
358
359void ThreadKeyPerfTest(int thread_num, bool test_pthread_key) {

Callers

nothing calls this directly

Calls 7

thread_setspecificFunction · 0.85
bthread_usleepFunction · 0.85
thread_getspecificFunction · 0.85
n_elapsedMethod · 0.80
getMethod · 0.45
startMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected