use a thread-local variable to get the current running loop
if we had a method to get the running loop, similar to how isc_tid() gets the current thread ID, we can simplify loop and loopmgr initialization. remove most uses of isc_loop_current() in favor of isc_loop(). in some places where that was the only reason to pass loopmgr, remove loopmgr from the function parameters.
This commit is contained in:
@@ -61,8 +61,7 @@ isc_timer_create(isc_loop_t *loop, isc_job_cb cb, void *cbarg,
|
||||
loopmgr = loop->loopmgr;
|
||||
|
||||
REQUIRE(VALID_LOOPMGR(loopmgr));
|
||||
|
||||
REQUIRE(loop == isc_loop_current(loopmgr));
|
||||
REQUIRE(loop == isc_loop());
|
||||
|
||||
timer = isc_mem_get(loop->mctx, sizeof(*timer));
|
||||
*timer = (isc_timer_t){
|
||||
@@ -92,7 +91,7 @@ isc_timer_stop(isc_timer_t *timer) {
|
||||
}
|
||||
|
||||
/* Stop the timer, if the loops are matching */
|
||||
if (timer->loop == isc_loop_current(timer->loop->loopmgr)) {
|
||||
if (timer->loop == isc_loop()) {
|
||||
uv_timer_stop(&timer->timer);
|
||||
}
|
||||
}
|
||||
@@ -120,7 +119,7 @@ isc_timer_start(isc_timer_t *timer, isc_timertype_t type,
|
||||
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
REQUIRE(type == isc_timertype_ticker || type == isc_timertype_once);
|
||||
REQUIRE(timer->loop == isc_loop_current(timer->loop->loopmgr));
|
||||
REQUIRE(timer->loop == isc_loop());
|
||||
|
||||
loop = timer->loop;
|
||||
|
||||
@@ -180,7 +179,7 @@ isc_timer_destroy(isc_timer_t **timerp) {
|
||||
timer = *timerp;
|
||||
*timerp = NULL;
|
||||
|
||||
REQUIRE(timer->loop == isc_loop_current(timer->loop->loopmgr));
|
||||
REQUIRE(timer->loop == isc_loop());
|
||||
|
||||
timer_destroy(timer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user