Chromium Code Reviews| Index: sdk/lib/async/stream.dart |
| diff --git a/sdk/lib/async/stream.dart b/sdk/lib/async/stream.dart |
| index 510cccb93d0b9f1044d696bd35b464479e91821d..f21c608b73b3cf31593e2c78435016aa586b6b58 100644 |
| --- a/sdk/lib/async/stream.dart |
| +++ b/sdk/lib/async/stream.dart |
| @@ -1378,20 +1378,23 @@ abstract class Stream<T> { |
| */ |
| abstract class StreamSubscription<T> { |
| /** |
| - * Cancels this subscription. It will no longer receive events. |
| + * Cancels this subscription. |
| * |
| - * May return a future which completes when the stream is done cleaning up. |
| - * This can be used if the stream needs to release some resources |
| - * that are needed for a following operation, |
| - * for example a file being read, that should be deleted afterwards. |
| - * In that case, the file may not be able to be deleted successfully |
| - * until the returned future has completed. |
| + * After this call it does no longer receive events. However, the cleanup of |
|
Lasse Reichstein Nielsen
2016/02/09 16:34:53
"After this call returns, the subscription no long
floitsch
2016/02/09 17:26:51
Done.
|
| + * the stream might not be finished yet. |
| * |
| - * The future will be completed with a `null` value. |
| - * If the cleanup throws, which it really shouldn't, the returned future |
| - * will be completed with that error. |
| + * Returns `null` if the cleanup is finished, or a future otherwise. |
| + * In the latter case, the future is completed once the stream has finished |
| + * its cleanup. |
|
Lasse Reichstein Nielsen
2016/02/09 16:34:53
I would focus on returning a future - we have many
floitsch
2016/02/09 17:26:51
Done.
|
| + * |
| + * Typically, futures are returned when the stream needs to release resources. |
| + * For example, a stream might need to close an open file (as an asynchronous |
| + * operation). If the listener wants to delete the file after having |
| + * canceled the subscription, it must wait for the cleanup future to complete. |
| * |
| - * Returns `null` if there is no need to wait. |
| + * A returned future completes with a `null` value. |
| + * If the cleanup throws, which it really shouldn't, the returned future |
| + * completes with that error. |
| */ |
| Future cancel(); |