diff options
author | Muxi Yan <mxyan@google.com> | 2017-03-22 14:30:16 -0700 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2017-03-22 14:30:16 -0700 |
commit | c2e53b5af4830c14d5cda72bba20df2855789300 (patch) | |
tree | c70183b10ec1a009269719df6ced9ccb6c1b0c62 | |
parent | 9f74e838e2cfdba10176e9fda3baa3dfe45a5ac0 (diff) |
Addressed the comments
-rw-r--r-- | src/objective-c/GRPCClient/GRPCCall.m | 5 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCOpBatchLog.h | 5 | ||||
-rw-r--r-- | src/objective-c/GRPCClient/private/GRPCOpBatchLog.m | 10 | ||||
-rw-r--r-- | src/objective-c/RxLibrary/GRXImmediateSingleWriter.m | 15 |
4 files changed, 23 insertions, 12 deletions
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 7d928f81c1..051138ea4d 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -107,8 +107,11 @@ static NSMutableDictionary *callFlags; GRPCRequestHeaders *_requestHeaders; + // In the case that the call is a unary call (i.e. the writer to GRPCCall is of type + // GRXImmediateSingleWriter), GRPCCall will delay sending ops (not send them to C core + // immediately) and buffer them into a batch _unaryOpBatch. The batch is sent to C core when + // the SendClose op is added. BOOL _unaryCall; - NSMutableArray *_unaryOpBatch; } diff --git a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h index dbc3417acf..753c4cfee6 100644 --- a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h +++ b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.h @@ -31,6 +31,9 @@ * */ + +#ifdef GRPC_TEST_OBJC + /** * Logs the op batches of a client. Used for testing. */ @@ -52,3 +55,5 @@ + (NSArray *)obtainAndCleanOpBatchLog; @end + +#endif diff --git a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m index c172c3c988..4b40baf122 100644 --- a/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m +++ b/src/objective-c/GRPCClient/private/GRPCOpBatchLog.m @@ -31,11 +31,13 @@ * */ +#ifdef GRPC_TEST_OBJC + #import "GRPCOpBatchLog.h" -@implementation GRPCOpBatchLog +static NSMutableArray *opBatchLog = nil; -NSMutableArray *opBatchLog = nil; +@implementation GRPCOpBatchLog + (void)enableOpBatchLog:(BOOL)enabled { @synchronized (opBatchLog) { @@ -65,4 +67,6 @@ NSMutableArray *opBatchLog = nil; } } -@end
\ No newline at end of file +@end + +#endif diff --git a/src/objective-c/RxLibrary/GRXImmediateSingleWriter.m b/src/objective-c/RxLibrary/GRXImmediateSingleWriter.m index a3e9cd60a3..a0da71cb76 100644 --- a/src/objective-c/RxLibrary/GRXImmediateSingleWriter.m +++ b/src/objective-c/RxLibrary/GRXImmediateSingleWriter.m @@ -35,41 +35,40 @@ @implementation GRXImmediateSingleWriter { id _value; - NSError *_errorOrNil; id<GRXWriteable> _writeable; } @synthesize state = _state; -- (instancetype)initWithValue:(id)value error:(NSError *)errorOrNil { +- (instancetype)initWithValue:(id)value { if (self = [super init]) { _value = value; - _errorOrNil = errorOrNil; _state = GRXWriterStateNotStarted; } return self; } + (GRXWriter *)writerWithValue:(id)value { - return [[self alloc] initWithValue:value error:nil]; + return [[self alloc] initWithValue:value]; } - (void)startWithWriteable:(id<GRXWriteable>)writeable { _state = GRXWriterStateStarted; _writeable = writeable; [writeable writeValue:_value]; - [self finishWithError:_errorOrNil]; + [self finish]; } -- (void)finishWithError:(NSError *)errorOrNil { +- (void)finish { _state = GRXWriterStateFinished; - _errorOrNil = nil; _value = nil; id<GRXWriteable> writeable = _writeable; _writeable = nil; - [writeable writesFinishedWithError:errorOrNil]; + [writeable writesFinishedWithError:nil]; } +// Overwrite the setter to disallow manual state transition. The getter +// of _state is synthesized. - (void)setState:(GRXWriterState)newState { // Manual state transition is not allowed return; |