diff options
author | Muxi Yan <mxyan@google.com> | 2017-06-26 17:09:09 -0700 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2017-06-26 17:09:09 -0700 |
commit | d6cee1513530ce71040db26a7202465f919b9c51 (patch) | |
tree | 91d7aa4790f3bcbd3ff1d356a155477df946216e /src | |
parent | 08fef09ed1b96f703b205fa98f5dd712ef3059e9 (diff) |
Simply queue up writesFinishedWithError without cancelling pending messages
Diffstat (limited to 'src')
-rw-r--r-- | src/objective-c/RxLibrary/GRXBufferedPipe.m | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/objective-c/RxLibrary/GRXBufferedPipe.m b/src/objective-c/RxLibrary/GRXBufferedPipe.m index 31c1448b55..ee3c3d3031 100644 --- a/src/objective-c/RxLibrary/GRXBufferedPipe.m +++ b/src/objective-c/RxLibrary/GRXBufferedPipe.m @@ -73,16 +73,10 @@ } - (void)writesFinishedWithError:(NSError *)errorOrNil { - if (errorOrNil) { - // No need to write pending values. - _errorOrNil = errorOrNil; - [self finishWithError:_errorOrNil]; - } else { - __weak GRXBufferedPipe *weakSelf = self; - dispatch_async(_writeQueue, ^{ - [weakSelf finishWithError:nil]; - }); - } + __weak GRXBufferedPipe *weakSelf = self; + dispatch_async(_writeQueue, ^{ + [weakSelf finishWithError:nil]; + }); } #pragma mark GRXWriter implementation @@ -98,7 +92,7 @@ case GRXWriterStateFinished: self.writeable = nil; if (_state == GRXWriterStatePaused) { - _writeQueue = nil; + dispatch_resume(_writeQueue); } _state = newState; return; @@ -109,7 +103,8 @@ } return; case GRXWriterStateStarted: - if (_state == GRXWriterStatePaused) { + if (_state == GRXWriterStatePaused || + _state == GRXWriterStateNotStarted) { _state = newState; dispatch_resume(_writeQueue); } @@ -121,17 +116,13 @@ } - (void)startWithWriteable:(id<GRXWriteable>)writeable { - _state = GRXWriterStateStarted; self.writeable = writeable; - dispatch_resume(_writeQueue); + self.state = GRXWriterStateStarted; } - (void)finishWithError:(NSError *)errorOrNil { - id<GRXWriteable> writeable = self.writeable; + [self.writeable writesFinishedWithError:errorOrNil]; self.state = GRXWriterStateFinished; - dispatch_async(_writeQueue, ^{ - [writeable writesFinishedWithError:errorOrNil]; - }); } @end |