Skip to content

Commit a89e220

Browse files
yield in spinLock unhappy path
1 parent 2921d8c commit a89e220

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

System/Metrics/Distribution.hsc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ add distrib val = addN distrib val 1
204204
spinLock :: MutableByteArray## RealWorld -> State## RealWorld -> State## RealWorld
205205
spinLock mba = \s ->
206206
case casIntArray## mba (unI lockPos) 0## 1## s of { (## s1, r ##) ->
207-
case r ==## 0## of { 0## ->
208-
spinLock mba s1; _ -> s1 }}
207+
case r of { 0## -> s1; _ ->
208+
case yield## s1 of { s2 ->
209+
spinLock mba s2 }}}
209210

210211
{-# INLINE spinUnlock #-}
211212
spinUnlock :: MutableByteArray## RealWorld -> State## RealWorld -> State## RealWorld

0 commit comments

Comments
 (0)