Skip to content

Commit a873a86

Browse files
committed
Handle spurious wakeups
1 parent ce062c8 commit a873a86

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/run/lazy-impl.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* if CAS(_x, null, Evaluating) then
3333
* var result = rhs
3434
* // if result == null then result == NULL
35-
* if !CAS(x, Evaluating, result) then
35+
* if !CAS(_x, Evaluating, result) then
3636
* val lock = _x.asInstanceOf[Waiting]
3737
* _x = result
3838
* lock.release(result)
@@ -60,7 +60,7 @@
6060
* notifyAll()
6161
*
6262
* def awaitRelease(): AnyRef = synchronized:
63-
* if !done then wait()
63+
* while !done do wait()
6464
* result
6565
*
6666
* Note 2: The code assumes that the getter result type `A` is disjoint from the type
@@ -189,7 +189,7 @@ class Waiting extends LazyControl {
189189
}
190190

191191
def awaitRelease(): AnyRef = synchronized {
192-
if (!done) wait()
192+
while (!done) wait()
193193
result
194194
}
195195
}

0 commit comments

Comments
 (0)