Add state transitions to GRPCCall

pull/6386/head
Jorge Canizales 9 years ago
parent 47b80bc558
commit 0803bb0b33
  1. 10
      src/objective-c/GRPCClient/GRPCCall.m

@ -136,6 +136,10 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
#pragma mark Finish
- (void)finishWithError:(NSError *)errorOrNil {
@synchronized(self) {
_state = GRXWriterStateFinished;
}
// If the call isn't retained anywhere else, it can be deallocated now.
_retainSelf = nil;
@ -342,6 +346,10 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
#pragma mark GRXWriter implementation
- (void)startWithWriteable:(id<GRXWriteable>)writeable {
@synchronized(self) {
_state = GRXWriterStateStarted;
}
// Create a retain cycle so that this instance lives until the RPC finishes (or is cancelled).
// This makes RPCs in which the call isn't externally retained possible (as long as it is started
// before being autoreleased).
@ -375,6 +383,7 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
}
- (void)setState:(GRXWriterState)newState {
@synchronized(self) {
// Manual transitions are only allowed from the started or paused states.
if (_state == GRXWriterStateNotStarted || _state == GRXWriterStateFinished) {
return;
@ -401,5 +410,6 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
return;
}
}
}
@end

Loading…
Cancel
Save