Skip to content

Commit 4d3958a

Browse files
committed
Define a parallel queue for lock operations
Fixes whatwg#74
1 parent 8360b75 commit 4d3958a

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

index.bs

+25-19
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,29 @@ A <dfn export id=file>file entry</dfn> additionally consists of
9494
a <dfn for="file entry">lock</dfn> (a string that may exclusively be "`open`", "`taken-exclusive`" or "`taken-shared`")
9595
and a <dfn for="file entry">shared lock count</dfn> (a number representing the number shared locks that are taken at a given point in time).
9696

97+
The <dfn id="file-system-lock-queue">file system lock queue</dfn> is a
98+
[=parallel queue=] to be used for all <a for=/>tasks</a> involving a
99+
[=file entry/lock=].
100+
97101
<div algorithm>
98102
To <dfn for="file entry/lock">take</dfn> a [=file entry/lock=] with a |value| of "`exclusive`" or "`shared`" on a given [=file entry=] |file|:
99103

100104
1. Let |lock| be the |file|'s [=file entry/lock=].
101-
1. Let |count| be the |file|'s [=file entry/shared lock count=].
102-
1. If |value| is "`exclusive`":
103-
1. If |lock| is "`open`":
104-
1. Set lock to "`taken-exclusive`".
105-
1. Return true.
106-
1. If |value| is "`shared`":
107-
1. If |lock| is "`open`":
108-
1. Set |lock| to "`taken-shared`".
109-
1. Set |count| to 1.
110-
1. Return true.
111-
1. Otherwise, if |lock| is "`taken-shared`":
112-
1. Increase |count| by one.
113-
1. Return true.
114-
1. Return false.
105+
1. [=Enqueue the following steps=] to the [=file system lock queue=]:
106+
1. Let |count| be the |file|'s [=file entry/shared lock count=].
107+
1. If |value| is "`exclusive`":
108+
1. If |lock| is "`open`":
109+
1. Set lock to "`taken-exclusive`".
110+
1. Return true.
111+
1. If |value| is "`shared`":
112+
1. If |lock| is "`open`":
113+
1. Set |lock| to "`taken-shared`".
114+
1. Set |count| to 1.
115+
1. Return true.
116+
1. Otherwise, if |lock| is "`taken-shared`":
117+
1. Increase |count| by one.
118+
1. Return true.
119+
1. Return false.
115120

116121
</div>
117122

@@ -120,11 +125,12 @@ To <dfn for="file entry/lock">release</dfn> a [=file entry/lock=] on a given [=f
120125
run these steps:
121126

122127
1. Let |lock| be the |file|'s associated [=file entry/lock=].
123-
1. Let |count| be the |file|'s [=file entry/shared lock count=].
124-
1. If |lock| is "`taken-shared`":
125-
1. Decrease |count| by one.
126-
1. If |count| is 0, set |lock| to "`open`".
127-
1. Otherwise, set |lock| to "`open`".
128+
1. [=Enqueue the following steps=] to the [=file system lock queue=]:
129+
1. Let |count| be the |file|'s [=file entry/shared lock count=].
130+
1. If |lock| is "`taken-shared`":
131+
1. Decrease |count| by one.
132+
1. If |count| is 0, set |lock| to "`open`".
133+
1. Otherwise, set |lock| to "`open`".
128134

129135
</div>
130136

0 commit comments

Comments
 (0)