executorservices 1.0.2 executorservices: ^1.0.2 copied to clipboard
A Dart package providing services that allow you to execute dart code in different executors, ex - isolates.
A library for Dart and Flutter developers.
Description #
It allows you to execute code in isolates or any executor currently supported.
Support concurrent execution of tasks or functions.
Support cleanup of unused isolates.
Support caching of isolate that allow you to reuse them (like thread).
It's extendable.
Usage #
A simple usage example:
import "package:executorservices/executorservices.dart";
import "dart:math";
main() {
final cachedExecutorService = ExecutorService.newUnboundExecutor();
cachedExecutorService.submitAction(randomInt);
cachedExecutorService.submit(SomeIntensiveTask());
}
int randomInt() {
return Random.secure().nextInt(1000);
}
class SomeIntensiveTask extends Task<String> {
@override
Future<String> execute() async {
await Future.delayed(Duration(minutes: 5));
return "Done executing intensive task";
}
}
Features and bugs #
Please file feature requests and bugs at the issue tracker.