aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-12-06 15:58:53 -0800
committerGravatar Muxi Yan <mxyan@google.com>2018-12-06 15:58:53 -0800
commitf9e50322bf1d6be736b415831eea44130b9dedfe (patch)
tree7da2c7f0be6c10a05303e5215c1630df339744ea
parenteeced98fc556c6a5bc3a5dedc171c98747217078 (diff)
batch fix
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.h16
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m4
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h49
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool.h28
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool.m7
-rw-r--r--src/objective-c/ProtoRPC/ProtoRPC.h16
-rw-r--r--src/objective-c/ProtoRPC/ProtoRPC.m5
-rw-r--r--src/objective-c/tests/ChannelTests/ChannelPoolTest.m2
-rw-r--r--src/objective-c/tests/ChannelTests/ChannelTests.m1
9 files changed, 73 insertions, 55 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h
index 985743433c..6d8b9c1b12 100644
--- a/src/objective-c/GRPCClient/GRPCCall.h
+++ b/src/objective-c/GRPCClient/GRPCCall.h
@@ -153,6 +153,14 @@ extern NSString *const kGRPCTrailersKey;
/** An object can implement this protocol to receive responses from server from a call. */
@protocol GRPCResponseHandler<NSObject>
+@required
+
+/**
+ * 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.
+ */
+@property(atomic, readonly) dispatch_queue_t dispatchQueue;
+
@optional
/**
@@ -175,14 +183,6 @@ extern NSString *const kGRPCTrailersKey;
- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata
error:(nullable NSError *)error;
-@required
-
-/**
- * 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.
- */
-@property(atomic, readonly) dispatch_queue_t dispatchQueue;
-
@end
/**
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index 48253677bd..e75ca7193a 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -856,9 +856,7 @@ const char *kCFStreamVarName = "grpc_cfstream";
_retainSelf = self;
if (_callOptions == nil) {
- GRPCMutableCallOptions *callOptions;
-
- callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy];
+ GRPCMutableCallOptions *callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy];
if (_serverName.length != 0) {
callOptions.serverAuthority = _serverName;
}
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h b/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h
new file mode 100644
index 0000000000..4e7c988585
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h
@@ -0,0 +1,49 @@
+/*
+ *
+ * Copyright 2018 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import "GRPCChannelPool.h"
+
+/** Test-only interface for \a GRPCPooledChannel. */
+@interface GRPCPooledChannel (Test)
+
+/**
+ * Initialize a pooled channel with non-default destroy delay for testing purpose.
+ */
+- (nullable instancetype)initWithChannelConfiguration:
+(GRPCChannelConfiguration *)channelConfiguration
+ destroyDelay:(NSTimeInterval)destroyDelay;
+
+/**
+ * Return the pointer to the raw channel wrapped.
+ */
+@property(atomic, readonly) GRPCChannel *wrappedChannel;
+
+@end
+
+/** Test-only interface for \a GRPCChannelPool. */
+@interface GRPCChannelPool (Test)
+
+/**
+ * Get an instance of pool isolated from the global shared pool with channels' destroy delay being
+ * \a destroyDelay.
+ */
+- (nullable instancetype)initTestPool;
+
+@end
+
+
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.h b/src/objective-c/GRPCClient/private/GRPCChannelPool.h
index 7c6f2b3bbf..d1f28ec9bf 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannelPool.h
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.h
@@ -75,23 +75,6 @@ NS_ASSUME_NONNULL_BEGIN
@end
-/** Test-only interface for \a GRPCPooledChannel. */
-@interface GRPCPooledChannel (Test)
-
-/**
- * Initialize a pooled channel with non-default destroy delay for testing purpose.
- */
-- (nullable instancetype)initWithChannelConfiguration:
-(GRPCChannelConfiguration *)channelConfiguration
- destroyDelay:(NSTimeInterval)destroyDelay;
-
-/**
- * Return the pointer to the raw channel wrapped.
- */
-@property(atomic, readonly) GRPCChannel *wrappedChannel;
-
-@end
-
/**
* Manage the pool of connected channels. When a channel is no longer referenced by any call,
* destroy the channel after a certain period of time elapsed.
@@ -119,15 +102,4 @@ NS_ASSUME_NONNULL_BEGIN
@end
-/** Test-only interface for \a GRPCChannelPool. */
-@interface GRPCChannelPool (Test)
-
-/**
- * Get an instance of pool isolated from the global shared pool with channels' destroy delay being
- * \a destroyDelay.
- */
-- (nullable instancetype)initTestPool;
-
-@end
-
NS_ASSUME_NONNULL_END
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCChannelPool.m
index 391022efd1..349bdd44a6 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannelPool.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.m
@@ -22,6 +22,7 @@
#import "GRPCChannel.h"
#import "GRPCChannelFactory.h"
#import "GRPCChannelPool.h"
+#import "GRPCChannelPool+Test.h"
#import "GRPCConnectivityMonitor.h"
#import "GRPCCronetChannelFactory.h"
#import "GRPCInsecureChannelFactory.h"
@@ -59,9 +60,7 @@ static const NSTimeInterval kDefaultChannelDestroyDelay = 30;
- (void)dealloc {
// Disconnect GRPCWrappedCall objects created but not yet removed
if (_wrappedCalls.allObjects.count != 0) {
- NSEnumerator *enumerator = [_wrappedCalls objectEnumerator];
- GRPCWrappedCall *wrappedCall;
- while ((wrappedCall = [enumerator nextObject])) {
+ for (GRPCWrappedCall *wrappedCall in _wrappedCalls.allObjects) {
[wrappedCall channelDisconnected];
};
}
@@ -73,7 +72,7 @@ callOptions:(GRPCCallOptions *)callOptions {
NSAssert(path.length > 0, @"path must not be empty.");
NSAssert(queue != nil, @"completionQueue must not be empty.");
NSAssert(callOptions, @"callOptions must not be empty.");
- if (path.length == 0 || queue == nil || callOptions == nil) return NULL;
+ if (path.length == 0 || queue == nil || callOptions == nil) return nil;
GRPCWrappedCall *call = nil;
diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h
index 287aa0369b..2e0400a323 100644
--- a/src/objective-c/ProtoRPC/ProtoRPC.h
+++ b/src/objective-c/ProtoRPC/ProtoRPC.h
@@ -28,6 +28,14 @@ NS_ASSUME_NONNULL_BEGIN
/** An object can implement this protocol to receive responses from server from a call. */
@protocol GRPCProtoResponseHandler<NSObject>
+@required
+
+/**
+ * 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.
+ */
+@property(atomic, readonly) dispatch_queue_t dispatchQueue;
+
@optional
/**
@@ -49,14 +57,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata
error:(nullable NSError *)error;
-@required
-
-/**
- * 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.
- */
-@property(atomic, readonly) dispatch_queue_t dispatchQueue;
-
@end
/** A unary-request RPC call with Protobuf. */
diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m
index 886e31ce58..0f63f72f53 100644
--- a/src/objective-c/ProtoRPC/ProtoRPC.m
+++ b/src/objective-c/ProtoRPC/ProtoRPC.m
@@ -75,7 +75,6 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing
- (void)cancel {
[_call cancel];
- _call = nil;
}
@end
@@ -124,7 +123,7 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing
#else
{
#endif
- _dispatchQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL);
+ _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
}
dispatch_set_target_queue(_dispatchQueue, handler.dispatchQueue);
@@ -145,7 +144,7 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing
copiedCall = _call;
_call = nil;
if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) {
- dispatch_async(_handler.dispatchQueue, ^{
+ dispatch_async(_dispatchQueue, ^{
id<GRPCProtoResponseHandler> copiedHandler = nil;
@synchronized(self) {
copiedHandler = self->_handler;
diff --git a/src/objective-c/tests/ChannelTests/ChannelPoolTest.m b/src/objective-c/tests/ChannelTests/ChannelPoolTest.m
index dc42d7c341..eab8c5193f 100644
--- a/src/objective-c/tests/ChannelTests/ChannelPoolTest.m
+++ b/src/objective-c/tests/ChannelTests/ChannelPoolTest.m
@@ -19,7 +19,7 @@
#import <XCTest/XCTest.h>
#import "../../GRPCClient/private/GRPCChannel.h"
-#import "../../GRPCClient/private/GRPCChannelPool.h"
+#import "../../GRPCClient/private/GRPCChannelPool+Test.h"
#import "../../GRPCClient/private/GRPCCompletionQueue.h"
#define TEST_TIMEOUT 32
diff --git a/src/objective-c/tests/ChannelTests/ChannelTests.m b/src/objective-c/tests/ChannelTests/ChannelTests.m
index ee7f8b6fdd..7c80868c2c 100644
--- a/src/objective-c/tests/ChannelTests/ChannelTests.m
+++ b/src/objective-c/tests/ChannelTests/ChannelTests.m
@@ -21,6 +21,7 @@
#import "../../GRPCClient/GRPCCallOptions.h"
#import "../../GRPCClient/private/GRPCChannel.h"
#import "../../GRPCClient/private/GRPCChannelPool.h"
+#import "../../GRPCClient/private/GRPCChannelPool+Test.h"
#import "../../GRPCClient/private/GRPCCompletionQueue.h"
#import "../../GRPCClient/private/GRPCWrappedCall.h"