[html5] r8463 - [giow] (0) First attempt at speccing the generic microtask queue idea. Fixing ht [...]

whatwg at whatwg.org whatwg at whatwg.org
Tue Feb 4 17:00:06 PST 2014


Author: ianh
Date: 2014-02-04 17:00:05 -0800 (Tue, 04 Feb 2014)
New Revision: 8463

Modified:
   complete.html
   index
   source
Log:
[giow] (0) First attempt at speccing the generic microtask queue idea.
Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=22296
Affected topics: DOM APIs

Modified: complete.html
===================================================================
--- complete.html	2014-02-04 23:17:01 UTC (rev 8462)
+++ complete.html	2014-02-05 01:00:05 UTC (rev 8463)
@@ -298,7 +298,7 @@
 
   <header class=head id=head><p><a href=http://www.whatwg.org/ class=logo><img width=101 src=/images/logo alt=WHATWG height=101></a></p>
    <hgroup><h1 class=allcaps>HTML</h1>
-    <h2 class="no-num no-toc">Living Standard — Last Updated 4 February 2014</h2>
+    <h2 class="no-num no-toc">Living Standard — Last Updated 5 February 2014</h2>
    </hgroup><dl><dt><strong>Web developer edition:</strong></dt>
     <dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
     <dt>Multiple-page version:</dt>
@@ -71921,22 +71921,61 @@
 
    <li><p>Return to the first step of the <a href=#event-loop>event loop</a>.</li>
 
-  </ol><hr><p>When a user agent is to <dfn id=perform-a-microtask-checkpoint>perform a microtask checkpoint</dfn>, if the <a href=#performing-a-microtask-checkpoint>performing a
+  </ol><hr><p>Each <a href=#event-loop>event loop</a> has a <dfn id=microtask-queue>microtask queue</dfn>. A <dfn id=microtask>microtask</dfn> is a
+  <a href=#concept-task title=concept-task>task</a> that is originally to be queued on the <a href=#microtask-queue>microtask
+  queue</a> rather than a <a href=#task-queue>task queue</a>. When an algorithm requires a
+  <a href=#microtask>microtask</a> to be <dfn id=queue-a-microtask title="queue a microtask">queued</dfn>, it must be appended
+  to the relevant <a href=#event-loop>event loop</a>'s <a href=#microtask-queue>microtask queue</a>; the <a href=#task-source>task
+  source</a> of such a <a href=#microtask>microtask</a> is the <dfn id=microtask-task-source>microtask task source</dfn>.</p>
+
+  <p class=note>It is possible for a <a href=#microtask>microtask</a> to be moved to a regular <a href=#task-queue>task
+  queue</a>, if, during its initial execution, it <a href=#spin-the-event-loop title="spin the event loop">spins the
+  event loop</a>. In that case, the <a href=#microtask-task-source>microtask task source</a> is the <a href=#task-source>task
+  source</a> used. Normally, the <a href=#task-source>task source</a> of a <a href=#microtask>microtask</a> is
+  irrelevant.</p>
+
+  <p>When a user agent is to <dfn id=perform-a-microtask-checkpoint>perform a microtask checkpoint</dfn>, if the <a href=#performing-a-microtask-checkpoint>performing a
   microtask checkpoint</a> flag is false, then the user agent must run the following steps:</p>
 
   <ol><li><p>Let the <a href=#performing-a-microtask-checkpoint>performing a microtask checkpoint</a> flag be true.</li>
 
-   <li><p><dfn id=perform-a-custom-elements-checkpoint>Perform a custom elements checkpoint</dfn>. <a href=#refsCUSTOM>[CUSTOM]</a></li>
+   <li>
 
-   <li><p><a href=#sort-the-tables-with-pending-sorts>Sort the tables with pending sorts</a>.</li>
+    <p><dfn id=perform-a-custom-elements-checkpoint>Perform a custom elements checkpoint</dfn>. <a href=#refsCUSTOM>[CUSTOM]</a></p>
 
+    <p class=critical>This will be removed once custom elements have been updated to use the
+    <a href=#microtask-queue>microtask queue</a>.</p>
+
+   </li>
+
    <li>
 
+    <p><a href=#sort-the-tables-with-pending-sorts>Sort the tables with pending sorts</a>.</p>
+
+    <p class=critical>This will be removed once sortable tables have been updated to use the
+    <a href=#microtask-queue>microtask queue</a>.</p>
+
+   </li>
+
+   <li>
+
     <p><a href=#concept-mo-invoke title=concept-mo-invoke>Invoke <code>MutationObserver</code> objects</a> for the
     <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a> to which the <a href=#responsible-browsing-context>responsible
