EasyWorker<R, I> class
Creates and spawns an isolate that shares the same code as the current isolate.
The argument entryPoint
specifies the initial function to call in the
spawned isolate. The entry-point function is invoked in the new isolate
with message
as the only argument.
- Implementers
Constructors
-
EasyWorker(Entrypoint<
I> entrypoint, {required String workerName, I? initialMessage, bool paused = false, bool errorsAreFatal = true, SendPort? onExit, SendPort? onError}) - Creates and spawns an isolate that shares the same code as the current isolate.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isolate ↔ Isolate
-
The isolate instance attached to this worker.
latefinal
- isReady → bool
-
check if this isolate is ready to accept message.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
R> -
listen for any message from this worker
no setter
Methods
-
dispose(
) → void - dispose all the resources and close the worker
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onMessage(
void onData(R)?, {Function? onError, void onDone()?, bool? cancelOnError}) → StreamSubscription - listen for any message from this worker
-
pause(
) → void - Requests the isolate to pause.
-
resume(
) → void - Requests the isolate to resume again.
-
send(
I message) → Future< void> - send message to this worker
-
toString(
) → String -
A string representation of this object.
inherited
-
waitUntilReady(
) → Future< void> - wait until this worker spawns
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
compute<
R, I> (WorkerEntrypoint< I> entrypoint, I payload, {String name = "", PayloadCallback? onInit, Object? initData}) → Future<R> -
Spin up a short lived worker, execute the
entrypoint
and get the result