WasmPool class final

A set of WasmWorkers that share the work.

final pool = await WasmPool.spawn(workers: 4);
final module = await pool.load(wasmBytes);
final instance = await module.instantiate();
final results = await instance.callAll('spin', [[n], [n], [n], [n]]);
await pool.dispose();

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
workerCount → int
The number of workers, i.e. the maximum parallelism.
no setter
workers → List<WasmWorker>
The workers themselves, for callers that need a specific one.
no setter

Methods

dispose() → Future<void>
Releases every worker.
load(Uint8List bytes) → Future<PooledModule>
Compiles bytes on every worker.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

spawn({int? workers, void configure(WasmConfig config)?}) → Future<WasmPool>
Starts workers workers, each with its own engine, store and thread.