Skip to content
Snippets Groups Projects
Commit 00ff7df7 authored by David Garcia Quintas's avatar David Garcia Quintas
Browse files

Removed callback queue sync from iomgr.

parent b8b59b18
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,6 @@ typedef struct delayed_callback { ...@@ -50,7 +50,6 @@ typedef struct delayed_callback {
} delayed_callback; } delayed_callback;
static gpr_mu g_mu; static gpr_mu g_mu;
static gpr_cv g_cv;
static gpr_cv g_rcv; static gpr_cv g_rcv;
static delayed_callback *g_cbs_head = NULL; static delayed_callback *g_cbs_head = NULL;
static delayed_callback *g_cbs_tail = NULL; static delayed_callback *g_cbs_tail = NULL;
...@@ -64,6 +63,8 @@ static void background_callback_executor(void *ignored) { ...@@ -64,6 +63,8 @@ static void background_callback_executor(void *ignored) {
gpr_mu_lock(&g_mu); gpr_mu_lock(&g_mu);
while (!g_shutdown) { while (!g_shutdown) {
gpr_timespec deadline = gpr_inf_future; gpr_timespec deadline = gpr_inf_future;
gpr_timespec short_deadline =
gpr_time_add(gpr_now(), gpr_time_from_millis(100));
if (g_cbs_head) { if (g_cbs_head) {
delayed_callback *cb = g_cbs_head; delayed_callback *cb = g_cbs_head;
g_cbs_head = cb->next; g_cbs_head = cb->next;
...@@ -74,19 +75,20 @@ static void background_callback_executor(void *ignored) { ...@@ -74,19 +75,20 @@ static void background_callback_executor(void *ignored) {
gpr_mu_lock(&g_mu); gpr_mu_lock(&g_mu);
} else if (grpc_alarm_check(&g_mu, gpr_now(), &deadline)) { } else if (grpc_alarm_check(&g_mu, gpr_now(), &deadline)) {
} else { } else {
gpr_cv_wait(&g_cv, &g_mu, deadline); gpr_mu_unlock(&g_mu);
gpr_sleep_until(gpr_time_min(short_deadline, deadline));
gpr_mu_lock(&g_mu);
} }
} }
gpr_mu_unlock(&g_mu); gpr_mu_unlock(&g_mu);
gpr_event_set(&g_background_callback_executor_done, (void *)1); gpr_event_set(&g_background_callback_executor_done, (void *)1);
} }
void grpc_kick_poller(void) { gpr_cv_broadcast(&g_cv); } void grpc_kick_poller(void) { }
void grpc_iomgr_init(void) { void grpc_iomgr_init(void) {
gpr_thd_id id; gpr_thd_id id;
gpr_mu_init(&g_mu); gpr_mu_init(&g_mu);
gpr_cv_init(&g_cv);
gpr_cv_init(&g_rcv); gpr_cv_init(&g_rcv);
grpc_alarm_list_init(gpr_now()); grpc_alarm_list_init(gpr_now());
g_refs = 0; g_refs = 0;
...@@ -143,7 +145,6 @@ void grpc_iomgr_shutdown(void) { ...@@ -143,7 +145,6 @@ void grpc_iomgr_shutdown(void) {
grpc_iomgr_platform_shutdown(); grpc_iomgr_platform_shutdown();
grpc_alarm_list_shutdown(); grpc_alarm_list_shutdown();
gpr_mu_destroy(&g_mu); gpr_mu_destroy(&g_mu);
gpr_cv_destroy(&g_cv);
gpr_cv_destroy(&g_rcv); gpr_cv_destroy(&g_rcv);
} }
...@@ -175,7 +176,6 @@ void grpc_iomgr_add_delayed_callback(grpc_iomgr_cb_func cb, void *cb_arg, ...@@ -175,7 +176,6 @@ void grpc_iomgr_add_delayed_callback(grpc_iomgr_cb_func cb, void *cb_arg,
g_cbs_tail->next = dcb; g_cbs_tail->next = dcb;
g_cbs_tail = dcb; g_cbs_tail = dcb;
} }
gpr_cv_signal(&g_cv);
gpr_mu_unlock(&g_mu); gpr_mu_unlock(&g_mu);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment