You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move queue map and held lock set to lock manager (#90)
Replace lock set and request queue associations with an origin with a lock manager instead.
This doesn't change normative behavior, just moves conceptual ownership off the origin. This paves the way for future work towards #74 to enable partitioning, and coincidentally matches implementations.
Copy file name to clipboardExpand all lines: index.bs
+27-26Lines changed: 27 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -208,7 +208,7 @@ A [=lock-concept|lock=] has an <dfn>agent</dfn> which is an [=/agent=].
208
208
209
209
A [=lock-concept|lock=] has a <dfn>clientId</dfn> which is an opaque string.
210
210
211
-
A [=lock-concept|lock=] has an<dfn>origin</dfn> which is an[=/origin=].
211
+
A [=lock-concept|lock=] has a<dfn>manager</dfn> which is a[=/lock manager=].
212
212
213
213
A [=lock-concept|lock=] has a <dfn>name</dfn> which is a [=resource name=].
214
214
@@ -246,7 +246,7 @@ The [=lock-concept/waiting promise=] is not named in the above code, but is stil
246
246
Further note that if the callback is not `async` and returns a non-promise, the return value is wrapped in a promise that is immediately resolved; the lock will be released in an upcoming microtask, and the [=lock-concept/released promise=] will also resolve in a subsequent microtask.
247
247
</aside>
248
248
249
-
Each origin has a <dfn>held lock set</dfn> which is a [=/set=] of [=lock-concept|locks=].
249
+
Each [=/lock manager=]has a <dfn for="lock manager">held lock set</dfn> which is a [=/set=] of [=lock-concept|locks=].
250
250
251
251
<div algorithm="waiting promise settles">
252
252
@@ -267,17 +267,17 @@ A <dfn>lock request</dfn> represents a pending request for a [=lock-concept|lock
267
267
268
268
<div dfn-for="lock request">
269
269
270
-
A [=lock request=] is a [=/struct=] with [=struct/items=]<dfn>agent</dfn>, <dfn>clientId</dfn>, <dfn>origin</dfn>, <dfn>name</dfn>, <dfn>mode</dfn>, <dfn>callback</dfn>, <dfn>promise</dfn>, and <dfn>signal</dfn>.
270
+
A [=lock request=] is a [=/struct=] with [=struct/items=]<dfn>agent</dfn>, <dfn>clientId</dfn>, <dfn>manager</dfn>, <dfn>name</dfn>, <dfn>mode</dfn>, <dfn>callback</dfn>, <dfn>promise</dfn>, and <dfn>signal</dfn>.
271
271
272
272
</div>
273
273
274
274
A <dfn>lock request queue</dfn> is a [=/queue=] of [=/lock requests=].
275
275
276
-
Each origin has a <dfn>lock request queue map</dfn>, which is a [=map=] of [=resource names=] to [=/lock request queues=].
276
+
Each [=/lock manager=]has a <dfn for="lock manager">lock request queue map</dfn>, which is a [=map=] of [=resource names=] to [=/lock request queues=].
277
277
278
278
<div algorithm>
279
279
280
-
To <dfn>get the lock request queue</dfn> from [=/lock request queue map=] |queueMap| from [=/resource name=] |name|, run these steps:
280
+
To <dfn>get the lock request queue</dfn> from [=lock manager/lock request queue map=] |queueMap| from [=/resource name=] |name|, run these steps:
281
281
282
282
1. If |queueMap|[|name|] does not [=map/exist=], [=map/set=] |queueMap|[|name|] to a new empty [=/lock request queue=].
283
283
1. Return |queueMap|[|name|].
@@ -289,11 +289,11 @@ To <dfn>get the lock request queue</dfn> from [=/lock request queue map=] |queue
289
289
290
290
A [=lock request=] |request| is said to be <dfn>grantable</dfn> if the following steps return true:
291
291
292
-
1. Let |origin| be |request|'s [=lock request/origin=].
293
-
1. Let |queueMap| be |origin|'s [=lock request queue map=].
292
+
1. Let |manager| be |request|'s [=lock request/manager=].
293
+
1. Let |queueMap| be |manager|'s [=lock manager/lock request queue map=].
294
294
1. Let |name| be |request|'s [=lock request/name=].
295
295
1. Let |queue| be the result of [=/getting the lock request queue=] from |queueMap| for |name|.
296
-
1. Let |held| be |origin|'s [=held lock set=]
296
+
1. Let |held| be |manager|'s [=lock manager/held lock set=]
297
297
1. Let |mode| be |request|'s [=lock request/mode=]
298
298
1. If |queue| [=queue/is empty|is not empty=] and |request| is not the first [=queue/item=] in |queue|, then return false.
299
299
1. If |mode| is "{{exclusive}}", then return true if no [=lock-concept|lock=] in |held| has [=lock-concept/name=] equal to |name|, and false otherwise.
@@ -495,7 +495,7 @@ The <dfn method for=LockManager>request(|name|, |callback|)</dfn> and
1. If |options| was not passed, then let |options| be a new {{LockOptions}} dictionary with default members.
498
-
1. Let |environment| be [=/this=]'s [=relevant settings object=].
498
+
1. Let |environment| be [=/this=]'s [=/relevant settings object=].
499
499
1. If |environment|'s [=responsible document=] is not [=fully active=], then return [=a promise rejected with=] a "{{InvalidStateError}}" {{DOMException}}.
500
500
1. Let |origin| be |environment|'s [=/origin=].
501
501
1. If |origin| is an [=opaque origin=], then return [=a promise rejected with=] a "{{SecurityError}}" {{DOMException}}.
@@ -505,7 +505,7 @@ The <dfn method for=LockManager>request(|name|, |callback|)</dfn> and
505
505
1. If |options|["`signal`"][=map/exists=], and either of |options|["`steal`"] or |options|["`ifAvailable`"] is true, then return [=a promise rejected with=] a "{{NotSupportedError}}" {{DOMException}}.
506
506
1. If |options|["`signal`"][=map/exists=] and its [=AbortSignal/aborted flag=] is set, then return [=a promise rejected with=] an "{{AbortError}}" {{DOMException}.
507
507
1. Let |promise| be [=a new promise=].
508
-
1. [=Request a lock=] with |promise|, the current [=/agent=], |environment|'s [=environment/id=], |origin|, |callback|, |name|, |options|["`mode`"], |options|["`ifAvailable`"], |options|["`steal`"], and |options|["`signal`"].
508
+
1. [=Request a lock=] with |promise|, the current [=/agent=], |environment|'s [=environment/id=], |origin|'s [=/lock manager=], |callback|, |name|, |options|["`mode`"], |options|["`ifAvailable`"], |options|["`steal`"], and |options|["`signal`"].
1. If |origin| is an [=opaque origin=], then return [=a promise rejected with=] a "{{SecurityError}}" {{DOMException}}.
561
561
1. Let |promise| be [=a new promise=].
562
-
1. [=enqueue the following steps|Enqueue the steps=] to [=snapshot the lock state=] for |origin| with |promise| to the [=lock task queue=].
562
+
1. [=enqueue the following steps|Enqueue the steps=] to [=snapshot the lock state=] for |origin|'s [=/lock manager=] with |promise| to the [=lock task queue=].
563
563
1. Return |promise|.
564
564
565
565
</div>
@@ -591,14 +591,14 @@ The <dfn attribute for=Lock>mode</dfn> getter's steps are to return the associat
To <dfn>request a lock</dfn> with |promise|, |agent|, |clientId|, |origin|, |callback|, |name|, |mode|, |ifAvailable|, |steal|, and |signal|:
594
+
To <dfn>request a lock</dfn> with |promise|, |agent|, |clientId|, |manager|, |callback|, |name|, |mode|, |ifAvailable|, |steal|, and |signal|:
595
595
596
-
1. Let |request| be a new [=lock request=] (|agent|, |clientId|, |origin|, |name|, |mode|, |callback|, |promise|, |signal|).
596
+
1. Let |request| be a new [=lock request=] (|agent|, |clientId|, |manager|, |name|, |mode|, |callback|, |promise|, |signal|).
597
597
1. If |signal| is present, then [=AbortSignal/add=] the algorithm [=signal to abort the request=] |request| to |signal|.
598
598
1. [=Enqueue the following steps=] to the [=lock task queue=]:
599
-
1. Let |queueMap| be |origin|'s [=lock request queue map=].
599
+
1. Let |queueMap| be |manager|'s [=lock manager/lock request queue map=].
600
600
1. Let |queue| be the result of [=/getting the lock request queue=] from |queueMap| for |name|.
601
-
1. Let |held| be |origin|'s [=held lock set=].
601
+
1. Let |held| be |manager|'s [=lock manager/held lock set=].
602
602
1. If |steal| is true, then run these steps:
603
603
1. [=list/For each=] |lock| of |held|:
604
604
1. If |lock|'s [=lock-concept/name=] is |name|, then run these steps:
@@ -624,11 +624,11 @@ To <dfn>request a lock</dfn> with |promise|, |agent|, |clientId|, |origin|, |cal
624
624
To <dfn>release the lock</dfn> |lock|:
625
625
626
626
1. [=Assert=]: these steps are running on the [=lock task queue=].
627
-
1. Let |origin| be |lock|'s [=lock-concept/origin=].
628
-
1. Let |queueMap| be |origin|'s [=lock request queue map=].
627
+
1. Let |manager| be |lock|'s [=lock-concept/manager=].
628
+
1. Let |queueMap| be |manager|'s [=lock manager/lock request queue map=].
629
629
1. Let |name| be |lock|'s [=resource name=].
630
630
1. Let |queue| be the result of [=/getting the lock request queue=] from |queueMap| for |name|.
631
-
1. [=list/Remove=][=lock-concept|lock=] from the |origin|'s [=held lock set=].
631
+
1. [=list/Remove=][=lock-concept|lock=] from the |manager|'s [=lock manager/held lock set=].
632
632
1. [=Process the lock request queue=] |queue|.
633
633
634
634
</div>
@@ -641,9 +641,9 @@ To <dfn>release the lock</dfn> |lock|:
641
641
To <dfn>abort the request</dfn> |request|:
642
642
643
643
1. [=Assert=]: these steps are running on the [=lock task queue=].
644
-
1. Let |origin| be |request|'s [=lock request/origin=].
644
+
1. Let |manager| be |request|'s [=lock request/manager=].
645
645
1. Let |name| be |request|'s [=lock request/name=].
646
-
1. Let |queueMap| be |origin|'s [=lock request queue map=].
646
+
1. Let |queueMap| be |manager|'s [=lock manager/lock request queue map=].
647
647
1. Let |queue| be the result of [=/getting the lock request queue=] from |queueMap| for |name|.
648
648
1. [=list/Remove=] |request| from |queue|.
649
649
1. [=Process the lock request queue=] |queue|.
@@ -672,16 +672,17 @@ To <dfn>process the lock request queue</dfn> |queue|:
672
672
Note: Only the first item in a queue is grantable. Therefore, if something is not grantable then all the following items are automatically not grantable.
673
673
674
674
1. [=list/Remove=] |request| from |queue|.
675
-
1. Let |agent| be |request|'s [=lock-concept/agent=]
675
+
1. Let |agent| be |request|'s [=lock-concept/agent=].
676
+
1. Let |manager| be |request|'s [=lock request/manager=].
676
677
1. Let |clientId| be |request|'s [=lock request/clientId=].
677
678
1. Let |name| be |request|'s [=lock request/name=].
678
679
1. Let |mode| be |request|'s [=lock request/mode=].
679
680
1. Let |callback| be |request|'s [=lock request/callback=].
680
681
1. Let |p| be |request|'s [=lock request/promise=].
681
682
1. Let |signal| be |request|'s [=lock request/signal=].
682
683
1. Let |waiting| be [=a new promise=].
683
-
1. Let |lock| be a new [=lock-concept|lock=] with [=lock-concept/agent=] |agent|, [=lock-concept/clientId=] |clientId|, [=lock-concept/origin=] |origin|, [=lock-concept/mode=] |mode|, [=lock-concept/name=] |name|, [=lock-concept/released promise=] |p|, and [=lock-concept/waiting promise=] |waiting|.
684
-
1. [=set/Append=] |lock| to |origin|'s [=held lock set=].
684
+
1. Let |lock| be a new [=lock-concept|lock=] with [=lock-concept/agent=] |agent|, [=lock-concept/clientId=] |clientId|, [=lock-concept/manager=] |manager|, [=lock-concept/mode=] |mode|, [=lock-concept/name=] |name|, [=lock-concept/released promise=] |p|, and [=lock-concept/waiting promise=] |waiting|.
685
+
1. [=set/Append=] |lock| to |manager|'s [=lock manager/held lock set=].
685
686
1. [=Enqueue the following steps=] on |callback|'s [=relevant settings object=]'s [=responsible event loop=]:
686
687
1. If |signal| is present, then run these steps:
687
688
1. If |signal|'s [=AbortSignal/aborted flag=] is set, then run these steps:
@@ -699,15 +700,15 @@ To <dfn>process the lock request queue</dfn> |queue|:
0 commit comments