diff options
author | 2018-10-16 17:10:32 -0700 | |
---|---|---|
committer | 2018-10-16 17:10:32 -0700 | |
commit | 7d32a2cb25275e03a44184ad9f8a3e494e62dd0d (patch) | |
tree | 3269faf207438c68dfe5e12e42a6f1f1f25aa4dc /src | |
parent | da43545ff7b4b1a6e310ff7fdeec6eb21f0e26b8 (diff) |
Set user's dispatch queue's handler to internal serial queue
Diffstat (limited to 'src')
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall.h | 4 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall.m | 7 | ||||
-rw-r--r-- | src/objective-c/ProtoRPC/ProtoRPC.h | 4 | ||||
-rw-r--r-- | src/objective-c/ProtoRPC/ProtoRPC.m | 11 |
4 files changed, 20 insertions, 6 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 48f4514a06..6adecec144 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -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; diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 50c38ed99e..917788e9f2 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -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; } diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index d20098ce8c..db1e8c6deb 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -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; diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index b860515d4e..9fb398408b 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -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]; } |