MCPcopy Create free account
hub / github.com/Tencent/phxqueue / ChildRun

Method ChildRun

phxqueue/consumer/consumer.cpp:480–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

478
479
480void Consumer::ChildRun(const int vpid) {
481 QLInfo("INFO: start vpid %u", vpid);
482
483 impl_->vpid = vpid;
484
485 comm::RetCode ret;
486
487 OnChildRun(vpid);
488
489 comm::proto::ConsumerContext &cc = impl_->cc;
490 cc.set_topic_id(GetTopicID());
491
492 comm::ConsumerBP::GetThreadInstance()->OnChildRun(cc.topic_id());
493
494 thread t(bind(&Consumer::ConsumeThreadRun, this, vpid));
495
496 while (true) {
497
498 BeforeLock(cc);
499
500 comm::ConsumerBP::GetThreadInstance()->OnLock(cc.topic_id());
501
502 int sub_id, store_id, queue_id;
503 if (comm::RetCode::RET_OK != (ret = impl_->lock.Lock(vpid, sub_id, store_id, queue_id))) {
504 if (comm::as_integer(ret) < 0) QLErr("DoLock ret %d vpid %u", comm::as_integer(ret), vpid);
505 sleep(2);
506 continue;
507 }
508 if (cc.sub_id() != sub_id ||
509 cc.store_id() != store_id ||
510 cc.queue_id() != queue_id) {
511 cc.set_sub_id(sub_id);
512 cc.set_store_id(store_id);
513 cc.set_queue_id(queue_id);
514 cc.set_prev_cursor_id(-1);
515 cc.set_next_cursor_id(-1);
516 }
517
518 comm::ConsumerBP::GetThreadInstance()->OnLockSucc(cc);
519
520 QLInfo("QUEUEINFO: vpid %u sub_id %d store_id %d queue_id %d", vpid, cc.sub_id(), cc.store_id(), cc.queue_id());
521
522 AfterLock(cc);
523
524 CheckMaxLoop(vpid);
525 CheckMem(vpid);
526
527 comm::ConsumerBP::GetThreadInstance()->OnProcess(cc);
528
529 if (comm::RetCode::RET_OK != (ret = Process(cc))) {
530 comm::ConsumerBP::GetThreadInstance()->OnProcessFail(cc);
531 QLErr("ERR: Process ret %d", comm::as_integer(ret));
532 usleep(100000);
533 } else {
534 comm::ConsumerBP::GetThreadInstance()->OnProcessSucc(cc);
535 }
536 }
537}

Callers

nothing calls this directly

Calls 8

as_integerFunction · 0.85
OnProcessMethod · 0.80
OnProcessFailMethod · 0.80
OnProcessSuccMethod · 0.80
OnChildRunMethod · 0.45
OnLockMethod · 0.45
LockMethod · 0.45
OnLockSuccMethod · 0.45

Tested by

no test coverage detected