Skip to content

Commit

Permalink
More explicitly associate agents and event loops
Browse files Browse the repository at this point in the history
This adds a specific definition for "an agent's event loop", as opposed
to "event loop" generally, and uses it where appropriate. In a few
cases, this involves moving from "object's event loop" to "object's
relevant agent's event loop".

Note that for worker agents, event loop creation and association with
the agent is explicit. For window agents there is no corresponding text.
This can be settled as part of #5411.
  • Loading branch information
domenic committed Mar 31, 2020
1 parent c568d1d commit b95c755
Showing 1 changed file with 36 additions and 28 deletions.
64 changes: 36 additions & 28 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -78561,8 +78561,8 @@ interface <dfn>BarProp</dfn> {
</dd>

<dt>The <span>responsible event loop</span></dt>
<dd><p>Return the <span>event loop</span> associated with <var>window</var>'s <span>relevant
agent</span>.</p></dd>
<dd><p>Return <var>window</var>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span>.</p></dd>

<dt>The <span>responsible document</span></dt>
<dd>
Expand Down Expand Up @@ -87972,8 +87972,8 @@ document.querySelector("button").addEventListener("click", bound);
</li>

<li>
<p><span>Queue a microtask</span> on the <span>surrounding agent</span>'s <span>event
loop</span> to perform the following steps:</p>
<p><span>Queue a microtask</span> on the <span>surrounding agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span> to perform the following steps:</p>

<ol>
<li><p>If <var>job settings</var> is not null, then <span>check if we can run script</span>
Expand Down Expand Up @@ -88895,14 +88895,16 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {

<p>To coordinate events, user interaction, scripts, rendering, networking, and so forth, user
agents must use <dfn data-x="event loop" data-lt="event loop" data-export="">event loops</dfn> as
described in this section. Each <span>agent</span> has an associated <span>event loop</span>,
which is unique to that agent.</p>
described in this section. Each <span>agent</span> has an associated <dfn data-export=""
data-dfn-for="agent" data-x="concept-agent-event-loop">event loop</dfn>, which is unique to that
agent.</p>

<p>The <span>event loop</span> of a <span>similar-origin window agent</span> is known as a
<dfn>window event loop</dfn>. The <span>event loop</span> of a <span>dedicated worker
agent</span>, <span>shared worker agent</span>, or <span>service worker agent</span> is known as a
<dfn>worker event loop</dfn>. And the <span>event loop</span> of a <span>worklet agent</span> is
known as a <dfn>worklet event loop</dfn>.</p>
<p>The <span data-x="concept-agent-event-loop">event loop</span> of a <span>similar-origin window
agent</span> is known as a <dfn>window event loop</dfn>. The <span
data-x="concept-agent-event-loop">event loop</span> of a <span>dedicated worker agent</span>,
<span>shared worker agent</span>, or <span>service worker agent</span> is known as a <dfn>worker
event loop</dfn>. And the <span data-x="concept-agent-event-loop">event loop</span> of a
<span>worklet agent</span> is known as a <dfn>worklet event loop</dfn>.</p>

<div class="note">
<p><span data-x="event loop">Event loops</span> do not necessarily correspond to implementation
Expand Down Expand Up @@ -89061,7 +89063,7 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {

<li><p>Let <var>event loop</var> be <var>document</var>'s <span
data-x="concept-relevant-realm">relevant realm</span>'s corresponding <span>agent</span>'s
<span>event loop</span>.</p></li>
<span data-x="concept-agent-event-loop">event loop</span>.</p></li>

<li><p><span>Queue a task</span> given <var>source</var>, <var>event loop</var>,
<var>document</var>, and <var>steps</var>.</p></li>
Expand Down Expand Up @@ -89209,8 +89211,8 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
<ol>
<li>
<p>Let <var>docs</var> be all <code>Document</code> objects whose <span>relevant
agent</span>'s <span>event loop</span> is this event loop, sorted arbitrarily except that the
following conditions must be met:</p>
agent</span>'s <span data-x="concept-agent-event-loop">event loop</span> is this event loop,
sorted arbitrarily except that the following conditions must be met:</p>

<ul>
<li><p>Any <code>Document</code> <var>B</var> whose <span
Expand Down Expand Up @@ -89367,8 +89369,9 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
</ul>

<p>then for each <code>Window</code> object whose whose <span>relevant agent</span>'s
<span>event loop</span> is this event loop, run the <span>start an idle period
algorithm</span>, passing the <code>Window</code>. <ref spec="REQUESTIDLECALLBACK"></p>
<span data-x="concept-agent-event-loop">event loop</span> is this event loop, run the
<span>start an idle period algorithm</span>, passing the <code>Window</code>. <ref
spec="REQUESTIDLECALLBACK"></p>
</li>

<li>
Expand Down Expand Up @@ -96161,8 +96164,8 @@ function receiver(e) {

<li>
<p><span>Queue a task</span> on the <dfn>posted message task source</dfn> of
<var>targetWindow</var>'s <span>relevant agent</span>'s <span>event loop</span> to run the
following steps:</p>
<var>targetWindow</var>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span> to run the following steps:</p>

<ol>
<li><p>If the <var>targetOrigin</var> argument is not a single literal U+002A ASTERISK character
Expand Down Expand Up @@ -96981,11 +96984,11 @@ interface <dfn>BroadcastChannel</dfn> : <span>EventTarget</span> {
<li>
<p>For each <code>BroadcastChannel</code> object <var>destination</var> in
<var>destinations</var>, <span>queue a task</span> on the <span>DOM manipulation task
source</span> of <var>destination</var>'s <span>relevant agent</span>'s <span>event loop</span>
that runs the following steps. If that event loop is a <span>window event loop</span>, then the
<span data-x="concept-task">task</span>'s <span data-x="concept-task-document">document</span>
must be set to <var>destination</var>'s <span><code>BroadcastChannel</code> settings
object</span>'s <span>responsible document</span>.</p>
source</span> of <var>destination</var>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span> that runs the following steps. If that event
loop is a <span>window event loop</span>, then the <span data-x="concept-task">task</span>'s
<span data-x="concept-task-document">document</span> must be set to <var>destination</var>'s
<span><code>BroadcastChannel</code> settings object</span>'s <span>responsible document</span>.</p>

<ol>
<li><p>If <var>destination</var>'s <span data-x="concept-BroadcastChannel-closed">closed
Expand Down Expand Up @@ -97694,7 +97697,8 @@ interface <dfn>DedicatedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span>

<ol>
<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
<var>workerGlobal</var>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span>'s <span data-x="task queue">task
queues</span>.</p>

<li><p>Set <var>workerGlobal</var>'s <span data-x="dom-WorkerGlobalScope-closing">closing</span>
Expand Down Expand Up @@ -98132,7 +98136,8 @@ interface <dfn>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> {
data-x="dom-WorkerGlobalScope-closing">closing</span> flag to true.</p></li>

<li><p>If there are any <span data-x="concept-task">tasks</span> queued in the
<code>WorkerGlobalScope</code> object's <span>event loop</span>'s <span data-x="task queue">task
<code>WorkerGlobalScope</code> object's <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span>'s <span data-x="task queue">task
queues</span>, discard them without processing them.</p></li>

<li><p><span data-x="abort a running script">Abort the script</span> currently running in the
Expand Down Expand Up @@ -98245,15 +98250,18 @@ interface <dfn>SharedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span> {
<li><p>Let <var>inherited origin</var> be <var>outside settings</var>'s <span
data-x="concept-settings-object-origin">origin</span>.</p></li>

<li><p>Let <var>worker event loop</var> be a newly created <span>worker event
loop</span>.</p></li>

<li><p>Let <var>realm</var> be the value of <var>execution context</var>'s Realm
component.</p></li>

<li><p>Let <var>worker global scope</var> be <var>realm</var>'s <span
data-x="concept-realm-global">global object</span>.</p></li>

<li><p>Let <var>worker event loop</var> be a newly created <span>worker event
loop</span>.</p></li>

<li><p>Set <var>worker global scope</var>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span> to <var>worker event loop</var>.</p></li>

<li>
<p>Let <var>settings object</var> be a new <span>environment settings object</span> whose algorithms
are defined as follows:</p>
Expand Down

0 comments on commit b95c755

Please sign in to comment.