-    browsing context</a> specified by the script's <a href=#settings-object>settings object</a> belongs, using
-    the <a href=#task-wrapper-algorithm>task wrapper algorithm</a> as the steps to invoke each callback.</p>
+    browsing context</a> specified by the script's <a href=#settings-object>settings object</a> belongs.</p>
 
+    <p class=critical>This will be removed once mutation observers have been updated to use the
+    <a href=#microtask-queue>microtask queue</a>.</p>
+
+   </li>
+
+   <li><p><i>Microtask queue handling</i>: If the <a href=#event-loop>event loop</a>'s <a href=#microtask-queue>microtask
+   queue</a> is empty, jump to the <i>done</i> step below.</li>
+
+   <li>
+
+    <p>Run the oldest <a href=#microtask>microtask</a> on the <a href=#event-loop>event loop</a>'s <a href=#microtask-queue>microtask
+    queue</a>.</p>
+
     <p class=note>This will typically invoke scripted callbacks, which eventually calls the
     <a href=#clean-up-after-running-a-callback>clean up after running a callback</a> steps, which call this <a href=#perform-a-microtask-checkpoint>perform a microtask
     checkpoint</a> algorithm again, which is why we use the <a href=#performing-a-microtask-checkpoint>performing a microtask
@@ -71944,8 +71983,15 @@
 
    </li>
 
-   <li><p>Let the <a href=#performing-a-microtask-checkpoint>performing a microtask checkpoint</a> flag be false.</li>
+   <li><p>If the <a href=#storage-mutex>storage mutex</a> is now owned by the <a href=#event-loop>event loop</a>, release it
+   so that it is once again free.</li>
 
+   <li><p>Remove the <a href=#microtask>microtask</a> run in the step above from the <a href=#microtask-queue>microtask
+   queue</a>, and return to the <i>microtask queue handling</i> step.</li>
+
+   <li><p><i>Done</i>: Let the <a href=#performing-a-microtask-checkpoint>performing a microtask checkpoint</a> flag be
+   false.</li>
+
   </ol><hr><p>When the user agent is to <dfn id=provide-a-stable-state>provide a stable state</dfn>, if any asynchronously-running
   algorithms are <dfn id=await-a-stable-state title="await a stable state">awaiting a stable state</dfn>, then the user
   agent must run their <dfn id=synchronous-section>synchronous section</dfn> and then resume running their asynchronous
@@ -71958,14 +72004,6 @@
   <p class=note>Steps in <a href=#synchronous-section title="synchronous section">synchronous sections</a> are marked
   with &#x231b;.</p>
 
-  <hr><p>The <dfn id=task-wrapper-algorithm>task wrapper algorithm</dfn>, which is implicitly invoked in the context of an
-  <a href=#event-loop>event loop</a> and is used to invoke a given <var title="">callback</var> in a specific
-  way, is as follows:</p>
-
-  <ol><li><p>Invoke <var title="">callback</var> as specified.</li>
-
-  </ol><p class=critical>The above will change in due course; see <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=20821">bug 20821</a>.</p>
-
   <hr><p>When an algorithm says to <dfn id=spin-the-event-loop>spin the event loop</dfn> until a condition <var title="">goal</var> is met, the user agent must run the following steps:</p>
 
   <ol><li><p>Let <var title="">task source</var> be the <a href=#task-source>task source</a> of the currently
@@ -71985,8 +72023,10 @@
     <p>Stop the currently running <a href=#concept-task title=concept-task>task</a>, allowing the <a href=#event-loop>event
     loop</a> to resume, but continue these steps asynchronously.</p>
 
-    <p class=note>This causes the <a href=#event-loop>event loop</a> to move on to the second step of its
-    processing model (defined above).</p>
+    <p class=note>This either causes the <a href=#event-loop>event loop</a> to move on to the second step of
+    its processing model, or causes the <a href=#perform-a-microtask-checkpoint>perform a microtask checkpoint</a> algorithm to
+    move on to its next step, depending on how the <span class=concept-task>task</span> came to be
+    run.</p>
 
    </li>
 

Modified: index
===================================================================
--- index	2014-02-04 23:17:01 UTC (rev 8462)
+++ index	2014-02-05 01:00:05 UTC (rev 8463)
@@ -298,7 +298,7 @@
 
   <header class=head id=head><p><a href=http://www.whatwg.org/ class=logo><img width=101 src=/images/logo alt=WHATWG height=101></a></p>
    <hgroup><h1 class=allcaps>HTML</h1>
