| 414 | } |
| 415 | |
| 416 | void Consumer::ConsumeThreadRun(const int vpid) { |
| 417 | OnConsumeThreadRun(vpid); |
| 418 | comm::ConsumerConsumeBP::GetThreadInstance()->OnConsumeThreadRun(impl_->cc); |
| 419 | |
| 420 | //stShareStack_t *share_stack= co_alloc_sharestack(impl_->opt.nshare_stack, 1024 * impl_->opt.share_stack_size_kb); |
| 421 | stCoRoutineAttr_t attr; |
| 422 | //attr.stack_size = 0; |
| 423 | attr.stack_size = 1024 * impl_->opt.share_stack_size_kb; |
| 424 | //attr.share_stack = share_stack; |
| 425 | |
| 426 | impl_->cond = co_cond_alloc(); |
| 427 | |
| 428 | if (0 != socketpair(PF_LOCAL, SOCK_STREAM, 0, impl_->consume_fds)) { |
| 429 | QLErr("socketpair fail"); |
| 430 | return; |
| 431 | } |
| 432 | |
| 433 | impl_->handle_buckets = unique_ptr<queue<int>[]>(new queue<int>[impl_->opt.nhandler]); |
| 434 | |
| 435 | impl_->handle_ctxs = unique_ptr<struct ConsumeCtx_t[]>(new ConsumeCtx_t[impl_->opt.nhandler]); |
| 436 | for (int i{0}; i < impl_->opt.nhandler; ++i) { |
| 437 | auto &&ctx = impl_->handle_ctxs[i]; |
| 438 | ctx.co = nullptr; |
| 439 | ctx.cid = i; |
| 440 | ctx.consumer = this; |
| 441 | |
| 442 | co_create(&(ctx.co), &attr, HandleRoutineRun, &ctx); |
| 443 | co_resume(ctx.co); |
| 444 | } |
| 445 | |
| 446 | impl_->batch_handle_finish = unique_ptr<bool[]>(new bool[impl_->opt.nbatch_handler]); |
| 447 | |
| 448 | impl_->batch_handle_ctxs = unique_ptr<struct ConsumeCtx_t[]>(new ConsumeCtx_t[impl_->opt.nbatch_handler]); |
| 449 | for (int i{0}; i < impl_->opt.nbatch_handler; ++i) { |
| 450 | impl_->batch_handle_finish[i] = true; |
| 451 | |
| 452 | auto &&ctx = impl_->batch_handle_ctxs[i]; |
| 453 | ctx.co = NULL; |
| 454 | ctx.cid = i; |
| 455 | ctx.consumer = this; |
| 456 | |
| 457 | co_create(&(ctx.co), &attr, BatchHandleRoutineRun, &ctx); |
| 458 | co_resume(ctx.co); |
| 459 | } |
| 460 | |
| 461 | // task dispatch |
| 462 | { |
| 463 | auto &&ctx = impl_->dispatch_ctx; |
| 464 | ctx.co = nullptr; |
| 465 | ctx.consumer = this; |
| 466 | co_create(&(ctx.co), &attr, DispatchRoutineRun, &ctx); |
| 467 | co_resume(ctx.co); |
| 468 | } |
| 469 | |
| 470 | |
| 471 | co_eventloop(co_get_epoll_ct(), nullptr, this); |
| 472 | |
| 473 | comm::ConsumerConsumeBP::GetThreadInstance()->OnConsumeThreadRunEnd(impl_->cc); |
nothing calls this directly
no test coverage detected