Addressed the comments

pull/9247/head
Muxi Yan 8 years ago
parent 9f74e838e2
commit c2e53b5af4
  1. 5
      src/objective-c/GRPCClient/GRPCCall.m
  2. 5
      src/objective-c/GRPCClient/private/GRPCOpBatchLog.h
  3. 10
      src/objective-c/GRPCClient/private/GRPCOpBatchLog.m
  4. 15
      src/objective-c/RxLibrary/GRXImmediateSingleWriter.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;
}

@ -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

@ -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
@end
#endif

@ -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;

Loading…
Cancel
Save