worker_pool library

A robust and easy-to-use isolate pool for Dart and Flutter.

This library provides the main WorkerPool class for managing a pool of isolates, along with helper classes for task management, resource handling, and communication.

Classes

FunctionRegistry
Function registry for storing functions in isolates
IsolateConstantManager
Manager for accessing constants in isolates Constants are initialized once in the main thread and passed to isolates
IsolateMessage
Message structure for isolate communication
IsolateResourceManager
Manager for isolate resources with proper cleanup
IsolateStartupData
Data structure for isolate startup
IsolateTask<T, R>
Represents a task to be executed in an isolate
IsolateWorker
Individual isolate worker
WorkerPool
A pool of isolates for executing tasks concurrently
WorkerPoolConfig
Configuration for the isolate pool

Enums

MessageType
Message types for isolate communication

Typedefs

ConstantProvider = Future<Map<String, dynamic>> Function()
A function type for providing constants to isolates This function is executed once in the main thread to initialize constants that will be passed to each isolate
IsolateFunction<T, R> = FutureOr<R> Function(T argument)
A function type that can be executed in an isolate
ResourceFinalizer = Future<void> Function(dynamic resource)
A function type for resource cleanup Takes the resource object and properly disposes it
ResourceInitializer = Future<Map<String, dynamic>?> Function()
A function type for resource initialization Returns a Map where keys are resource names and values are resource objects