https://github.com/d-markey/squadron_builder
Dart code generator for Squadron workers. Implement your worker service and let squadron_builder bridge the gap with Web Workers and Isolates!
https://github.com/d-markey/squadron_builder
code-generation dart isolate parallelism-library thread webworker
Last synced: 8 months ago
JSON representation
Dart code generator for Squadron workers. Implement your worker service and let squadron_builder bridge the gap with Web Workers and Isolates!
- Host: GitHub
- URL: https://github.com/d-markey/squadron_builder
- Owner: d-markey
- License: mit
- Created: 2022-08-02T10:01:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-12T10:10:17.000Z (11 months ago)
- Last Synced: 2025-04-12T11:24:38.216Z (11 months ago)
- Topics: code-generation, dart, isolate, parallelism-library, thread, webworker
- Language: Dart
- Homepage: https://pub.dev/packages/squadron_builder
- Size: 735 KB
- Stars: 20
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README

## **Squadron - Multithreading and worker pools in Dart**
Offload CPU-bound and long running tasks and give your mobile and Web apps some air!
# squadron_builder
Dart code generator for Squadron workers. Implement your worker service and let `squadron_builder` bridge the gap with Web Workers and Isolates!
[](https://pub.dev/packages/squadron_builder)
[](https://pub.dev/packages/squadron_builder)
[](https://pub.dev/packages/squadron_builder)
[](https://github.com/d-markey/squadron_builder/blob/master/LICENSE)
[](https://dart.dev/null-safety)
[](https://pub.dev/packages/lints)
[](https://pub.dev/packages/squadron_builder/score)
[](https://pub.dev/packages/squadron_builder/score)
[](https://pub.dev/packages/squadron_builder/score)
[](https://github.com/d-markey/squadron_builder/commits)
# Usage
`squadron_builder` is a companion package to `Squadron` and is intended to be installed as a development dependency to your project.
Its purpose is to generate the code for Workers and WorkerPools based on the service classes you want to run in dedicated threads.
Example of a service class:
```dart
// file hello_world.dart
// mandatory, will be generated with platform-specific code for your worker's entry points
import 'hello_world.activator.g.dart';
// mandatory, will be generated with code for your worker & worker pool
part 'hello_world.worker.g.dart';
// this annotation tells squadron_builder that this class contains code to be executed on dedicated threads
@SquadronService(baseUrl: '~/workers', targetPlatform: TargetPlatform.vm | TargetPlatform.web)
base class HelloWorld {
// this annotation tells squadron_builder that this method is exposed to clients running in the main thread for instance
@squadronMethod
FutureOr hello([String? name]) {
name = name?.trim() ?? 'World';
return 'Hello, $name!';
}
}
```