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

Method _add_group

src/bthread/task_control.cpp:452–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450}
451
452int TaskControl::_add_group(TaskGroup* g, bthread_tag_t tag) {
453 if (__builtin_expect(NULL == g, 0)) {
454 return -1;
455 }
456 std::unique_lock<butil::Mutex> mu(_modify_group_mutex);
457 if (_stop) {
458 return -1;
459 }
460 g->set_tag(tag);
461 g->set_pl(&_tagged_pl[tag][butil::fmix64(pthread_numeric_id()) % _pl_num_of_each_tag]);
462 size_t ngroup = _tagged_ngroup[tag].load(butil::memory_order_relaxed);
463 if (ngroup < (size_t)BTHREAD_MAX_CONCURRENCY) {
464 _tagged_groups[tag][ngroup] = g;
465 _tagged_ngroup[tag].store(ngroup + 1, butil::memory_order_release);
466 }
467 mu.unlock();
468 // See the comments in _destroy_group
469 // TODO: Not needed anymore since non-worker pthread cannot have TaskGroup
470 // signal_task(65536, tag);
471 return 0;
472}
473
474void TaskControl::delete_task_group(void* arg) {
475 delete(TaskGroup*)arg;

Callers

nothing calls this directly

Calls 7

fmix64Function · 0.85
pthread_numeric_idFunction · 0.85
set_tagMethod · 0.80
set_plMethod · 0.80
loadMethod · 0.45
storeMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected