An open API service indexing awesome lists of open source software.

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

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);
}
```