Merge pull request #2219 from nicolasnoble/cascade-kick-should-happen-higher

Reworking the cascade kick to be Windows-specific.
pull/2222/head
Craig Tiller 10 years ago
commit 88f8e940a0
  1. 10
      src/core/iomgr/pollset_windows.c
  2. 1
      src/core/iomgr/pollset_windows.h
  3. 1
      src/core/surface/completion_queue.c

@ -48,6 +48,7 @@
won't actually do any polling, and return as quickly as possible. */
void grpc_pollset_init(grpc_pollset *pollset) {
memset(pollset, 0, sizeof(*pollset));
gpr_mu_init(&pollset->mu);
gpr_cv_init(&pollset->cv);
}
@ -55,7 +56,10 @@ void grpc_pollset_init(grpc_pollset *pollset) {
void grpc_pollset_shutdown(grpc_pollset *pollset,
void (*shutdown_done)(void *arg),
void *shutdown_done_arg) {
grpc_pollset_kick(pollset);
gpr_mu_lock(&pollset->mu);
pollset->shutting_down = 1;
gpr_cv_broadcast(&pollset->cv);
gpr_mu_unlock(&pollset->mu);
shutdown_done(shutdown_done_arg);
}
@ -76,7 +80,9 @@ int grpc_pollset_work(grpc_pollset *pollset, gpr_timespec deadline) {
if (grpc_alarm_check(&pollset->mu, now, &deadline)) {
return 1 /* GPR_TRUE */;
}
gpr_cv_wait(&pollset->cv, &pollset->mu, deadline);
if (!pollset->shutting_down) {
gpr_cv_wait(&pollset->cv, &pollset->mu, deadline);
}
return 1 /* GPR_TRUE */;
}

@ -46,6 +46,7 @@
typedef struct grpc_pollset {
gpr_mu mu;
gpr_cv cv;
int shutting_down;
} grpc_pollset;
#define GRPC_POLLSET_MU(pollset) (&(pollset)->mu)

@ -208,7 +208,6 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
}
if (cc->shutdown) {
ev = create_shutdown_event();
grpc_pollset_kick(&cc->pollset);
break;
}
if (!grpc_pollset_work(&cc->pollset, deadline)) {

Loading…
Cancel
Save