Skip to content

Commit

Permalink
Remove the PendingJob record and change job enqueue host operations t…
Browse files Browse the repository at this point in the history
…o take a single abstract closure.
  • Loading branch information
syg committed Mar 5, 2020
1 parent 1f935d5 commit e36a223
Showing 1 changed file with 9 additions and 82 deletions.
91 changes: 9 additions & 82 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -7576,87 +7576,14 @@ <h1>GetGlobalObject ( )</h1>
<emu-clause id="sec-jobs">
<h1>Jobs and Host Operations to Enqueue Jobs</h1>
<p>A <dfn id="job">Job</dfn> is an abstract closure with no parameters that initiates an ECMAScript computation when no other ECMAScript computation is currently in progress.</p>
<p>Execution of a Job can be initiated only when there is no running execution context and the execution context stack is empty. A PendingJob is a request for the future execution of a Job. A PendingJob is an internal Record whose fields are specified in <emu-xref href="#table-25"></emu-xref>. Once execution of a Job is initiated, the Job always executes to completion. No other Job may be initiated until the currently running Job completes. However, the currently running Job or external events may cause the enqueuing of additional PendingJobs that may be initiated sometime after completion of the currently running Job.</p>
<emu-table id="table-25" caption="PendingJob Record Fields">
<table>
<tbody>
<tr>
<th>
Field Name
</th>
<th>
Value
</th>
<th>
Meaning
</th>
</tr>
<tr>
<td>
[[Job]]
</td>
<td>
A Job abstract closure
</td>
<td>
This is the abstract closure that is performed when execution of this PendingJob is initiated.
</td>
</tr>
<tr>
<td>
[[Arguments]]
</td>
<td>
A List
</td>
<td>
The List of argument values that are to be passed to [[Job]] when it is activated.
</td>
</tr>
<tr>
<td>
[[Realm]]
</td>
<td>
A Realm Record
</td>
<td>
The Realm Record for the initial execution context when this PendingJob is initiated.
</td>
</tr>
<tr>
<td>
[[ScriptOrModule]]
</td>
<td>
A Script Record or Module Record
</td>
<td>
The script or module for the initial execution context when this PendingJob is initiated.
</td>
</tr>
<tr>
<td>
[[HostDefined]]
</td>
<td>
Any, default value is *undefined*.
</td>
<td>
Field reserved for use by host environments that need to associate additional information with a pending Job.
</td>
</tr>
</tbody>
</table>
</emu-table>
<p>Jobs are scheduled for execution by ECMAScript host environments with abstract operations. The ECMAScript specification describes the host hook HostEnqueuePromiseJob to schedule one job; host environments may define additional abstract operations which schedule jobs. Such operations accept a PendingJob Record as a parameter. These abstract operations schedule the PendingJob to be performed at some future time. Their implementations must conform to the following requirements:</p>
<p>Jobs are scheduled for execution by ECMAScript host environments with abstract operations. The ECMAScript specification describes the host hook HostEnqueuePromiseJob to schedule one job; host environments may define additional abstract operations which schedule jobs. Such operations accept a Job abstract closure as the parameter and schedule it to be performed at some future time. Their implementations must conform to the following requirements:</p>

<ul>
<li>At some future point in time, when there is no running execution context and the execution context stack is empty, the implementation must:
<ol>
<li>Push an execution context onto the execution context stack.</li>
<li>Perform any implementation-defined preparation steps.</li>
<li>Call the abstract closure _pending_.[[Job]].</li>
<li>Call the abstract closure.</li>
<li>Perform any implementation-defined cleanup steps.</li>
<li>Pop the previously-pushed execution context from the execution context stack.</li>
</ol>
Expand All @@ -7666,10 +7593,14 @@ <h1>Jobs and Host Operations to Enqueue Jobs</h1>
<li>The abstract closure must return a normal completion, implementing its own handling of errors.</li>
</ul>

<emu-note>
<p>Host environments are not required to treat Jobs uniformly with respect to scheduling. For example, web browsers treat Promise-handling Jobs as microtasks. Future features may add Jobs that are treated as tasks.</p>
</emu-note>

<emu-clause id="sec-hostenqueuepromisejob" aoid="HostEnqueuePromiseJob">
<h1>HostEnqueuePromiseJob ( _pending_ )</h1>
<h1>HostEnqueuePromiseJob ( _job_ )</h1>

<p>HostEnqueuePromiseJob is a host-defined abstract operation that schedules the PendingJob Record _pending_ to be performed, at some future time. The PendingJob Records used with this algorithm are intended to be related to the handling of Promises, or otherwise, to be scheduled with equal priority to Promise handling operations.</p>
<p>HostEnqueuePromiseJob is a host-defined abstract operation that schedules the Job abstract closure _job_ to be performed, at some future time. The abstract closures used with this algorithm are intended to be related to the handling of Promises, or otherwise, to be scheduled with equal priority to Promise handling operations.</p>

<p>The implementation of HostEnqueuePromiseJob must conform to the requirements in <emu-xref href="#sec-jobs"></emu-xref>. Additionally, Jobs must be scheduled in FIFO order, with Jobs running in the same order as the HostEnqueuePromiseJob invocations which scheduled them.</p>
</emu-clause>
Expand All @@ -7679,11 +7610,7 @@ <h1>EnqueueJob ( _kind_, _job_ )</h1>
<p>The abstract operation EnqueueJob takes two arguments, _kind_ and an abstract closure _job_, and performs the following steps:</p>
<emu-alg>
1. Assert: _job_ is a Job abstract closure.
1. Let _callerContext_ be the running execution context.
1. Let _callerRealm_ be _callerContext_'s Realm.
1. Let _callerScriptOrModule_ be _callerContext_'s ScriptOrModule.
1. Let _pending_ be PendingJob { [[Job]]: _job_, [[Realm]]: _callerRealm_, [[ScriptOrModule]]: _callerScriptOrModule_, [[HostDefined]]: *undefined* }.
1. If _kind_ is ~promise~, then perform ! HostEnqueuePromiseJob(_pending_).
1. If _kind_ is ~promise~, then perform ! HostEnqueuePromiseJob(_job_).
1. Return NormalCompletion(~empty~).
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit e36a223

Please sign in to comment.