[whatwg] Web Workers API
Oliver Hunt
oliver at apple.com
Thu Jul 1 23:21:20 PDT 2010
All meesaging through postMessage uses the internal structured cloning algorithm detailed at http://www.w3.org/TR/2010/WD-html5-20100304/Overview.html#internal-structured-cloning-algorithm
It's basically a deep copy, but has a few restrictions on the types cloned, and doesn't copy functions or the prototype property, etc.
--Oliver
On Jul 1, 2010, at 9:06 PM, Evan Ireland wrote:
> Hi,
>
> The IDL for Worker in the Web Workers API specification shows:
>
> void postMessage(in any message, in optional MessagePortArray ports);
>
> I have a question regarding the 'any' type for message.
>
> If a caller of postMessage passes an object to a worker that is not a
> string, is it converted to a string or can non-string objects be propagated
> through to the onmessage(event) in the worker.
>
> So if I write:
>
> var w = new MyWorker('MyWorker.js');
> w.postMessage(new MyObject());
>
> --------------
> // MyWorker.js
>
> onmessage = function(event)
> {
> var d = event.data;
> // what type is 'd'?
> }
>
> If 'd' is not a string, then is it a MyObject, and if so, how is it supposed
> to be marshalled by the inter-worker(thread) communication?
>
> I suggest that whatever the answer, that this be covered when the spec
> document is next updated.
>
> Thanks.
>
>
More information about the whatwg
mailing list