diff options
author | Craig Tiller <ctiller@google.com> | 2015-07-17 22:59:53 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-07-17 22:59:53 -0700 |
commit | b5980be9a08678212e5dbd6549b923f545d83539 (patch) | |
tree | e0318622c5a5576377537783608b60516b46c4cf /src/objective-c/RxLibrary/GRXWriter.m | |
parent | a14215a67841ea7920260c655c01e4570595a3db (diff) | |
parent | f87a0984ab727e95b068237f3bb0689d9685c8ea (diff) |
Merge github.com:grpc/grpc into sometimes-its-good-just-to-check-in-with-each-other
Diffstat (limited to 'src/objective-c/RxLibrary/GRXWriter.m')
-rw-r--r-- | src/objective-c/RxLibrary/GRXWriter.m | 76 |
1 files changed, 1 insertions, 75 deletions
diff --git a/src/objective-c/RxLibrary/GRXWriter.m b/src/objective-c/RxLibrary/GRXWriter.m index cc14383560..019fcbd785 100644 --- a/src/objective-c/RxLibrary/GRXWriter.m +++ b/src/objective-c/RxLibrary/GRXWriter.m @@ -33,80 +33,6 @@ #import "GRXWriter.h" -@interface GRXWriter () <GRXWriteable> -@end - -@implementation GRXWriter { - id<GRXWriter> _writer; - id<GRXWriteable> _writeable; -} - -- (instancetype)init { - return [self initWithWriter:nil]; -} - -// Designated initializer -- (instancetype)initWithWriter:(id<GRXWriter>)writer { - if (!writer) { - [NSException raise:NSInvalidArgumentException format:@"writer can't be nil."]; - } - if ((self = [super init])) { - _writer = writer; - } - return self; -} - -// This is used to send a completion or an error to the writeable. It nillifies -// our reference to it in order to guarantee no more messages are sent to it, -// and to release it. -- (void)finishOutputWithError:(NSError *)errorOrNil { - id<GRXWriteable> writeable = _writeable; - _writeable = nil; - [writeable writesFinishedWithError:errorOrNil]; -} - -// This is used to stop the input writer. It nillifies our reference to it -// to release it. -- (void)finishInput { - id<GRXWriter> writer = _writer; - _writer = nil; - writer.state = GRXWriterStateFinished; -} - -#pragma mark GRXWriteable implementation - -- (void)writeValue:(id)value { - [_writeable writeValue:value]; -} - -- (void)writesFinishedWithError:(NSError *)errorOrNil { - _writer = nil; - [self finishOutputWithError:errorOrNil]; -} - -#pragma mark GRXWriter implementation - -- (GRXWriterState)state { - return _writer ? _writer.state : GRXWriterStateFinished; -} - -- (void)setState:(GRXWriterState)state { - if (state == GRXWriterStateFinished) { - _writeable = nil; - [self finishInput]; - } else { - _writer.state = state; - } -} - -- (void)startWithWriteable:(id<GRXWriteable>)writeable { - _writeable = writeable; - [_writer startWithWriteable:self]; -} - -- (void)finishWithError:(NSError *)errorOrNil { - [self finishOutputWithError:errorOrNil]; - [self finishInput]; -} +@implementation GRXWriter @end |