initialize abstract method
- int? isolatesCount,
- int tasksPerIsolate = defaultTasksPerIsolate,
- WorkerInitializer? initializer,
- String isolatesPrefix = defaultIsolatePrefix,
Initializes worker.
Worker manager can be lazily initialized on the first execution,
so you can omit calling initialize
.
To initialize worker with a custom amount of isolates, use the
isolatesCount
parameter.
Default value is calculated by the following formula:
max(1, (numberOfProcessors / 2).floor())
Please keep in mind that Flutter already uses 3 threads:
Dart main, native main and GPU. So your isolatesCount
should be less
than numberOfProcessors - 3
.
Each isolate can execute one or more tasks asynchronously
(thanks to async IO and event loop).
tasksPerIsolate
parameter is used to set maximum number of tasks that
one isolate can perform asynchronously.
initializer
is a function that will be executed in the each worker
isolate. It can be used to initialize something in the worker isolate.
isolatesPrefix
will be used to set isolates debug name. Debug name will
be visible in the debugger.
Implementation
Future<void> initialize({
int? isolatesCount,
int tasksPerIsolate = defaultTasksPerIsolate,
WorkerInitializer? initializer,
String isolatesPrefix = defaultIsolatePrefix,
});