mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
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.
This commit is contained in:
parent
f35d735d69
commit
4ece70db5b
@ -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<Value> argv[] = {NanNull(), GetTagNodeValue(result->tag)};
|
||||
NanCallback *callback = GetTagCallback(result.tag);
|
||||
Handle<Value> 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<Value> argv[] = {NanError(ErrorMessage())};
|
||||
|
||||
callback->Call(1, argv);
|
||||
|
||||
DestroyTag(result->tag);
|
||||
grpc_event_finish(result);
|
||||
result = NULL;
|
||||
DestroyTag(result.tag);
|
||||
}
|
||||
|
||||
} // namespace node
|
||||
|
||||
@ -70,7 +70,7 @@ class CompletionQueueAsyncWorker : public NanAsyncWorker {
|
||||
void HandleErrorCallback();
|
||||
|
||||
private:
|
||||
grpc_event *result;
|
||||
grpc_event result;
|
||||
|
||||
static grpc_completion_queue *queue;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user