| 408 | } |
| 409 | |
| 410 | int 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 | |
| 432 | void OnTimedOut(void *arg) { |
| 433 | bthread_id_t id = { reinterpret_cast<uint64_t>(arg) }; |
nothing calls this directly
no test coverage detected