From 4ece70db5beb05959617f186c7ac07f7844fb8e5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 4 May 2015 14:53:51 -0700 Subject: [PATCH] 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. --- ext/completion_queue_async_worker.cc | 16 ++++++---------- ext/completion_queue_async_worker.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ext/completion_queue_async_worker.cc b/ext/completion_queue_async_worker.cc index 4e57121a..4be208c8 100644 --- a/ext/completion_queue_async_worker.cc +++ b/ext/completion_queue_async_worker.cc @@ -63,7 +63,7 @@ CompletionQueueAsyncWorker::~CompletionQueueAsyncWorker() {} void CompletionQueueAsyncWorker::Execute() { result = grpc_completion_queue_next(queue, gpr_inf_future); - if (result->data.op_complete != GRPC_OP_OK) { + if (!result.success) { SetErrorMessage("The batch encountered an error"); } } @@ -96,25 +96,21 @@ void CompletionQueueAsyncWorker::HandleOKCallback() { } else { current_threads -= 1; } - NanCallback *callback = GetTagCallback(result->tag); - Handle argv[] = {NanNull(), GetTagNodeValue(result->tag)}; + NanCallback *callback = GetTagCallback(result.tag); + Handle argv[] = {NanNull(), GetTagNodeValue(result.tag)}; callback->Call(2, argv); - DestroyTag(result->tag); - grpc_event_finish(result); - result = NULL; + DestroyTag(result.tag); } void CompletionQueueAsyncWorker::HandleErrorCallback() { NanScope(); - NanCallback *callback = GetTagCallback(result->tag); + NanCallback *callback = GetTagCallback(result.tag); Handle argv[] = {NanError(ErrorMessage())}; callback->Call(1, argv); - DestroyTag(result->tag); - grpc_event_finish(result); - result = NULL; + DestroyTag(result.tag); } } // namespace node diff --git a/ext/completion_queue_async_worker.h b/ext/completion_queue_async_worker.h index 5d52bbb1..27fedf2f 100644 --- a/ext/completion_queue_async_worker.h +++ b/ext/completion_queue_async_worker.h @@ -70,7 +70,7 @@ class CompletionQueueAsyncWorker : public NanAsyncWorker { void HandleErrorCallback(); private: - grpc_event *result; + grpc_event result; static grpc_completion_queue *queue;