aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2015-08-05 16:36:10 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2015-08-05 16:36:10 -0700
commit0607bae87e0f3417972bc221a5c4f8dc6bec5fef (patch)
tree8e96046decc59df06220cf07c7e48047688f0541 /src
parent7d261ee5b6bf69378787600971de0361d2c76081 (diff)
Forward-declare grpc_channel and specify ownership semantics
Diffstat (limited to 'src')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.h8
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.m2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.h b/src/objective-c/GRPCClient/private/GRPCChannel.h
index de0b58ffe4..2a7b701576 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.h
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.h
@@ -33,12 +33,14 @@
#import <Foundation/Foundation.h>
-#include <grpc/grpc.h>
+struct grpc_channel;
// Each separate instance of this class represents at least one TCP connection to the provided host.
// Create them using one of the subclasses |GRPCSecureChannel| and |GRPCUnsecuredChannel|.
@interface GRPCChannel : NSObject
-@property(nonatomic, readonly) grpc_channel *unmanagedChannel;
+@property(nonatomic, readonly) struct grpc_channel *unmanagedChannel;
-- (instancetype)initWithChannel:(grpc_channel *)unmanagedChannel NS_DESIGNATED_INITIALIZER;
+// This initializer takes ownership of the passed channel, and will destroy it when this object is
+// deallocated. It's illegal to pass the same grpc_channel to two different GRPCChannel objects.
+- (instancetype)initWithChannel:(struct grpc_channel *)unmanagedChannel NS_DESIGNATED_INITIALIZER;
@end
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m
index 49d6008fd4..4366e63320 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.m
@@ -33,6 +33,8 @@
#import "GRPCChannel.h"
+#include <grpc/grpc.h>
+
@implementation GRPCChannel
- (instancetype)init {