You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On JVM the AtomicReference class contains the getAndUpdate() method. It'd be convenient to have it for other targets/common code as well. The non-JVM implementation can look like:
fungetAndUpdate(updateFunction: (V) ->V): V {
while(true) {
val prev = get()
val next = updateFunction(prev)
if (compareAndSet(prev, next)) return prev
}
}
This discussion was converted from issue #91 on August 07, 2026 19:05.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
On JVM the
AtomicReferenceclass contains thegetAndUpdate()method. It'd be convenient to have it for other targets/common code as well. The non-JVM implementation can look like:The signature of the corresponding JVM method is:
where
UnaryOperatoris a functional interface:That should place nicely with the SAM conversion
All reactions