F
Flint DartDocs
GitHub

Isolate

Use isolates to run heavy work off the main request thread. Flint provides IsolateTask for single jobs and IsolateTaskQueue for batching.

Single Task

CodeBlock dart
class ReportJob extends IsolateTask {
  @override
  Future performTask() async {
    // heavy work here
    return 'done';
  }
}

await ReportJob().perform(
  onDone: (result) => Log.debug('Result: $result'),
  onError: (err) => Log.debug('Error: $err'),
);

Queue Multiple Tasks

CodeBlock dart
final tasks = [
  ReportJob(),
  ReportJob(),
];

await IsolateTaskQueue.scheduleTasks(
  tasks,
  onDone: (task, result) => Log.debug('Done: $result'),
  onError: (task, err) => Log.debug('Error: $err'),
);

CLI Scaffold

Generate a new isolate task with the CLI:

CodeBlock bash
flint --make-isolate ReportJob
F
Flint DartBackend framework and Dart UI docs

Build routes, controllers, APIs, docs, and browser UI from one Dart-shaped stack.

Controllers
OpenAPI
Flint UI
Copyright 2024 Flint Dart. Maintained by Eulogia Technologies.
v 1.1.14
MIT License
Built with Dart