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

Method TriggerOnWritable

src/brpc/stream.cpp:410–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408}
409
410int Stream::TriggerOnWritable(bthread_id_t id, void *data, int error_code) {
411 WritableMeta *wm = (WritableMeta*)data;
412
413 if (wm->has_timer) {
414 bthread_timer_del(wm->timer);
415 }
416 wm->error_code = error_code;
417 if (wm->new_thread) {
418 const bthread_attr_t* attr =
419 FLAGS_usercode_in_pthread ? &BTHREAD_ATTR_PTHREAD
420 : &BTHREAD_ATTR_NORMAL;
421 bthread_t tid;
422 if (bthread_start_background(&tid, attr, RunOnWritable, wm) != 0) {
423 LOG(FATAL) << "Fail to start bthread" << berror();
424 RunOnWritable(wm);
425 }
426 } else {
427 RunOnWritable(wm);
428 }
429 return bthread_id_unlock_and_destroy(id);
430}
431
432void OnTimedOut(void *arg) {
433 bthread_id_t id = { reinterpret_cast<uint64_t>(arg) };

Callers

nothing calls this directly

Calls 4

bthread_timer_delFunction · 0.85
bthread_start_backgroundFunction · 0.85
berrorFunction · 0.85

Tested by

no test coverage detected