[whatwg] Worker lifecycle

Hi all,
A couple of quick questions about the lifecycle of workers - specifically
I'm trying to grok the body of text at section 4.5 of the Web Workers spec.
It seems like it's saying that if I create a shared worker, then hand off
its port to another window, that shared worker will be orphaned once the
original window is closed.

It seems like instead of just using the normal message port reachability
algorithm (once a worker's message ports are no longer reachable, it is
considered orphaned) we instead have to track the original allocator of all
ports, and only count a worker as reachable if the window that allocated the
original port is still active.

"[a worker is permissible if] at some point past or present a
MessagePortowned by the worker was entangled with a
MessagePort *p* whose owner is a Window object whose active document is the
Document that was that browsing context's active document when *p* was
created, and that Document is fully active"

Am I reading this correctly? It just seems wonky that if I create a shared
worker from window A, hand the port off to window B, then close window A,
that worker is now orphaned despite being reachable from window B. But if I
do the same thing, but before window A closes, window B creates a new port
and sends it to the worker via the port that window A gave it, the worker
won't be orphaned when window A closes.

What's the intent here?

Also, one other thing: I was previously under the impression that
SharedWorkers had a different lifecycle from dedicated Workers -
SharedWorkers would not exit as long as there were any windows open to that
domain. In retrospect, I'm pretty sure I just made that up - SharedWorkers
and dedicated Workers have identical lifecycles, correct?

-atw
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090410/06588e9b/attachment.htm>

Received on Friday, 10 April 2009 18:32:26 UTC