W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2008

[whatwg] Terminate a Worker algorithm

From: Alexey Proskuryakov <ap@webkit.org>
Date: Tue, 16 Dec 2008 09:55:57 +0300
Message-ID: <82FD17FC-463A-45E3-B9D1-C10B04A33B7A@webkit.org>

Dec 16, 2008, ? 9:43 AM, Ian Hickson ???????(?):

>> 1) The algorithm assumes that a WorkerGlobalScope exists, and doesn't
>> specify what happens if it is invoked before WorkerGlobalScope is
>> created (e.g. if the script is still being loaded, or the scope is  
>> being
>> created, but Worker.terminate() is called from JS). I think that the
>> right behavior is to re-invoke the algorithm after the scope is  
>> created,
>> because it may be too late to prevent its creation.
>
> It can't be invoked before the WorkerGlobalScope is created. The
> WorkerGlobalScope is created before the constructor returns the Worker
> object.

This means that creating a Worker would involve running a nested run  
loop, waiting for WorkerGlobalScope to be created in another thread/ 
process. I think that WorkerGlobalScope needs to be created  
asynchronously. The above is the only observable difference with  
synchronous creation that I could find, so I think that requiring  
synchronous operation is unnecessary.

>> 2) Events in WorkerGlobalScope event queue are dropped when  
>> terminating a
>> worker, but messages posted to Worker are not. I think that the  
>> expected
>> behavior is that after calling Worker.terminate(), no messages will  
>> be
>> dispatched to worker's event listeners.
>
> Once 'closing' is set to true, the queue discards any additional  
> tasks.


There is no "closing" flag on the Worker object, it's only defined on  
WorkerGlobalScope as far as I can see.

- WBR, Alexey Proskuryakov
Received on Monday, 15 December 2008 22:55:57 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:46 UTC