@@ -29,13 +29,11 @@ communicate with their protocol buffer equivalents.
2929
3030## Worker Communication and Management
3131
32- The way Dart VM launches lightweight isolates versus Node.js launches worker
33- threads are very different.
34-
35- In Dart VM, the lightweight isolates share program structures like loaded
36- libraries, classes, functions, etc., even including JIT optimized code. This
37- allows main isolate to spawn child isolate with a reference to the entry point
38- function.
32+ The way the Dart VM launches lightweight isolates is very different from how
33+ Node.js launches worker threads. In the Dart VM, the lightweight isolates share
34+ program structures like loaded libraries, classes, functions, and so on, even
35+ including JIT optimized code. This allows main isolate to spawn child isolate
36+ with a reference to the entry point function.
3937
4038```
4139┌─────────────────┐ ┌─────────────────┐
@@ -55,21 +53,21 @@ function.
5553
5654In Node.JS, the worker threads do not share program structures. In order to
5755launch a worker thread, it needs an entry point file, with the entry point
58- function effectly hard-coded in the entry point file. While it's possible
59- to have a separate entry point file for the worker threads, it requires more
60- complex packaging changes with ` cli_pkg ` , therefore the main thread and the
61- worker threads share [ the same entry point file] ( js/executable.dart ) , which
62- decides what to run based on ` worker_threads.isMainThread ` .
56+ function effectly hard-coded in that file. While it's possible to have a
57+ separate entry point file for the worker threads, it would require complex
58+ packaging changes within ` cli_pkg ` , so instead the main thread and the worker
59+ threads share [ the same entry point file] ( js/executable.dart ) , which decides
60+ what to run based on ` worker_threads.isMainThread ` .
6361
6462```
6563 if (worker_threads.isMainThread) { if (worker_threads.isMainThread) {
6664 mainEntryPoint(); mainEntryPoint();
6765 } else { } else {
68- workerEntryPoint(); new Worker(process.argv[1], { workerEntryPoint();
69- } argv: process.argv.slice(2), }
70- workerData: channel.port2,
71- ┌────────────────────────────────────┐ transferList: [channel.port2] ┌────────────────────────────────────┐
72- │ Main Thread │ }) │ Worker Thread │
66+ workerEntryPoint(); new Worker(process.argv[1], { workerEntryPoint();
67+ } argv: process.argv.slice(2), }
68+ workerData: channel.port2,
69+ ┌────────────────────────────────────┐ transferList: [channel.port2] ┌────────────────────────────────────┐
70+ │ Main Thread │ }) │ Worker Thread │
7371│ ├────────────────────────────────────────────────────────────►│ │
7472│ │ │ │
7573│ ┌────────────────────────────────┐ │ Synchronous Messaging │ ┌────────────────────────────────┐ │
0 commit comments