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

Function return_keytable

src/bthread/key.cpp:374–401  ·  view source on GitHub ↗

Referenced in task_group.cpp, must be extern. Caller of this function must hold the KeyTable

Source from the content-addressed store, hash-verified

372// Referenced in task_group.cpp, must be extern.
373// Caller of this function must hold the KeyTable
374void return_keytable(bthread_keytable_pool_t* pool, KeyTable* kt) {
375 if (NULL == kt) {
376 return;
377 }
378 if (pool == NULL) {
379 delete kt;
380 return;
381 }
382 pthread_rwlock_rdlock(&pool->rwlock);
383 if (pool->destroyed) {
384 pthread_rwlock_unlock(&pool->rwlock);
385 delete kt;
386 return;
387 }
388 auto list = (butil::ThreadLocal<bthread::KeyTableList>*)pool->list;
389 list->get()->append(kt);
390 if (list->get()->get_length() > FLAGS_key_table_list_size) {
391 pthread_rwlock_unlock(&pool->rwlock);
392 pthread_rwlock_wrlock(&pool->rwlock);
393 if (!pool->destroyed) {
394 int out = list->get()->move_first_n_to_target(
395 (KeyTable**)(&pool->free_keytables),
396 FLAGS_key_table_list_size / 2);
397 pool->size += out;
398 }
399 }
400 pthread_rwlock_unlock(&pool->rwlock);
401}
402
403static void cleanup_pthread(void* arg) {
404 KeyTable* kt = static_cast<KeyTable*>(arg);

Callers 3

return_thread_implFunction · 0.85
TESTFunction · 0.85
task_runnerMethod · 0.85

Calls 3

get_lengthMethod · 0.80
appendMethod · 0.45
getMethod · 0.45

Tested by 2

return_thread_implFunction · 0.68
TESTFunction · 0.68