Avoiding double access to field in 'compareAndExchange' inline implementation
This commit is contained in:
parent
fe6d2c22ef
commit
d5ed25cb54
@ -30,13 +30,18 @@ internal actual /*value*/ class _AtomicLong {
|
|||||||
actual fun compareAndSet(expected: Long, newValue: Long): Boolean =
|
actual fun compareAndSet(expected: Long, newValue: Long): Boolean =
|
||||||
this._native.compareAndSet(expected, newValue)
|
this._native.compareAndSet(expected, newValue)
|
||||||
|
|
||||||
actual fun compareAndExchange(expected: Long, newValue: Long): Long =
|
actual fun compareAndExchange(expected: Long, newValue: Long): Long {
|
||||||
if (_Linkage._isNativeCompareAndExchangeExists) this._native.compareAndExchange(expected, newValue)
|
if (_Linkage._isNativeCompareAndExchangeExists) {
|
||||||
else _Misc._compareAndExchange(
|
return this._native.compareAndExchange(expected, newValue)
|
||||||
get = this._native::get,
|
} else {
|
||||||
cas = this._native::compareAndSet,
|
val a = this._native
|
||||||
expected = expected, newValue = newValue
|
return _Misc._compareAndExchange(
|
||||||
)
|
get = a::get,
|
||||||
|
cas = a::compareAndSet,
|
||||||
|
expected = expected, newValue = newValue
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private object _Linkage {
|
private object _Linkage {
|
||||||
@JvmField
|
@JvmField
|
||||||
|
@ -24,10 +24,12 @@ internal actual class _AtomicLong {
|
|||||||
actual fun compareAndSet(expected: Long, newValue: Long): Boolean =
|
actual fun compareAndSet(expected: Long, newValue: Long): Boolean =
|
||||||
this._atomicfu.compareAndSet(expected, newValue)
|
this._atomicfu.compareAndSet(expected, newValue)
|
||||||
|
|
||||||
actual fun compareAndExchange(expected: Long, newValue: Long): Long =
|
actual fun compareAndExchange(expected: Long, newValue: Long): Long {
|
||||||
_Misc._compareAndExchange(
|
val a = this._atomicfu
|
||||||
get = this._atomicfu::value::get,
|
return _Misc._compareAndExchange(
|
||||||
cas = this._atomicfu::compareAndSet,
|
get = a::value::get,
|
||||||
|
cas = a::compareAndSet,
|
||||||
expected = expected, newValue = newValue
|
expected = expected, newValue = newValue
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user