-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move worker's close() to dedicated worker and shared worker #1119
Changes from 5 commits
535e285
fd020a2
e798194
c80d871
048da21
933c8b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96297,8 +96297,6 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> { | |
readonly attribute <span>WorkerNavigator</span> <span data-x="dom-worker-navigator">navigator</span>; | ||
void <span data-x="dom-WorkerGlobalScope-importScripts">importScripts</span>(DOMString... urls); | ||
|
||
void <span data-x="dom-WorkerGlobalScope-close">close</span>(); | ||
|
||
attribute <span>OnErrorEventHandler</span> <span data-x="handler-WorkerGlobalScope-onerror">onerror</span>; | ||
attribute <span>EventHandler</span> <span data-x="handler-WorkerGlobalScope-onlanguagechange">onlanguagechange</span>; | ||
attribute <span>EventHandler</span> <span data-x="handler-WorkerGlobalScope-onoffline">onoffline</span>; | ||
|
@@ -96340,9 +96338,6 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> { | |
<dt><var>workerGlobal</var> . <code subdfn data-x="dom-WorkerGlobalScope-importScripts">importScripts</code>(<var>urls</var>...)</dt> | ||
<dd>Fetches each <span>URL</span> in <var>urls</var>, executes them one-by-one in the order they | ||
are passed, and then returns (or throws if something went amiss).</dd> | ||
|
||
<dt><var>workerGlobal</var> . <code subdfn data-x="dom-WorkerGlobalScope-close">close</code>()</dt> | ||
<dd>Aborts <var>workerGlobal</var>.</dd> | ||
</dl> | ||
|
||
<div w-nodev> | ||
|
@@ -96359,24 +96354,6 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> { | |
<code>WorkerGlobalScope</code> object, this is not problematic as it cannot be observed from | ||
script.</p> | ||
|
||
<hr> | ||
|
||
<p>When a script invokes the <dfn><code data-x="dom-WorkerGlobalScope-close">close()</code></dfn> | ||
method on a <code>WorkerGlobalScope</code> object, the user agent must run the following steps | ||
(atomically):</p> | ||
|
||
<ol> | ||
|
||
<li><p>Discard any <span data-x="concept-task">tasks</span> that have been added to the | ||
<code>WorkerGlobalScope</code> object's <span>event loop</span>'s <span data-x="task queue">task | ||
queues</span>.</p> | ||
|
||
<li><p>Set the worker's <code>WorkerGlobalScope</code> object's <span | ||
data-x="dom-WorkerGlobalScope-closing">closing</span> flag to true. (This prevents any further | ||
tasks from being queued.)</p></li> | ||
|
||
</ol> | ||
|
||
</div> | ||
|
||
<hr> | ||
|
@@ -96403,6 +96380,9 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> { | |
<pre class="idl">[Global=(Worker,DedicatedWorker),Exposed=DedicatedWorker] | ||
/*sealed*/ interface <dfn>DedicatedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> { | ||
void <span data-x="dom-DedicatedWorkerGlobalScope-postMessage">postMessage</span>(any message, optional sequence<<span data-x="idl-object">object</span>> transfer = []); | ||
|
||
void <span data-x="dom-DedicatedWorkerGlobalScope-close">close</span>(); | ||
|
||
attribute <span>EventHandler</span> <span data-x="handler-DedicatedWorkerGlobalScope-onmessage">onmessage</span>; | ||
};</pre> | ||
|
||
|
@@ -96414,11 +96394,46 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> { | |
<p>All messages received by that port must immediately be retargeted at the | ||
<code>DedicatedWorkerGlobalScope</code> object.</p> | ||
|
||
<dl class="domintro"> | ||
<dt><var>dedicatedWorkerGlobal</var> . <code subdfn data-x="dom-DedicatedWorkerGlobalScope- | ||
postMessage">postMessage</code>(<var>message</var> [, <var>transfer</var> ])</dt> | ||
<dd>Clones <var>message</var> and transmits it to the <code>Worker</code> object associated with | ||
<var>dedicatedWorkerGlobal</var>. <var>transfer</var> can be passed as a list of objects that are | ||
to be transfered rather than cloned.</dd> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh hey, thank you for adding this! Instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
<dt><var>dedicatedWorkerGlobal</var> . <code subdfn data-x="dom-DedicatedWorkerGlobalScope- | ||
close">close</code>()</dt> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You cannot have a newline here. You need to break before data-x. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
<dd>Aborts <var>dedicatedWorkerGlobal</var>.</dd> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should appear before the The |
||
</dl> | ||
|
||
<p>The <dfn><code data-x="dom-DedicatedWorkerGlobalScope-postMessage">postMessage()</code></dfn> | ||
method on <code>DedicatedWorkerGlobalScope</code> objects must act as if, when invoked, it | ||
immediately invoked <span data-x="dom-MessagePort-postMessage">the method of the same name</span> | ||
on the port, with the same arguments, and returned the same return value.</p> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Roughly, this should read: "The |
||
<div w-nodev> | ||
|
||
<p>To <dfn>close a worker</dfn>, given a <var>workerGlobal</var>, run these steps:</p> | ||
|
||
<ol> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to say atomically here I think. We should call it out when something is a non-atomic operation and I think we mostly do, through "in parallel" and such. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess "atomically" was used to consider the two steps as an atomic operation so it would say other threads running in parallel won't queue a task between the step 1 and step 2. But I'm not sure what the original intent was. Just removed it as commented. I think changing the order of the steps (i.e. set the flag first and discard the tasks in the queue) seem to work as well without "atomically". If you feel that'd be better here, let me know. |
||
|
||
<li><p>Discard any <span data-x="concept-task">tasks</span> that have been added to | ||
<var>workerGlobal</var>'s <span>event loop</span>'s <span data-x="task queue">task | ||
queues</span>.</p> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Variable needs to be renamed here too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Thanks. |
||
<li><p>Set <var>workerGlobal</var>'s <span data-x="dom-WorkerGlobalScope-closing">closing</span> | ||
flag to true. (This prevents any further tasks from being queued.)</p></li> | ||
|
||
</ol> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also remove the newline directly after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. Done. |
||
|
||
<p>The <dfn><code data-x="dom-DedicatedWorkerGlobalScope-close">close()</code></dfn> method, when | ||
invoked, must <span>close a worker</span> with this <code>DedicatedWorkerGlobalScope</code> | ||
object.</p> | ||
|
||
</div> | ||
|
||
<hr> | ||
|
||
<p>The following are the <span>event handlers</span> (and their corresponding <span data-x="event | ||
handler event type">event handler event types</span>) that must be supported, as <span>event | ||
handler IDL attributes</span>, by objects implementing the <code>DedicatedWorkerGlobalScope</code> | ||
|
@@ -96442,6 +96457,9 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> { | |
/*sealed*/ interface <dfn>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> { | ||
readonly attribute DOMString <span data-x="dom-SharedWorkerGlobalScope-name">name</span>; | ||
readonly attribute <span>ApplicationCache</span> <span data-x="dom-SharedWorkerGlobalScope-applicationCache">applicationCache</span>; // deprecated | ||
|
||
void <span data-x="dom-SharedWorkerGlobalScope-close">close</span>(); | ||
|
||
attribute <span>EventHandler</span> <span data-x="handler-SharedWorkerGlobalScope-onconnect">onconnect</span>; | ||
};</pre> | ||
|
||
|
@@ -96459,6 +96477,10 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> { | |
<dt><var>sharedWorkerGlobal</var> . <code subdfn data-x="dom-SharedWorkerGlobalScope-name">name</code></dt> | ||
<dd>Returns <var>sharedWorkerGlobal</var>'s <span | ||
data-x="concept-SharedWorkerGlobalScope-name">name</span>.</dd> | ||
|
||
<dt><var>sharedWorkerGlobal</var> . <code subdfn data-x="dom-SharedWorkerGlobalScope- | ||
close">close</code>()</dt> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You cannot have a newline here. You need to break before data-x. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
<dd>Aborts <var>sharedWorkerGlobal</var>.</dd> | ||
</dl> | ||
|
||
<div w-nodev> | ||
|
@@ -96468,8 +96490,14 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> { | |
data-x="concept-SharedWorkerGlobalScope-name">name</span>. Its value represents the name that can | ||
be used to obtain a reference to the worker using the <code>SharedWorker</code> constructor.</p> | ||
|
||
<p>The <dfn><code data-x="dom-SharedWorkerGlobalScope-close">close()</code></dfn> method, when | ||
invoked, must <span>close a worker</span> with this <code>SharedWorkerGlobalScope</code> | ||
object.</p> | ||
|
||
</div> | ||
|
||
<hr> | ||
|
||
<p>The following are the <span>event handlers</span> (and their corresponding <span data-x="event | ||
handler event type">event handler event types</span>) that must be supported, as <span>event | ||
handler IDL attributes</span>, by objects implementing the <code>SharedWorkerGlobalScope</code> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot have a newline here. You need to break before data-x.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Done.