Merge pull request #6 from murgatroid99/objective_c_completion_queue_update

Updated Objective C code to match completion queue changes
pull/1472/head
Craig Tiller 10 years ago
commit f00454a646
  1. BIN
      src/objective-c/GRPCClient/.DS_Store
  2. BIN
      src/objective-c/GRPCClient/private/.DS_Store
  3. 2
      src/objective-c/GRPCClient/private/GRPCCompletionQueue.h
  4. 11
      src/objective-c/GRPCClient/private/GRPCCompletionQueue.m
  5. 4
      src/objective-c/GRPCClient/private/GRPCWrappedCall.m

Binary file not shown.

Binary file not shown.

@ -34,7 +34,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
typedef void(^GRPCQueueCompletionHandler)(grpc_op_error error); typedef void(^GRPCQueueCompletionHandler)(bool success);
// This class lets one more easily use grpc_completion_queue. To use it, pass // This class lets one more easily use grpc_completion_queue. To use it, pass
// the value of the unmanagedQueue property of an instance of this class to // the value of the unmanagedQueue property of an instance of this class to

@ -65,20 +65,17 @@
dispatch_async(gDefaultConcurrentQueue, ^{ dispatch_async(gDefaultConcurrentQueue, ^{
while (YES) { while (YES) {
// The following call blocks until an event is available. // The following call blocks until an event is available.
grpc_event *event = grpc_completion_queue_next(unmanagedQueue, gpr_inf_future); grpc_event event = grpc_completion_queue_next(unmanagedQueue, gpr_inf_future);
GRPCQueueCompletionHandler handler; GRPCQueueCompletionHandler handler;
switch (event->type) { switch (event.type) {
case GRPC_OP_COMPLETE: case GRPC_OP_COMPLETE:
handler = (__bridge_transfer GRPCQueueCompletionHandler)event->tag; handler = (__bridge_transfer GRPCQueueCompletionHandler)event.tag;
handler(event->data.op_complete); handler(event.success);
grpc_event_finish(event);
break; break;
case GRPC_QUEUE_SHUTDOWN: case GRPC_QUEUE_SHUTDOWN:
grpc_event_finish(event);
grpc_completion_queue_destroy(unmanagedQueue); grpc_completion_queue_destroy(unmanagedQueue);
return; return;
default: default:
grpc_event_finish(event);
[NSException raise:@"Unrecognized completion type" format:@""]; [NSException raise:@"Unrecognized completion type" format:@""];
} }
}; };

@ -296,8 +296,8 @@
[op getOp:&ops_array[i++]]; [op getOp:&ops_array[i++]];
} }
grpc_call_error error = grpc_call_start_batch(_call, ops_array, nops, grpc_call_error error = grpc_call_start_batch(_call, ops_array, nops,
(__bridge_retained void *)(^(grpc_op_error error){ (__bridge_retained void *)(^(bool success){
if (error != GRPC_OP_OK) { if (!success) {
if (errorHandler) { if (errorHandler) {
errorHandler(); errorHandler();
} else { } else {

Loading…
Cancel
Save