Set user's dispatch queue's handler to internal serial queue

pull/16190/head
Muxi Yan 6 years ago
parent da43545ff7
commit 7d32a2cb25
  1. 4
      src/objective-c/GRPCClient/GRPCCall.h
  2. 7
      src/objective-c/GRPCClient/GRPCCall.m
  3. 4
      src/objective-c/ProtoRPC/ProtoRPC.h
  4. 11
      src/objective-c/ProtoRPC/ProtoRPC.m

@ -174,9 +174,7 @@ extern id const kGRPCTrailersKey;
/**
* All the responses must be issued to a user-provided dispatch queue. This property specifies the
* dispatch queue to be used for issuing the notifications. A serial queue should be provided if
* the order of responses (initial metadata, message, message, ..., message, trailing metadata)
* needs to be maintained.
* dispatch queue to be used for issuing the notifications.
*/
@property(atomic, readonly) dispatch_queue_t dispatchQueue;

@ -101,6 +101,12 @@ const char *kCFStreamVarName = "grpc_cfstream";
if (requestOptions.host.length == 0 || requestOptions.path.length == 0) {
[NSException raise:NSInvalidArgumentException format:@"Neither host nor path can be nil."];
}
if (requestOptions.safety > GRPCCallSafetyCacheableRequest) {
[NSException raise:NSInvalidArgumentException format:@"Invalid call safety value."];
}
if (responseHandler == nil) {
[NSException raise:NSInvalidArgumentException format:@"Response handler required."];
}
if ((self = [super init])) {
_requestOptions = [requestOptions copy];
@ -114,6 +120,7 @@ const char *kCFStreamVarName = "grpc_cfstream";
// Fallback on earlier versions
_dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
}
dispatch_set_target_queue(responseHandler.dispatchQueue, _dispatchQueue);
_started = NO;
}

@ -48,9 +48,7 @@
/**
* All the responses must be issued to a user-provided dispatch queue. This property specifies the
* dispatch queue to be used for issuing the notifications. A serial queue should be provided if
* the order of responses (initial metadata, message, message, ..., message, trailing metadata)
* needs to be maintained.
* dispatch queue to be used for issuing the notifications.
*/
@property(atomic, readonly) dispatch_queue_t dispatchQueue;

@ -72,6 +72,16 @@
responseHandler:(id<GRPCProtoResponseHandler>)handler
callOptions:(GRPCCallOptions *)callOptions
responseClass:(Class)responseClass {
if (requestOptions.host.length == 0 || requestOptions.path.length == 0) {
[NSException raise:NSInvalidArgumentException format:@"Neither host nor path can be nil."];
}
if (requestOptions.safety > GRPCCallSafetyCacheableRequest) {
[NSException raise:NSInvalidArgumentException format:@"Invalid call safety value."];
}
if (handler == nil) {
[NSException raise:NSInvalidArgumentException format:@"Response handler required."];
}
if ((self = [super init])) {
_requestOptions = [requestOptions copy];
_handler = handler;
@ -82,6 +92,7 @@
} else {
_dispatchQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL);
}
dispatch_set_target_queue(handler.dispatchQueue, _dispatchQueue);
[self start];
}

Loading…
Cancel
Save