Skip to content

Commit 3e7fbf8

Browse files
committed
Define a parallel queue for lock operations
Fixes whatwg#74
1 parent 2b0a522 commit 3e7fbf8

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
@@ -90,24 +90,29 @@ A <dfn export id=file>file entry</dfn> additionally consists of
9090
a <dfn for="file entry">lock</dfn> (a string that may exclusively be "`open`", "`taken-exclusive`" or "`taken-shared`")
9191
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).
9292

93+
The <dfn id="file-system-lock-queue">file system lock queue</dfn> is a
94+
[=parallel queue=] to be used for all <a for=/>tasks</a> involving a
95+
[=file entry/lock=].
96+
9397
<div algorithm>
9498
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|:
9599

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

112117
</div>
113118

@@ -116,11 +121,12 @@ To <dfn for="file entry/lock">release</dfn> a [=file entry/lock=] on a given [=f
116121
run these steps:
117122

118123
1. Let |lock| be the |file|'s associated [=file entry/lock=].
119-
1. Let |count| be the |file|'s [=file entry/shared lock count=].
120-
1. If |lock| is "`taken-shared`":
121-
1. Decrease |count| by one.
122-
1. If |count| is 0, set |lock| to "`open`".
123-
1. Otherwise, set |lock| to "`open`".
124+
1. [=Enqueue the following steps=] to the [=file system lock queue=]:
125+
1. Let |count| be the |file|'s [=file entry/shared lock count=].
126+
1. If |lock| is "`taken-shared`":
127+
1. Decrease |count| by one.
128+
1. If |count| is 0, set |lock| to "`open`".
129+
1. Otherwise, set |lock| to "`open`".
124130

125131
</div>
126132

0 commit comments

Comments
 (0)