typedef struct isc__workthread isc__workthread_t;
isc__workthread_t *
-isc__workthread_create(isc_mem_t *mctx, isc_worklane_t lane);
+isc__workthread_create(isc_loop_t *loop, isc_worklane_t lane);
/*%<
* Create one worker thread for 'lane' with its own dispatch queue (the loop
* manager creates one per loop). Used by the loop manager; not for general
UV_RUNTIME_CHECK(uv_prepare_start, r);
for (isc_worklane_t lane = 0; lane < ISC_WORKLANE_COUNT; lane++) {
- loop->workthreads[lane] =
- isc__workthread_create(isc__loopmgr->mctx, lane);
+ loop->workthreads[lane] = isc__workthread_create(loop, lane);
}
isc_barrier_wait(&loopmgr->starting);
struct {
unsigned int magic;
isc_worklane_t lane;
- isc_mem_t *mctx;
+ isc_loop_t *loop;
isc_thread_t thread;
struct __cds_wfcq_head qhead;
int32_t state; /* enum waitstate */
}
isc__workthread_t *
-isc__workthread_create(isc_mem_t *mctx, isc_worklane_t lane) {
- isc__workthread_t *thread = isc_mem_get(mctx, sizeof(*thread));
+isc__workthread_create(isc_loop_t *loop, isc_worklane_t lane) {
+ isc__workthread_t *thread = isc_mem_get(loop->mctx, sizeof(*thread));
*thread = (isc__workthread_t){
.lane = lane,
.magic = WORKTHREAD_MAGIC,
.state = THREAD_WAITING,
- .mctx = isc_mem_ref(mctx),
+ .loop = loop,
};
__cds_wfcq_init(&thread->qhead, &thread->qtail);
INSIST(cds_wfcq_empty(&thread->qhead, &thread->qtail));
thread->magic = 0;
- isc_mem_putanddetach(&thread->mctx, thread, sizeof(*thread));
+ isc_mem_put(thread->loop->mctx, thread, sizeof(*thread));
}
void