|
|
|
@ -101,9 +101,12 @@ static void push_front_worker(grpc_pollset *p, grpc_pollset_worker *worker) { |
|
|
|
|
void grpc_pollset_kick_ext(grpc_pollset *p, |
|
|
|
|
grpc_pollset_worker *specific_worker, |
|
|
|
|
gpr_uint32 flags) { |
|
|
|
|
GRPC_TIMER_BEGIN("grpc_pollset_kick_ext", 0); |
|
|
|
|
|
|
|
|
|
/* pollset->mu already held */ |
|
|
|
|
if (specific_worker != NULL) { |
|
|
|
|
if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) { |
|
|
|
|
GRPC_TIMER_BEGIN("grpc_pollset_kick_ext.broadcast", 0); |
|
|
|
|
GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0); |
|
|
|
|
for (specific_worker = p->root_worker.next; |
|
|
|
|
specific_worker != &p->root_worker; |
|
|
|
@ -111,44 +114,50 @@ void grpc_pollset_kick_ext(grpc_pollset *p, |
|
|
|
|
grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd); |
|
|
|
|
} |
|
|
|
|
p->kicked_without_pollers = 1; |
|
|
|
|
return; |
|
|
|
|
GRPC_TIMER_END("grpc_pollset_kick_ext.broadcast", 0); |
|
|
|
|
} else if (gpr_tls_get(&g_current_thread_worker) != |
|
|
|
|
(gpr_intptr)specific_worker) { |
|
|
|
|
GRPC_TIMER_MARK("different_thread_worker", 0); |
|
|
|
|
if ((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) != 0) { |
|
|
|
|
specific_worker->reevaluate_polling_on_wakeup = 1; |
|
|
|
|
} |
|
|
|
|
grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd); |
|
|
|
|
return; |
|
|
|
|
} else if ((flags & GRPC_POLLSET_CAN_KICK_SELF) != 0) { |
|
|
|
|
GRPC_TIMER_MARK("kick_yoself", 0); |
|
|
|
|
if ((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) != 0) { |
|
|
|
|
specific_worker->reevaluate_polling_on_wakeup = 1; |
|
|
|
|
} |
|
|
|
|
grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} else if (gpr_tls_get(&g_current_thread_poller) != (gpr_intptr)p) { |
|
|
|
|
GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0); |
|
|
|
|
GRPC_TIMER_MARK("kick_anonymous", 0); |
|
|
|
|
specific_worker = pop_front_worker(p); |
|
|
|
|
if (specific_worker != NULL) { |
|
|
|
|
if (gpr_tls_get(&g_current_thread_worker) == |
|
|
|
|
(gpr_intptr)specific_worker) { |
|
|
|
|
GRPC_TIMER_MARK("kick_anonymous_not_self", 0); |
|
|
|
|
push_back_worker(p, specific_worker); |
|
|
|
|
specific_worker = pop_front_worker(p); |
|
|
|
|
if ((flags & GRPC_POLLSET_CAN_KICK_SELF) == 0 && |
|
|
|
|
gpr_tls_get(&g_current_thread_worker) == |
|
|
|
|
(gpr_intptr)specific_worker) { |
|
|
|
|
push_back_worker(p, specific_worker); |
|
|
|
|
return; |
|
|
|
|
specific_worker = NULL; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
push_back_worker(p, specific_worker); |
|
|
|
|
grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd); |
|
|
|
|
return; |
|
|
|
|
if (specific_worker != NULL) { |
|
|
|
|
GRPC_TIMER_MARK("finally_kick", 0); |
|
|
|
|
push_back_worker(p, specific_worker); |
|
|
|
|
grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
GRPC_TIMER_MARK("kicked_no_pollers", 0); |
|
|
|
|
p->kicked_without_pollers = 1; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
GRPC_TIMER_END("grpc_pollset_kick_ext", 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void grpc_pollset_kick(grpc_pollset *p, grpc_pollset_worker *specific_worker) { |
|
|
|
|