-    <h2 class="no-num no-toc">Living Standard — Last Updated 4 February 2014</h2>
+    <h2 class="no-num no-toc">Living Standard — Last Updated 5 February 2014</h2>
    </hgroup><dl><dt><strong>Web developer edition:</strong></dt>
     <dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
     <dt>Multiple-page version:</dt>
@@ -71921,22 +71921,61 @@
 
    <li><p>Return to the first step of the <a href=#event-loop>event loop</a>.</li>
 
-  </ol><hr><p>When a user agent is to <dfn id=perform-a-microtask-checkpoint>perform a microtask checkpoint</dfn>, if the <a href=#performing-a-microtask-checkpoint>performing a
+  </ol><hr><p>Each <a href=#event-loop>event loop</a> has a <dfn id=microtask-queue>microtask queue</dfn>. A <dfn id=microtask>microtask</dfn> is a
+  <a href=#concept-task title=concept-task>task</a> that is originally to be queued on the <a href=#microtask-queue>microtask
+  queue</a> rather than a <a href=#task-queue>task queue</a>. When an algorithm requires a
+  <a href=#microtask>microtask</a> to be <dfn id=queue-a-microtask title="queue a microtask">queued</dfn>, it must be appended
+  to the relevant <a href=#event-loop>event loop</a>'s <a href=#microtask-queue>microtask queue</a>; the <a href=#task-source>task
+  source</a> of such a <a href=#microtask>microtask</a> is the <dfn id=microtask-task-source>microtask task source</dfn>.</p>
+
+  <p class=note>It is possible for a <a href=#microtask>microtask</a> to be moved to a regular <a href=#task-queue>task
+  queue</a>, if, during its initial execution, it <a href=#spin-the-event-loop title="spin the event loop">spins the
+  event loop</a>. In that case, the <a href=#microtask-task-source>microtask task source</a> is the <a href=#task-source>task
+  source</a> used. Normally, the <a href=#task-source>task source</a> of a <a href=#microtask>microtask</a> is
+  irrelevant.</p>
+
+  <p>When a user agent is to <dfn id=perform-a-microtask-checkpoint>perform a microtask checkpoint</dfn>, if the <a href=#performing-a-microtask-checkpoint>performing a
   microtask checkpoint</a> flag is false, then the user agent must run the following steps:</p>
 
   <ol><li><p>Let the <a href=#performing-a-microtask-checkpoint>performing a microtask checkpoint</a> flag be true.</li>
 
-   <li><p><dfn id=perform-a-custom-elements-checkpoint>Perform a custom elements checkpoint</dfn>. <a href=#refsCUSTOM>[CUSTOM]</a></li>
+   <li>
 
-   <li><p><a href=#sort-the-tables-with-pending-sorts>Sort the tables with pending sorts</a>.</li>
+    <p><dfn id=perform-a-custom-elements-checkpoint>Perform a custom elements checkpoint</dfn>. <a href=#refsCUSTOM>[CUSTOM]</a></p>
 
+    <p class=critical>This will be removed once custom elements have been updated to use the
+    <a href=#microtask-queue>microtask queue</a>.</p>
+
+   </li>
+
    <li>
 
+    <p><a href=#sort-the-tables-with-pending-sorts>Sort the tables with pending sorts</a>.</p>
+
+    <p class=critical>This will be removed once sortable tables have been updated to use the
+    <a href=#microtask-queue>microtask queue</a>.</p>
+
+   </li>
+
+   <li>
+
     <p><a href=#concept-mo-invoke title=concept-mo-invoke>Invoke <code>MutationObserver</code> objects</a> for the
     <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a> to which the <a href=#responsible-browsing-context>responsible
-    browsing context</a> specified by the script's <a href=#settings-object>settings object</a> belongs, using
-    the <a href=#task-wrapper-algorithm>task wrapper algorithm</a> as the steps to invoke each callback.</p>
+    browsing context</a> specified by the script's <a href=#settings-object>settings object</a> belongs.</p>
 
