https://github.com/ryanprw/dart-snapshot
example of using the snapshot with spawn isolate
https://github.com/ryanprw/dart-snapshot
dart snaps
Last synced: 2 months ago
JSON representation
example of using the snapshot with spawn isolate
- Host: GitHub
- URL: https://github.com/ryanprw/dart-snapshot
- Owner: Ryanprw
- Created: 2025-03-07T16:42:29.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-07T17:33:05.000Z (over 1 year ago)
- Last Synced: 2025-03-07T17:35:05.529Z (over 1 year ago)
- Topics: dart, snaps
- Language: Dart
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# An example of using the snapshot with spawn isolate
## Primary
``dart compile exe bin/primary.dart -o primary.exe``
``./primary.exe``
bin/primary.dart
```dart
import 'dart:io' as io;
import 'dart:isolate';
import 'package:path/path.dart' as path;
void main(List arguments) => Future(() async {
print('primary start');
final uri =
Uri.parse(path.join(io.Directory.current.path, 'secondary.aot'));
final isolate = await Isolate.spawnUri(
uri,
arguments,
null,
debugName: 'secondary',
);
await Future.delayed(const Duration(seconds: 3));
isolate.kill();
print('primary end');
});
```
## Secondary
``dart compile aot-snapshot bin/secondary.dart -o secondary.aot``
bin/secondary.dart
```dart
import 'dart:developer' as dev;
void main(List? arguments, Object? message) {
final message = 'Hello, I am secondary';
print(message);
dev.log(message);
}
```