Are Web Workers themselves allowed to have Web Worker threads?
-
19-09-2019 - |
Question
This would seem to be the case in Firefox 3.5+, there I can instantiate a Web Worker, and inside the worker, spawn another thread. However, the code will not work in Google Chrome, leading me to believe this is either a Mozilla proprietary extension to the spec or that Chrome has not fully implemented the spec. So which is it?
Solution
http://www.whatwg.org/specs/web-workers/current-work/#interface-objects-and-constructors seems to say it MAY be possible (as of 21.10.2009):
"There must be no interface objects and constructors available in the global scope of scripts whose script's global object is a WorkerGlobalScope object except for the following: [...] The Worker and SharedWorker interface objects and constructors."
Here
- "in the global scope of scripts whose script's global object is a WorkerGlobalScope object" means "among the worker's globals"
- "must be no ... except" is open to the interpretation.
You might want to search open issues/post feedback. The spec has this text:
To send feedback: whatwg@whatwg.org
To view and vote on feedback: http://www.whatwg.org/issues/
OTHER TIPS
Yes, webworkers can spawn subworkers. major latest browsers are supporting webworker interface.
Here are some tutorials to get it.
https://developer.mozilla.org/en-US/docs/DOM/Using_web_workers
https://developer.mozilla.org/en-US/docs/DOM/Worker/Functions_available_to_workers