Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: lib/src/two_way_stream.dart

Issue 1328503003: Add Server.isClosed and Client.isClosed. (Closed) Base URL: git@github.com:dart-lang/json_rpc_2.git@master
Patch Set: Code review changes Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/server.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/two_way_stream.dart
diff --git a/lib/src/two_way_stream.dart b/lib/src/two_way_stream.dart
index 5914173876f6d21799bfdcc1c34cd45471c71852..f2d5b5eb6929ab8c46ea405bd94a45984fc38e51 100644
--- a/lib/src/two_way_stream.dart
+++ b/lib/src/two_way_stream.dart
@@ -38,6 +38,9 @@ class TwoWayStream {
Future get done => _doneCompleter.future;
final _doneCompleter = new Completer();
+ /// Whether the stream has been closed.
+ bool get isClosed => _doneCompleter.isCompleted;
+
/// Creates a two-way stream.
///
/// [input] and [output] should emit and take (respectively) JSON-encoded
@@ -103,12 +106,12 @@ class TwoWayStream {
_inputSubscription = _input.listen(handleInput,
onError: (error, stackTrace) {
if (_doneCompleter.isCompleted) return;
- _output.close();
_doneCompleter.completeError(error, stackTrace);
+ _output.close();
}, onDone: () {
if (_doneCompleter.isCompleted) return;
- _output.close();
_doneCompleter.complete();
+ _output.close();
}, cancelOnError: true);
return _doneCompleter.future;
@@ -123,6 +126,7 @@ class TwoWayStream {
throw new StateError("Can't call $_name.close before $_name.listen.");
}
+ _isClosed = true;
if (!_doneCompleter.isCompleted) _doneCompleter.complete();
var inputFuture = _inputSubscription.cancel();
« no previous file with comments | « lib/src/server.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698