Skip to content

Commit

Permalink
Normative: Treat the Atomics.wait timeout as an extended mathematical…
Browse files Browse the repository at this point in the history
… lower bound

Fixes tc39#2914
  • Loading branch information
gibson042 committed Nov 29, 2022
1 parent a5f5f80 commit e3f2597
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -41981,7 +41981,7 @@ <h1>
SuspendAgent (
_WL_: a WaiterList,
_W_: an agent signifier,
_timeout_: a non-negative integer,
_timeout_: a non-negative extended mathematical value,
): a Boolean
</h1>
<dl class="header">
Expand All @@ -41991,7 +41991,7 @@ <h1>
1. Assert: _W_ is equivalent to AgentSignifier().
1. Assert: _W_ is on the list of waiters in _WL_.
1. Assert: AgentCanSuspend() is *true*.
1. Perform LeaveCriticalSection(_WL_) and suspend _W_ for up to _timeout_ milliseconds, 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. _W_ can notify either because the timeout expired or because it was notified explicitly by another agent calling NotifyWaiter with arguments _WL_ and _W_, and not for any other reasons at all.
1. Perform LeaveCriticalSection(_WL_) and suspend _W_ until either _W_ is notified by another agent calling NotifyWaiter with arguments _WL_ and _W_ or at least _timeout_ milliseconds have elapsed, performing the combined operation in such a way that a notification arriving after the critical section is exited but before the suspension takes effect is not lost.
1. Perform EnterCriticalSection(_WL_).
1. If _W_ was notified explicitly by another agent calling NotifyWaiter with arguments _WL_ and _W_, return *true*.
1. Return *false*.
Expand Down Expand Up @@ -42282,9 +42282,14 @@ <h1>Atomics.wait ( _typedArray_, _index_, _value_, _timeout_ )</h1>
1. Else,
1. Perform RemoveWaiter(_WL_, _W_).
1. Perform LeaveCriticalSection(_WL_).
1. Let _padding_ be an implementation-defined non-negative integer.
1. [id="step-atomics.wait-degrade-resolution"] If _padding_ ≠ 0, wait until a further _padding_ milliseconds have elapsed.
1. If _notified_ is *true*, return *"ok"*.
1. Return *"timed-out"*.
</emu-alg>
<emu-note>
<p>Step <emu-xref href="#step-atomics.wait-degrade-resolution"></emu-xref> allows implementations to pad timeouts, which they might use to mitigate timing attacks and/or support processor timers with coarse resolution.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-atomics.notify">
Expand Down

0 comments on commit e3f2597

Please sign in to comment.