diff options
author | Craig Tiller <ctiller@google.com> | 2015-05-04 14:53:51 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-05-04 14:53:51 -0700 |
commit | 64be9f7a30a4bcb9ce3647f11ba9e06994aa3bb7 (patch) | |
tree | 42a4af35a2fe0f3a79573ff37130fd6b74c55cb9 /src/csharp/ext | |
parent | c112d146a2dcc5e90d5f5cca10f55f212f9492c6 (diff) |
C Core API cleanup.
Simplify grpc_event into something that can be non-heap allocated.
Deprecate grpc_event_finish.
Remove grpc_op_error - use an int as this is more idiomatic C style.
Diffstat (limited to 'src/csharp/ext')
-rw-r--r-- | src/csharp/ext/grpc_csharp_ext.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index fb8b75798d..df812c816e 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -63,8 +63,7 @@ grpc_byte_buffer *string_to_byte_buffer(const char *buffer, size_t len) { return bb; } -typedef void(GPR_CALLTYPE *callback_funcptr)(grpc_op_error op_error, - void *batch_context); +typedef void(GPR_CALLTYPE *callback_funcptr)(int success, void *batch_context); /* * Helper to maintain lifetime of batch op inputs and store batch op outputs. @@ -302,27 +301,26 @@ grpcsharp_completion_queue_destroy(grpc_completion_queue *cq) { GPR_EXPORT grpc_completion_type GPR_CALLTYPE grpcsharp_completion_queue_next_with_callback(grpc_completion_queue *cq) { - grpc_event *ev; + grpc_event ev; grpcsharp_batch_context *batch_context; grpc_completion_type t; void(GPR_CALLTYPE * callback)(grpc_event *); ev = grpc_completion_queue_next(cq, gpr_inf_future); - t = ev->type; - if (t == GRPC_OP_COMPLETE && ev->tag) { + t = ev.type; + if (t == GRPC_OP_COMPLETE && ev.tag) { /* NEW API handler */ - batch_context = (grpcsharp_batch_context *)ev->tag; - batch_context->callback(ev->data.op_complete, batch_context); + batch_context = (grpcsharp_batch_context *)ev.tag; + batch_context->callback(ev.success, batch_context); grpcsharp_batch_context_destroy(batch_context); - } else if (ev->tag) { + } else if (ev.tag) { /* call the callback in ev->tag */ /* C forbids to cast object pointers to function pointers, so * we cast to intptr first. */ - callback = (void(GPR_CALLTYPE *)(grpc_event *))(gpr_intptr)ev->tag; - (*callback)(ev); + callback = (void(GPR_CALLTYPE *)(grpc_event *))(gpr_intptr)ev.tag; + (*callback)(&ev); } - grpc_event_finish(ev); /* return completion type to allow some handling for events that have no * tag - such as GRPC_QUEUE_SHUTDOWN @@ -789,7 +787,7 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_redirect_log(grpcsharp_log_func func) { /* For testing */ GPR_EXPORT void GPR_CALLTYPE grpcsharp_test_callback(callback_funcptr callback) { - callback(GRPC_OP_OK, NULL); + callback(1, NULL); } /* For testing */ |