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
}
}
On JVM the
AtomicReference
class 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
UnaryOperator
is a functional interface:That should place nicely with the SAM conversion
The text was updated successfully, but these errors were encountered: