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

Method start

src/bthread/timer_thread.cpp:144–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144int TimerThread::start(const TimerThreadOptions* options_in) {
145 if (_started) {
146 return 0;
147 }
148 if (options_in) {
149 _options = *options_in;
150 }
151 if (_options.num_buckets == 0) {
152 LOG(ERROR) << "num_buckets can't be 0";
153 return EINVAL;
154 }
155 if (_options.num_buckets > 1024) {
156 LOG(ERROR) << "num_buckets=" << _options.num_buckets << " is too big";
157 return EINVAL;
158 }
159 _buckets = new (std::nothrow) Bucket[_options.num_buckets];
160 if (NULL == _buckets) {
161 LOG(ERROR) << "Fail to new _buckets";
162 return ENOMEM;
163 }
164 const int ret = pthread_create(&_thread, NULL, TimerThread::run_this, this);
165 if (ret) {
166 return ret;
167 }
168 _started = true;
169 return 0;
170}
171
172TimerThread::Task* TimerThread::Bucket::consume_tasks() {
173 Task* head = NULL;

Callers 3

init_global_timer_threadFunction · 0.45
fd.cppFile · 0.45
SignalTraceMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected