|
|
|
@ -196,7 +196,7 @@ typedef struct cq_vtable { |
|
|
|
|
void (*init)(void *data); |
|
|
|
|
void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq); |
|
|
|
|
void (*destroy)(void *data); |
|
|
|
|
int (*begin_op)(grpc_completion_queue *cq, void *tag); |
|
|
|
|
bool (*begin_op)(grpc_completion_queue *cq, void *tag); |
|
|
|
|
void (*end_op)(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cq, void *tag, |
|
|
|
|
grpc_error *error, |
|
|
|
|
void (*done)(grpc_exec_ctx *exec_ctx, void *done_arg, |
|
|
|
@ -288,8 +288,8 @@ static void cq_shutdown_next(grpc_exec_ctx *exec_ctx, |
|
|
|
|
static void cq_shutdown_pluck(grpc_exec_ctx *exec_ctx, |
|
|
|
|
grpc_completion_queue *cq); |
|
|
|
|
|
|
|
|
|
static int cq_begin_op_for_next(grpc_completion_queue *cq, void *tag); |
|
|
|
|
static int cq_begin_op_for_pluck(grpc_completion_queue *cq, void *tag); |
|
|
|
|
static bool cq_begin_op_for_next(grpc_completion_queue *cq, void *tag); |
|
|
|
|
static bool cq_begin_op_for_pluck(grpc_completion_queue *cq, void *tag); |
|
|
|
|
|
|
|
|
|
static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx, |
|
|
|
|
grpc_completion_queue *cq, void *tag, |
|
|
|
@ -549,28 +549,28 @@ static void cq_check_tag(grpc_completion_queue *cq, void *tag, bool lock_cq) { |
|
|
|
|
static void cq_check_tag(grpc_completion_queue *cq, void *tag, bool lock_cq) {} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
static int cq_begin_op_for_next(grpc_completion_queue *cq, void *tag) { |
|
|
|
|
static bool cq_begin_op_for_next(grpc_completion_queue *cq, void *tag) { |
|
|
|
|
cq_next_data *cqd = DATA_FROM_CQ(cq); |
|
|
|
|
while (true) { |
|
|
|
|
gpr_atm count = gpr_atm_no_barrier_load(&cqd->pending_events); |
|
|
|
|
if (count == 0) { |
|
|
|
|
cq_check_tag(cq, tag, true); /* Used in debug builds only */ |
|
|
|
|
return 1; |
|
|
|
|
return false; |
|
|
|
|
} else if (gpr_atm_no_barrier_cas(&cqd->pending_events, count, count + 1)) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int cq_begin_op_for_pluck(grpc_completion_queue *cq, void *tag) { |
|
|
|
|
static bool cq_begin_op_for_pluck(grpc_completion_queue *cq, void *tag) { |
|
|
|
|
cq_pluck_data *cqd = DATA_FROM_CQ(cq); |
|
|
|
|
GPR_ASSERT(!cqd->shutdown_called); |
|
|
|
|
gpr_ref(&cqd->pending_events); |
|
|
|
|
return 0; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int grpc_cq_begin_op(grpc_completion_queue *cq, void *tag) { |
|
|
|
|
bool grpc_cq_begin_op(grpc_completion_queue *cq, void *tag) { |
|
|
|
|
#ifndef NDEBUG |
|
|
|
|
gpr_mu_lock(cq->mu); |
|
|
|
|
if (cq->outstanding_tag_count == cq->outstanding_tag_capacity) { |
|
|
|
|