From 8047abb9de31d2bd5e3d3c52692f79cd2fee37f8 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Sun, 20 Aug 2023 13:17:34 +0300 Subject: [PATCH] Remove atomics, leave thread safety to implementation --- fetch.bs | 84 +++++++++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/fetch.bs b/fetch.bs index b6c18814..32841b13 100644 --- a/fetch.bs +++ b/fetch.bs @@ -2708,20 +2708,18 @@ not fully active. It has the following itemsrequest
A request. -
inactivity deferred delay (default null) +
inactivity delay (default null)
Null or a duration. -
sent (default false) -
A boolean. -
invoke state (default "deferred")

"deferred", "scheduled", "terminated", - "aborted", or "sent". + "aborted", or "activated". -

This value can be modified in parallel. To set it safely, use atomic - operations, e.g. atomically exchange the value (set it to the new value and return the new value - in one operation). +

This value can be modified in parallel. There could be a race condition where + the Document object's event loop might change it to + "deferred" at the same time that it is changed to "activated". UAs can + mitigate this race condition in an implementation-defined manner. @@ -2731,26 +2729,33 @@ not fully active. It has the following itemsterminated:

    -
  1. For each fetch record record in fetchGroup's - fetch records, if record's controller - is non-null and record's request's done flag is unset - and keepalive is false, terminate - record's controller. - -

  2. For each deferred fetch record - deferredRecord in fetchGroup's - deferred fetch records: If the result of atomically exchanging the value - of deferredRecord's invoke state with - "terminated" is not "sent", then the user agent should - fetch deferredRecord's request. The - exact time in which the fetch takes place is implementation-defined. +

  3. For each fetch record record of + fetchGroup's fetch records, if record's + controller is non-null and record's + request's done flag is unset and keepalive is + false, terminate record's + controller. + +

  4. +

    For each deferred fetch record + deferredRecord of fetchGroup's + deferred fetch records: + +

      +
    1. Set deferredRecord's invoke state to + "terminated". + +

    2. Fetch deferredRecord's + request. +

    +

When a fetch group fetchGroup is deactivated: -For each deferred fetch record deferredRecord in +For each deferred fetch record deferredRecord of fetchGroup's deferred fetch records whose -inactivity deferred delay is not null: +inactivity delay is not null:

  1. Set deferredRecord's invoke state to @@ -2761,28 +2766,20 @@ not fully active. It has the following items

  2. The user agent should wait until deferredRecord's - inactivity deferred delay have passed or until + inactivity delay have passed or until deferredRecord's invoke state is not "scheduled". The user agent may wait for a longer or shorter period time, e.g., to optimize batching of deferred fetches. -

  3. If the result of atomically exchanging the value of deferredRecord's - invoke state with "sent" is - "scheduled", then fetch record's - request. +

  4. If deferredRecord's is not "scheduled", abort these steps. + +

  5. Set deferredRecord's invoke state to + "activated". + +

  6. Fetch record's request.

- -

When a fetch group fetchGroup is -reactivated: -For each deferred fetch record deferredRecord in -fetchGroup's deferred fetch records: If the result of atomically -exchanging the value of deferredRecord's invoke state -with "deferred" is "sent", then remove -deferredRecord from fetchGroup's -deferred fetch records and set deferredRecord's -sent to true.

Resolving domains

@@ -6755,8 +6752,8 @@ is deactivated.
  • Let deferredRecord be a new deferred fetch record whose request is request. -

  • Set deferredRecord's inactivity deferred delay - to inactivityDeferredDelay. +

  • Set deferredRecord's inactivity delay to + inactivityDeferredDelay.

  • Append deferredRecord to request's client's fetch group's @@ -8630,7 +8627,7 @@ dictionary DeferredRequestInit : RequestInit { }; interface FetchLaterResult { - readonly attribute boolean sent; + readonly attribute boolean activated; }; partial interface mixin WindowOrWorkerGlobalScope { @@ -8642,8 +8639,9 @@ partial interface mixin WindowOrWorkerGlobalScope { deferred record.

    -

    The sent getter steps are to return -this's deferred record's sent. +

    The activated getter steps are to return +true if this's deferred record's +invoke state is "activated"; Otherwise false.