| commit | 1a3ee492c9d4071ddd90cabe11ab730b631d5358 | [log] [tgz] |
|---|---|---|
| author | Lasse R.H. Nielsen <lrn@google.com> | Thu Mar 10 13:03:06 2022 +0100 |
| committer | GitHub <noreply@github.com> | Thu Mar 10 13:03:06 2022 +0100 |
| tree | dca347684fda00e043037aed1bc155123fce6a83 | |
| parent | d733a5a93f58f865bbfb8f2d3301a2d4c1e1035c [diff] |
Avoid leaking unreachable listeners on `CancelableOperation`. (#206) * Make `CancelableOperation` not hold onto unnecessary callbacks. The existing `CancelableOperation` contains two completers, where at most one will ever complete. Listeners added to the other completer's future will never be released as long as the operation is alive, even after the operation has otherwise completed. This change drops reference to the other completer when one completer is chosen for completion. That can allow the completer, its future, and that future's listeners to be GC'ed when it's known that they'll never be relevant again. The change has one visible effect: If asking for the `value` future after the operation has been cancelled and the value completer has been released, you'll get a new future, which also never completes, which is not identical to other futures returned by the same getter. THis only matters if someone checks the future for identity, their behavior is exactly the same (no behavior, whatsoever). Since the same class returns a completely new future on each call read of `valueOrCancellation`, I think that's a reasonable change, and unlikely to affect anyone. (Users are not usually expecting asynchronous functions to return the same future every time since `async` functions don't.) Fixes #200.
Contains utility classes in the style of dart:async to work with asynchronous computations.
The AsyncCache class allows expensive asynchronous computations values to be cached for a period of time.
The AsyncMemoizer class makes it easy to only run an asynchronous operation once on demand.
The CancelableOperation class defines an operation that can be canceled by its consumer. The producer can then listen for this cancellation and stop producing the future when it's received. It can be created using a CancelableCompleter.
The delegating wrapper classes allow users to easily add functionality on top of existing instances of core types from dart:async. These include DelegatingFuture, DelegatingStream, DelegatingStreamSubscription, DelegatingStreamConsumer, DelegatingSink, DelegatingEventSink, and DelegatingStreamSink.
The FutureGroup class makes it easy to wait until a group of futures that may change over time completes.
The LazyStream class allows a stream to be initialized lazily when .listen() is first called.
The NullStreamSink class is an implementation of StreamSink that discards all events.
The RestartableTimer class extends Timer with a reset() method.
The Result class that can hold either a value or an error. It provides various utilities for converting to and from Futures and Streams.
The StreamGroup class merges a collection of streams into a single output stream.
The StreamQueue class allows a stream to be consumed event-by-event rather than being pushed whichever events as soon as they arrive.
The StreamSplitter class allows a stream to be duplicated into multiple identical streams.
The StreamZip class combines multiple streams into a single stream of lists of events.
This package contains a number of StreamTransformers. SingleSubscriptionTransformer converts a broadcast stream to a single-subscription stream, and typedStreamTransformer casts the type of a Stream. It also defines a transformer type for StreamSinks, StreamSinkTransformer.
The SubscriptionStream class wraps a StreamSubscription so it can be re-used as a Stream.