aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-08-11 17:28:42 -0700
committerGravatar murgatroid99 <mlumish@google.com>2015-08-11 17:28:42 -0700
commit9e2b7c81b10f79085df25a27fd2ab4b37e7d00e5 (patch)
tree6a98eedeb3353289bee6ea5b44af8cbb62e031fa /src/objective-c/GRPCClient/private/GRPCWrappedCall.m
parenta16b5ef455c63a18929b4ef90945e90f01c1fd58 (diff)
parent9a2a3aecc8f7d667df0236df0367bb59a4ae37b1 (diff)
Resolved merge conflicts with master
Diffstat (limited to 'src/objective-c/GRPCClient/private/GRPCWrappedCall.m')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.m39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
index 1db63df77f..951c051036 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
@@ -32,11 +32,14 @@
*/
#import "GRPCWrappedCall.h"
+
#import <Foundation/Foundation.h>
#include <grpc/grpc.h>
#include <grpc/byte_buffer.h>
#include <grpc/support/alloc.h>
+
#import "GRPCCompletionQueue.h"
+#import "GRPCHost.h"
#import "NSDictionary+GRPC.h"
#import "NSData+GRPC.h"
#import "NSError+GRPC.h"
@@ -219,38 +222,36 @@
@end
-@implementation GRPCWrappedCall{
- grpc_call *_call;
+#pragma mark GRPCWrappedCall
+
+@implementation GRPCWrappedCall {
GRPCCompletionQueue *_queue;
+ grpc_call *_call;
}
- (instancetype)init {
- return [self initWithChannel:nil path:nil host:nil];
+ return [self initWithHost:nil path:nil];
}
-- (instancetype)initWithChannel:(GRPCChannel *)channel
- path:(NSString *)path
- host:(NSString *)host {
- if (!channel || !path || !host) {
+- (instancetype)initWithHost:(NSString *)host
+ path:(NSString *)path {
+ if (!path || !host) {
[NSException raise:NSInvalidArgumentException
- format:@"channel, method, and host cannot be nil."];
+ format:@"path and host cannot be nil."];
}
-
+
if (self = [super init]) {
static dispatch_once_t initialization;
dispatch_once(&initialization, ^{
grpc_init();
});
-
+
+ // Each completion queue consumes one thread. There's a trade to be made between creating and
+ // consuming too many threads and having contention of multiple calls in a single completion
+ // queue. Currently we favor latency and use one per call.
_queue = [GRPCCompletionQueue completionQueue];
- if (!_queue) {
- return nil;
- }
- _call = grpc_channel_create_call(channel.unmanagedChannel,
- _queue.unmanagedQueue,
- path.UTF8String,
- host.UTF8String,
- gpr_inf_future(GPR_CLOCK_REALTIME));
+
+ _call = [[GRPCHost hostWithAddress:host] unmanagedCallWithPath:path completionQueue:_queue];
if (_call == NULL) {
return nil;
}
@@ -299,4 +300,4 @@
grpc_call_destroy(_call);
}
-@end \ No newline at end of file
+@end