diff options
author | 2017-05-11 10:55:02 -0700 | |
---|---|---|
committer | 2017-05-11 10:55:02 -0700 | |
commit | 63cde40c6dc031dcb358b7058fe3805284a6ad16 (patch) | |
tree | f55a352f0cb5356d1c5de3e12071ac182b135e0e /src/core/lib/support/mpscq.c | |
parent | 6d06776a126d90437361dcb295758a717d4b866d (diff) | |
parent | 822aae53d37bd569780b88bae5caa1fa2a5987ca (diff) |
Merge pull request #11010 from ctiller/uberpoll
Roll up of all new polling engines
Diffstat (limited to 'src/core/lib/support/mpscq.c')
-rw-r--r-- | src/core/lib/support/mpscq.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/lib/support/mpscq.c b/src/core/lib/support/mpscq.c index 5b9323275a..1015cc6776 100644 --- a/src/core/lib/support/mpscq.c +++ b/src/core/lib/support/mpscq.c @@ -54,21 +54,31 @@ void gpr_mpscq_push(gpr_mpscq *q, gpr_mpscq_node *n) { } gpr_mpscq_node *gpr_mpscq_pop(gpr_mpscq *q) { + bool empty; + return gpr_mpscq_pop_and_check_end(q, &empty); +} + +gpr_mpscq_node *gpr_mpscq_pop_and_check_end(gpr_mpscq *q, bool *empty) { gpr_mpscq_node *tail = q->tail; gpr_mpscq_node *next = (gpr_mpscq_node *)gpr_atm_acq_load(&tail->next); if (tail == &q->stub) { // indicates the list is actually (ephemerally) empty - if (next == NULL) return NULL; + if (next == NULL) { + *empty = true; + return NULL; + } q->tail = next; tail = next; next = (gpr_mpscq_node *)gpr_atm_acq_load(&tail->next); } if (next != NULL) { + *empty = false; q->tail = next; return tail; } gpr_mpscq_node *head = (gpr_mpscq_node *)gpr_atm_acq_load(&q->head); if (tail != head) { + *empty = false; // indicates a retry is in order: we're still adding return NULL; } @@ -79,5 +89,6 @@ gpr_mpscq_node *gpr_mpscq_pop(gpr_mpscq *q) { return tail; } // indicates a retry is in order: we're still adding + *empty = false; return NULL; } |