Commit 0d7f5d9
committed
fix(samples): backend-nodejs-wasm-multithread — migrate to new target API
Same surgical migration as matrix-mt + the await pattern. This sample
was untouched by Group 3 because it's a CLI sample, not browser; only
surfaced when running it on the command line.
- cppjs.config.mjs: build.usePthread → target.runtime: 'mt'
- package.json script: -p WebAssembly →
-p wasm -a wasm32 -r mt -e node -b release
(mirrors the st sibling's flags but with -r mt)
- src/index.mjs:
- Update the dist import path to the target-system naming
(cppjs-sample-backend-nodejs-wasm-multithread-wasm-wasm32-mt-release.node.js).
- await Native.sample()/runOnThread()/getThreadResult() — comlink
proxies the worker calls.
- Move getThreadResult() into setTimeout's async callback so the
thread has time to finish.
Verified: `node src/index.mjs` prints both the standard result and
the thread-computed result.1 parent 88312f8 commit 0d7f5d9
3 files changed
Lines changed: 9 additions & 9 deletions
File tree
- cppjs-samples/cppjs-sample-backend-nodejs-wasm-multithread
- src
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
0 commit comments