1 | | | import 'dart:isolate'; |
2 | | |
|
3 | | | import '../_worker_monitor.dart'; |
4 | | | import '../_worker_runner.dart'; |
5 | | | import '../squadron.dart'; |
6 | | | import '../worker_service.dart'; |
7 | | |
|
8 | | 1 | void bootstrap(WorkerInitializer initializer, Map? command) async { |
9 | | 1 | final workerPort = ReceivePort(); |
10 | | 2 | final monitor = WorkerMonitor(() { |
11 | | 1 | Squadron.config('terminating Isolate'); |
12 | | 1 | workerPort.close(); |
13 | | 2 | Isolate.current.kill(); |
14 | | | }); |
15 | | |
|
16 | | 1 | final runner = WorkerRunner(monitor); |
17 | | |
|
18 | | 3 | workerPort.listen((message) => runner.processMessage(message)); |
19 | | |
|
20 | | 2 | await runner.connect(command, workerPort, initializer); |
21 | | | } |