isolate_pool_2
1.0.8, released 2 years ago by saplin.blogspot.com
A pool of long‑living Dart isolates for running jobs or hosting objects off the main isolate.
What it does
The package creates and keeps active isolates ready to receive requests. It lets you schedule one‑off jobs like compute() but reuses isolates, and also host persistent objects accessed via proxies. Results are returned to the main isolate asynchronously.
AI-written summary of version 1.0.8, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to run heavy CPU‑bound tasks frequently without the overhead of spawning a new isolate each time
- You want to keep stateful objects alive in isolates and communicate with them via RPC‑style calls
Skip it when
- A single occasional compute() call is enough
- You target web where isolates are not supported
- You need UI‑related functionality or platform channels
Strengths
- Reuses isolates for better performance on repeated tasks
- Supports persistent isolate instances with proxy communication
- Pure Dart, no native setup required
Weaknesses
- Works only on platforms that support Dart isolates (no web)
- Debugging cross‑isolate communication can be tricky
- No built‑in serialization helpers, you must ensure data is isolate‑safe
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
class MyJob extends PooledJob<int>{
final int value;
MyJob(this.value);
@override
int job() => value * 2;
}
void main() async {
final pool = await IsolatePool.create();
final result = await pool.scheduleJob(MyJob(5));
print(result); // 10
await pool.stop();
}Alternatives
Packages that do the same job and could replace isolate_pool_2.
- squadron
Multithreading and worker thread pools for Dart and Flutter using Isolates and Web Workers.
87Compare - isolate_channel
Communication channels for isolates based on Flutter's platform channels.
82Compare - isolate_pool_executor
Manages a pool of Dart isolates to run CPU‑intensive tasks without blocking the main isolate.
58Compare - computer
Easy to use pool of concurrent workers with a compute-like API.
48Compare