Fix atomic value updating

This commit is contained in:
Karlatemp 2020-10-23 18:03:41 +08:00
parent 27aff26bfd
commit 4564531f8b
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8

View File

@ -182,7 +182,7 @@ internal inline fun AtomicLong.updateWhen(condition: (Long) -> Boolean, update:
while (true) {
val current = value
if (condition(current)) {
if (compareAndSet(0, update(current))) {
if (compareAndSet(current, update(current))) {
return true
} else continue
}