1 | | | import 'dart:isolate'; |
2 | | |
|
3 | | | import '../../worker/worker_request.dart'; |
4 | | | import '../../worker_service.dart'; |
5 | | | import '../xplat/_worker_runner.dart'; |
6 | | | import '_worker_runner.dart'; |
7 | | |
|
8 | | 9 | void bootstrap(WorkerInitializer initializer, WorkerRequest? command) { |
9 | | 9 | final workerPort = ReceivePort(); |
10 | | |
|
11 | | 18 | final runner = WorkerRunner((r) { |
12 | | 18 | r.internalLogger.t('Terminating Isolate'); |
13 | | 9 | workerPort.close(); |
14 | | 18 | Isolate.current.kill(priority: Isolate.beforeNextEvent); |
15 | | | }); |
16 | | |
|
17 | | 18 | workerPort.listen(runner.handle); |
18 | | 18 | runner.connect(command, workerPort.sendPort, initializer); |
19 | | | } |