IsolateStreamGenerator<T> class
abstract
An object that runs in another isolate to generate the values given by an IsolateStream. Clients of IsolateStream subclass this. An instance is provided to the IsolateStream constructor, and is sent to a new isolate using SendPort.send. The new isolate is created with Isolate.spawn. See the restrictions in SendPort.send about sending object instances.
Note that this object is a Sink
See also IsolateByteStreamGenerator.
- Implemented types
-
- Sink<
T>
- Sink<
- Implementers
Constructors
- IsolateStreamGenerator.new()
- Initialize a new generator.
Properties
- bufferSize → int
-
Give the desired size of the buffer between the producing isolate and
the consuming isolate. A flow control protocol will
attempt to keep the buffer between half full and completely full,
if production is faster than consumption. A buffer size of zero
will cause rendezvous semantics, where the producer pauses until the
consumer has taken the value. The units should be the same
as sizeOf.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
T value) → void -
Synchronously send the given value to the consumer, without regard
to respecting the maximum buffer size. If this is
called, the caller must ensure that flushIfNeeded is called
frequently enough to prevent excessive buffer growth.
override
-
close(
) → void -
Closes the sink.
override
-
flushIfNeeded(
) → Future< void> -
If necessary, pause the sending isolate (the producer) until our
consumer has processed sufficient data.
await x.flushIfNeeded()
should be called regularly, in order to ensure the Send/Receive port buffer between the isolates doesn't get too big. -
generate(
) → Future< void> - Generate the values for the IsolateStream. An implementation of this method can send values using the appropriate methods of this class. When this method returns, the generating isolate is killed, and the IsolateStream is set as having received its last element.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sendValue(
T value) → Future< void> - Send the given value to the consumer, pausing if the buffer is full. This may only be called in the producer isolate.
-
sizeOf(
T value) → int - Give an estimate of the size of the given value. This size should be in the same units bufferSize.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited