WebAssembly / WebAssembly/threads
Common JS shell infrastructure
Open
@lars-t-hansen is already working on this.
Since Nov 6, 2017.
- Dominant language
- WebAssembly
- Stars
- 767
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
cc @jfbastien @saambarati @kmiller68 @binji @MikeHolman
JF brought up the issue that we'll want a shared system in the JS shells to be able to test wasm threaded code. (And JS code for that matter - everyone will love us.)
To kick us off, I propose the following strawman:
The main thread can create new workers:
var w = new Worker(text) // where text is defined below
w.postMessage(obj) // what you think
w.onmessage = function (ev) { ... } // where ev.data is something sent by postMessage
dispatch() // enter the event loop
The worker can then:
onmessage = function (ev) { ... } where ev.data is something sent by postMessage
postMessage(obj) // what you think
Note,
- There is an implicit event loop in the worker.
- There is an explicit event loop in the main thread by means of
dispatch(); when it returns the main thread continues and may exit. (Debatable how good this explicit event loop is, not sure what d8 does here. Discuss.) - The worker cannot create new workers (keeps things simple).
- The object to be posted is anything structured-cloneable
- I haven't bothered to worry about transfering objects here
The "text" for a worker is a string that starts with 'text/plain;', this is for web compat so that tests can just carry over (ideally).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.