| 131 | } |
| 132 | |
| 133 | void BenchMark::ThreadRun(const int vtid) { |
| 134 | stCoRoutineAttr_t attr; |
| 135 | attr.stack_size = 1024 * 16; |
| 136 | |
| 137 | |
| 138 | std::unique_ptr<struct CoWorkerCtx_t[]> ctxs(new struct CoWorkerCtx_t[impl_->nroutine]); |
| 139 | |
| 140 | for (int i{0}; i < impl_->nroutine; ++i) |
| 141 | { |
| 142 | CoWorkerCtx_t *ctx = &ctxs[i]; |
| 143 | ctx->co = nullptr; |
| 144 | ctx->bm = this; |
| 145 | ctx->vtid = vtid; |
| 146 | ctx->rid = i; |
| 147 | |
| 148 | co_create(&(ctx->co), &attr, RoutineRunFunc, ctx); |
| 149 | co_resume(ctx->co); |
| 150 | } |
| 151 | co_eventloop(co_get_epoll_ct(), nullptr, this); |
| 152 | } |
| 153 | |
| 154 | void BenchMark::Run() |
| 155 | { |