Editorial: use a dedicated parallel queue for the Clients API - #1842
Editorial: use a dedicated parallel queue for the Clients API#1842monica-ch wants to merge 1 commit into
Conversation
7f622b8 to
805ee59
Compare
| Each {{Clients}} object has an associated <dfn>Clients parallel queue</dfn> (a [=parallel queue=]) used to serialize the {{Clients}} object's operations. | ||
|
|
There was a problem hiding this comment.
Recognizing this patch is a WIP, I think this is currently under-constrained and it probably makes sense to do this like you've done it for the Cache API in #1838 which is basically one-per-storage-key. (Whereas this currently seems to be 1-per-ServiceWorker instance.)
There was a problem hiding this comment.
Agreed, 1-per-Clients is under-constrained. Will rework to 1-per-storage-key matching #1838.
Quick clarification before I push: #1838 hangs the queue off [=name to cache map=] because that map is itself per-storage-key. Clients don't have an equivalent map — the [=/service worker clients=] list is UA-wide, filtered by storage key. Would you prefer a UA-level <dfn>Clients parallel queue</dfn> map keyed by storage key, or a prose "for each storage key, the UA has an associated Clients parallel queue" form?
There was a problem hiding this comment.
(this got cross-referenced below, but the right answer definitely is not obvious to me, so I asked in the storage spec at whatwg/storage#194)
There was a problem hiding this comment.
Thanks for kicking off the discussion. Reworked per Anne's suggestion, UA now owns a map keyed by storage key, per-Clients methods enqueue via a relevant service worker clients parallel queue helper (mirrors #1838's relevant name to cache map. PTAL.
805ee59 to
8911a7f
Compare
Give each storage key its own parallel queue, held by the user agent, and route Clients.get, Clients.matchAll, Clients.openWindow, and Clients.claim through it. This serializes operations across all Clients objects that share a storage key, rather than only within a single ServiceWorkerGlobalScope. Introduces three dfns: a user-agent-owned service worker clients parallel queue map (storage key to parallel queue), a per-storage-key service worker clients parallel queue helper with lazy initialization, and a per-Clients relevant service worker clients parallel queue helper mirroring the relevant name to cache map pattern from PR 1838. Closes: w3c#1840
8911a7f to
73a7c0b
Compare
Closes #1840. Follow-up to #1755.
Give each {{Clients}} object a dedicated parallel queue and route the operations on {{Clients}} through it, so operations on the same {{Clients}} object do not race with each other (e.g.
matchAlliterating over service worker clients whileclaimis mutating their [=active service worker=]).Changes
<dfn export for="Clients">Clients parallel queue</dfn>(a [=parallel queue=]) attached to each {{Clients}} object, following the same pattern as thename to cache map parallel queueintroduced in Editorial: serialize CacheStorage access on a dedicated parallel queue #1838.Run … in parallelblock:Resolve |promise| with undefined.steps (inget()andclaim()) inQueue a taskon|promise|'s [=responsible event loop=] using the [=DOM manipulation task source=], matching the pattern already used inmatchAll()and consistent with the queue-a-task refactor from Editorial: Queue a task to resolve/reject promise or when fire an event. #1755.Total change: +10 / −6 in
index.bs, one commit.Rationale
Yoshi flagged this concern during #1755 review:
#1836 landed the queue-a-task-for-resolve fixes for these methods. This PR delivers the sibling parallel-queue work that was explicitly deferred in the split plan.
Out of scope
in parallelblock entirely and useQueue a taskon the client's own event loop, so no parallel-queue treatment is meaningful for them.Related
Preview | Diff