+    <p class=critical>This will be removed once mutation observers have been updated to use the
+    <a href=#microtask-queue>microtask queue</a>.</p>
+
+   </li>
+
+   <li><p><i>Microtask queue handling</i>: If the <a href=#event-loop>event loop</a>'s <a href=#microtask-queue>microtask
+   queue</a> is empty, jump to the <i>done</i> step below.</li>
+
+   <li>
+
+    <p>Run the oldest <a href=#microtask>microtask</a> on the <a href=#event-loop>event loop</a>'s <a href=#microtask-queue>microtask
+    queue</a>.</p>
+
     <p class=note>This will typically invoke scripted callbacks, which eventually calls the
     <a href=#clean-up-after-running-a-callback>clean up after running a callback</a> steps, which call this <a href=#perform-a-microtask-checkpoint>perform a microtask
     checkpoint</a> algorithm again, which is why we use the <a href=#performing-a-microtask-checkpoint>performing a microtask
@@ -71944,8 +71983,15 @@
 
    </li>
 
-   <li><p>Let the <a href=#performing-a-microtask-checkpoint>performing a microtask checkpoint</a> flag be false.</li>
+   <li><p>If the <a href=#storage-mutex>storage mutex</a> is now owned by the <a href=#event-loop>event loop</a>, release it
+   so that it is once again free.</li>
 
+   <li><p>Remove the <a href=#microtask>microtask</a> run in the step above from the <a href=#microtask-queue>microtask
+   queue</a>, and return to the <i>microtask queue handling</i> step.</li>
+
+   <li><p><i>Done</i>: Let the <a href=#performing-a-microtask-checkpoint>performing a microtask checkpoint</a> flag be
+   false.</li>
+
   </ol><hr><p>When the user agent is to <dfn id=provide-a-stable-state>provide a stable state</dfn>, if any asynchronously-running
   algorithms are <dfn id=await-a-stable-state title="await a stable state">awaiting a stable state</dfn>, then the user
   agent must run their <dfn id=synchronous-section>synchronous section</dfn> and then resume running their asynchronous
@@ -71958,14 +72004,6 @@
   <p class=note>Steps in <a href=#synchronous-section title="synchronous section">synchronous sections</a> are marked
   with &#x231b;.</p>
 
-  <hr><p>The <dfn id=task-wrapper-algorithm>task wrapper algorithm</dfn>, which is implicitly invoked in the context of an
-  <a href=#event-loop>event loop</a> and is used to invoke a given <var title="">callback</var> in a specific
-  way, is as follows:</p>
-
-  <ol><li><p>Invoke <var title="">callback</var> as specified.</li>
-
-  </ol><p class=critical>The above will change in due course; see <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=20821">bug 20821</a>.</p>
-
   <hr><p>When an algorithm says to <dfn id=spin-the-event-loop>spin the event loop</dfn> until a condition <var title="">goal</var> is met, the user agent must run the following steps:</p>
 
   <ol><li><p>Let <var title="">task source</var> be the <a href=#task-source>task source</a> of the currently
@@ -71985,8 +72023,10 @@
     <p>Stop the currently running <a href=#concept-task title=concept-task>task</a>, allowing the <a href=#event-loop>event
     loop</a> to resume, but continue these steps asynchronously.</p>
 
-    <p class=note>This causes the <a href=#event-loop>event loop</a> to move on to the second step of its
-    processing model (defined above).</p>
+    <p class=note>This either causes the <a href=#event-loop>event loop</a> to move on to the second step of
+    its processing model, or causes the <a href=#perform-a-microtask-checkpoint>perform a microtask checkpoint</a> algorithm to
+    move on to its next step, depending on how the <span class=concept-task>task</span> came to be
+    run.</p>
 
    </li>
 

Modified: source
===================================================================
--- source	2014-02-04 23:17:01 UTC (rev 8462)
+++ source	2014-02-05 01:00:05 UTC (rev 8463)
@@ -80326,6 +80326,19 @@
 
   <hr>
 
+  <p>Each <span>event loop</span> has a <dfn>microtask queue</dfn>. A <dfn>microtask</dfn> is a
+  <span data-x="concept-task">task</span> that is originally to be queued on the <span>microtask
+  queue</span> rather than a <span>task queue</span>. When an algorithm requires a
+  <span>microtask</span> to be <dfn data-x="queue a microtask">queued</dfn>, it must be appended
+  to the relevant <span>event loop</span>'s <span>microtask queue</span>; the <span>task
+  source</span> of such a <span>microtask</span> is the <dfn>microtask task source</dfn>.</p>
+
+  <p class="note">It is possible for a <span>microtask</span> to be moved to a regular <span>task
+  queue</span>, if, during its initial execution, it <span data-x="spin the event loop">spins the
+  event loop</span>. In that case, the <span>microtask task source</span> is the <span>task
+  source</span> used. Normally, the <span>task source</span> of a <span>microtask</span> is
+  irrelevant.</p>
+
   <p>When a user agent is to <dfn>perform a microtask checkpoint</dfn>, if the <span>performing a
   microtask checkpoint</span> flag is false, then the user agent must run the following steps:</p>
 
