Extend PromiseWorker to allow bi-directional communication
Categories
(Toolkit :: Async Tooling, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox125 | --- | fixed |
People
(Reporter: tarek, Assigned: tarek)
References
Details
Attachments
(1 file)
PromiseWorker is a wrapper around ChromeWorker with extended capabilities designed to simplify main thread-to-worker thread asynchronous function calls.
The problem is that any post from the worker that is not an answer from an initial message from the parent, will break it, as it's based on a queue mechansim see https://searchfox.org/mozilla-central/source/toolkit/components/promiseworker/PromiseWorker.sys.mjs#150
I have a use case where the worker needs to send specific messages back to the parent during the thread-to-worker flow.
e.g.
- parent posts a message to run a function into the worker
- worker runs some code and needs something from the parent process (in my case fetching a file from cache)
- worker eventually sends back the result to the parent
What I propose is to replace the queue with a Map, so when the parent receives a message that is not an answer from https://searchfox.org/mozilla-central/source/toolkit/components/promiseworker/PromiseWorker.sys.mjs#281 -- it still propagates it -- making the PromiseWorker fully bi-directional
Assignee | ||
Updated•1 year ago
|
Assignee | ||
Comment 1•1 year ago
|
||
Updated•1 year ago
|
Comment 3•1 year ago
|
||
bugherder |
Description
•