Skip to content

Commit

Permalink
Say that all job-related host hooks pass a realm for scheduling in a …
Browse files Browse the repository at this point in the history
…particular agent
  • Loading branch information
syg committed Jun 7, 2023
1 parent a1876f4 commit 6da1bbe
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -11834,18 +11834,18 @@ <h1>GetGlobalObject ( ): an Object</h1>
<emu-clause id="sec-jobs" oldids="sec-jobs-and-job-queues,sec-enqueuejob,sec-runjobs,job-queue">
<h1>Jobs and Host Operations to Enqueue Jobs</h1>
<p>A <dfn id="job" variants="Jobs">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>Jobs are scheduled for execution by ECMAScript host environments in an agent. A Job is usually, but not always, executed in the same agent that enqueued it. This specification describes the host hooks HostEnqueueGenericJob, HostEnqueueFinalizationRegistryCleanupJob, HostEnqueuePromiseJob, and HostEnqueueTimeoutJob to schedule jobs. The host hooks in this specification are organized by the additional constraints imposed on the scheduling of jobs. Hosts 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>
<p>Jobs are scheduled for execution by ECMAScript host environments in a particular agent. This specification describes the host hooks HostEnqueueGenericJob, HostEnqueueFinalizationRegistryCleanupJob, HostEnqueuePromiseJob, and HostEnqueueTimeoutJob to schedule jobs. The host hooks in this specification are organized by the additional constraints imposed on the scheduling of jobs. Hosts may define additional abstract operations which schedule jobs. Such operations accept a Job Abstract Closure and a realm (a Realm Record or *null*) as parameters. If a Realm Record is provided, these operations schedule the job to be performed at some future time in the provided realm, in the agent that owns the realm. If *null* is provided instead for the realm, then the job does not evaluate ECMAScript code. Their implementations must conform to the following requirements:</p>

<ul>
<li>At some future point in time in some agent _agent_, when there is no running execution context in _agent_ and its execution context stack is empty, the implementation must:
<li>At some future point in time, when there is no running context in the agent for which the job is scheduled and that agent's execution context stack is empty, the implementation must:
<ol>
<li>Perform any host-defined preparation steps.</li>
<li>Invoke the Job Abstract Closure.</li>
<li>Perform any host-defined cleanup steps, after which the execution context stack must be empty.</li>
</ol>
</li>
<li>Only one Job may be actively undergoing evaluation at any point in time.</li>
<li>Once evaluation of a Job starts, it must run to completion before evaluation of any other Job starts.</li>
<li>Only one Job may be actively undergoing evaluation at any point in time in an agent.</li>
<li>Once evaluation of a Job starts, it must run to completion before evaluation of any other Job starts in an agent.</li>
<li>The Abstract Closure must return a normal completion, implementing its own handling of errors.</li>
</ul>

Expand Down Expand Up @@ -12007,12 +12007,13 @@ <h1>
<h1>
HostEnqueueTimeoutJob (
_timeoutJob_: a Job Abstract Closure,
_realm_: a Realm Record,
_milliseconds_: a non-negative finite Number,
): ~unused~
</h1>
<dl class="header">
<dt>description</dt>
<dd>It schedules _timeoutJob_ to be performed after at least _milliseconds_ milliseconds.</dd>
<dd>It schedules _timeoutJob_ in the realm _realm_ in the agent signified by _realm_.[[AgentSignifier]] to be performed after at least _milliseconds_ milliseconds.</dd>
</dl>
<p>An implementation of HostEnqueueTimeoutJob must conform to the requirements in <emu-xref href="#sec-jobs"></emu-xref>.</p>
</emu-clause>
Expand Down Expand Up @@ -42697,7 +42698,7 @@ <h1>
1. Assert: _waiterRecord_.[[AgentSignifier]] is _thisAgent_.
1. Assert: _waiterRecord_.[[PromiseCapability]] is ~blocking~.
1. Assert: AgentCanSuspend() is *true*.
1. Perform LeaveCriticalSection(_WL_) and suspend the surrounding agent until the time is _waiterRecord_.[[TimeoutTime]], performing the combined operation in such a way that a notification that arrives after the critical section is exited but before the suspension takes effect is not lost. The only way for the surrounding agent to wake from suspension is by another agent calling NotifyWaiter with arguments _WL_ and _thisAgent_. This can happen if the timeout expires or via a call to `Atomics.notify`.
1. Perform LeaveCriticalSection(_WL_) and suspend the surrounding agent until the time is _waiterRecord_.[[TimeoutTime]], performing the combined operation in such a way that a notification that arrives after the critical section is exited but before the suspension takes effect is not lost. The surrounding agent can only wake from suspension due to a timeout or due to another agent calling NotifyWaiter with arguments _WL_ and _thisAgent_ (i.e. via a call to `Atomics.notify`).
1. Perform EnterCriticalSection(_WL_).
1. Return ~unused~.
</emu-alg>
Expand Down Expand Up @@ -42834,14 +42835,15 @@ <h1>
1. Perform EnterCriticalSection(_WL_).
1. If _WL_.[[Waiters]] contains _waiterRecord_, then
1. Let _timeOfJobExecution_ be the time value (UTC) identifying the current time.
1. Assert: ℝ(_timeOfJobExecution_) ≥ _waiterRecord_.[[TimeoutTime]].
1. Assert: ℝ(_timeOfJobExecution_) ≥ _waiterRecord_.[[TimeoutTime]] (ignoring potential non-monotonicity of time values).
1. Set _waiterRecord_.[[Result]] to *"timed-out"*.
1. Perform RemoveWaiter(_WL_, _waiterRecord_).
1. Perform NotifyWaiter(_WL_, _waiterRecord_).
1. Perform LeaveCriticalSection(_WL_).
1. Return ~unused~.
1. Let _now_ be the time value (UTC) identifying the current time.
1. Perform HostEnqueueTimeoutJob(_timeoutJob_, 𝔽(_waiterRecord_.[[TimeoutTime]]) - _now_).
1. Let _currentRealm_ be the current Realm Record.
1. Perform HostEnqueueTimeoutJob(_timeoutJob_, _currentRealm_, 𝔽(_waiterRecord_.[[TimeoutTime]]) - _now_).
1. Return ~unused~.
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit 6da1bbe

Please sign in to comment.