@@ -80333,17 +80346,43 @@
 
    <li><p>Let the <span>performing a microtask checkpoint</span> flag be true.</p></li>
 
-   <li><p><dfn>Perform a custom elements checkpoint</dfn>. <a href="#refsCUSTOM">[CUSTOM]</a></p></li>
+   <li>
 
-   <li><p><span>Sort the tables with pending sorts</span>.</p></li>
+    <p><dfn>Perform a custom elements checkpoint</dfn>. <a href="#refsCUSTOM">[CUSTOM]</a></p>
 
+    <p class="critical">This will be removed once custom elements have been updated to use the
+    <span>microtask queue</span>.</p>
+
+   </li>
+
    <li>
 
+    <p><span>Sort the tables with pending sorts</span>.</p>
+
+    <p class="critical">This will be removed once sortable tables have been updated to use the
+    <span>microtask queue</span>.</p>
+
+   </li>
+
+   <li>
+
     <p><span data-x="concept-mo-invoke">Invoke <code>MutationObserver</code> objects</span> for the
     <span>unit of related similar-origin browsing contexts</span> to which the <span>responsible
-    browsing context</span> specified by the script's <span>settings object</span> belongs, using
-    the <span>task wrapper algorithm</span> as the steps to invoke each callback.</p>
+    browsing context</span> specified by the script's <span>settings object</span> belongs.</p>
 
+    <p class="critical">This will be removed once mutation observers have been updated to use the
+    <span>microtask queue</span>.</p>
+
+   </li>
+
+   <li><p><i>Microtask queue handling</i>: If the <span>event loop</span>'s <span>microtask
+   queue</span> is empty, jump to the <i>done</i> step below.</p></li>
+
+   <li>
+
+    <p>Run the oldest <span>microtask</span> on the <span>event loop</span>'s <span>microtask
+    queue</span>.</p>
+
     <p class="note">This will typically invoke scripted callbacks, which eventually calls the
     <span>clean up after running a callback</span> steps, which call this <span>perform a microtask
     checkpoint</span> algorithm again, which is why we use the <span>performing a microtask
@@ -80351,8 +80390,15 @@
 
    </li>
 
-   <li><p>Let the <span>performing a microtask checkpoint</span> flag be false.</p></li>
+   <li><p>If the <span>storage mutex</span> is now owned by the <span>event loop</span>, release it
+   so that it is once again free.</p></li>
 
+   <li><p>Remove the <span>microtask</span> run in the step above from the <span>microtask
+   queue</span>, and return to the <i>microtask queue handling</i> step.</p></li>
+
+   <li><p><i>Done</i>: Let the <span>performing a microtask checkpoint</span> flag be
+   false.</p></li>
+
   </ol>
 
   <hr>
@@ -80372,21 +80418,6 @@
 
   <hr>
 
-  <p>The <dfn>task wrapper algorithm</dfn>, which is implicitly invoked in the context of an
-  <span>event loop</span> and is used to invoke a given <var data-x="">callback</var> in a specific
-  way, is as follows:</p>
-
-  <ol>
-
-   <li><p>Invoke <var data-x="">callback</var> as specified.</p></li>
-
-  </ol>
-
-  <p class="critical">The above will change in due course; see <a
-  href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=20821">bug 20821</a>.</p>
-
-  <hr>
-
   <p>When an algorithm says to <dfn>spin the event loop</dfn> until a condition <var
   data-x="">goal</var> is met, the user agent must run the following steps:</p>
 
@@ -80409,8 +80440,10 @@
     <p>Stop the currently running <span data-x="concept-task">task</span>, allowing the <span>event
     loop</span> to resume, but continue these steps asynchronously.</p>
 
-    <p class="note">This causes the <span>event loop</span> to move on to the second step of its
-    processing model (defined above).</p>
+    <p class="note">This either causes the <span>event loop</span> to move on to the second step of
+    its processing model, or causes the <span>perform a microtask checkpoint</span> algorithm to
+    move on to its next step, depending on how the <span class="concept-task">task</span> came to be
+    run.</p>
 
    </li>
 




More information about the Commit-Watchers mailing list