[K/N] Stabilization of Atomics API
`AtomicInt`, `AtomicLong`, `AtomicReference` and `AtomicNativePtr` classes were moved to `kotlin.concurrent` package. The corresponding classes from `kotlin.native.concurrent` were deprecated with warning since Kotlin 1.9.
In order to prepare for further commonization of Atomics API the following changes were made:
* `kotlin.concurrent.AtomicInt`:
* `increment(): Unit` and `decrement(): Unit` methods were deprecated with error
* New methods were added: `incrementAndGet(): Int` , `decrementAndGet(): Int`, `getAndIncrement(): Int`, `getAndDecrement(): Int`, `getAndSet(newValue: Int): Int`
* `kotlin.concurrent.AtomicLong`:
* `increment(): Unit` and `decrement(): Unit` methods were deprecated with error
* New methods were added: `incrementAndGet(): Long`, `decrementAndGet(): Long`, `getAndIncrement(): Long`, `getAndDecrement(): Long`, `getAndSet(newValue: Long): Long`
* Deprecated `AtomicLong()` constructor with default parameter value
* For all atomic classes `compareAndSwap` method was renamed to `compareAndExchange`
See KT-58074 for more details.
Merge-request: KT-MR-9272
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
This commit is contained in:
@@ -35,8 +35,8 @@ val c = "3"
|
||||
fun box() : String {
|
||||
if (::x.compareAndSetField(1, 2) != true) return "FAIL Int: 1"
|
||||
if (::x.compareAndSetField(1, 2) != false) return "FAIL Int: 2"
|
||||
if (::x.compareAndSwapField(2, 1) != 2) return "FAIL Int: 3"
|
||||
if (::x.compareAndSwapField(2, 1) != 1) return "FAIL Int: 4"
|
||||
if (::x.compareAndExchangeField(2, 1) != 2) return "FAIL Int: 3"
|
||||
if (::x.compareAndExchangeField(2, 1) != 1) return "FAIL Int: 4"
|
||||
if (::x.getAndSetField(3) != 1) return "FAIL Int: 5"
|
||||
if (::x.getAndSetField(1) != 3) return "FAIL Int: 6"
|
||||
if (::x.getAndAddFieldLocal(1) != 1) return "FAIL Int: 7"
|
||||
@@ -45,8 +45,8 @@ fun box() : String {
|
||||
|
||||
if (::y.compareAndSetField(1L, 2L) != true) return "FAIL Long: 1"
|
||||
if (::y.compareAndSetField(1L, 2L) != false) return "FAIL Long: 2"
|
||||
if (::y.compareAndSwapField(2L, 1L) != 2L) return "FAIL Long: 3"
|
||||
if (::y.compareAndSwapField(2L, 1L) != 1L) return "FAIL Long: 4"
|
||||
if (::y.compareAndExchangeField(2L, 1L) != 2L) return "FAIL Long: 3"
|
||||
if (::y.compareAndExchangeField(2L, 1L) != 1L) return "FAIL Long: 4"
|
||||
if (::y.getAndSetField(3L) != 1L) return "FAIL Long: 5"
|
||||
if (::y.getAndSetField(1L) != 3L) return "FAIL Long: 6"
|
||||
if (::y.getAndAddFieldLocal(1L) != 1L) return "FAIL Long: 7"
|
||||
@@ -57,8 +57,8 @@ fun box() : String {
|
||||
if (isExperimentalMM()) {
|
||||
if (::z.compareAndSetField(a, b) != true) return "FAIL String: 1"
|
||||
if (::z.compareAndSetField(a, b) != false) return "FAIL String: 2"
|
||||
if (::z.compareAndSwapField(b, a) != b) return "FAIL String: 3"
|
||||
if (::z.compareAndSwapField(b, a) != a) return "FAIL String: 4"
|
||||
if (::z.compareAndExchangeField(b, a) != b) return "FAIL String: 3"
|
||||
if (::z.compareAndExchangeField(b, a) != a) return "FAIL String: 4"
|
||||
if (::z.getAndSetField(c) != a) return "FAIL String: 5"
|
||||
if (::z.getAndSetField(a) != c) return "FAIL String: 6"
|
||||
if (z != a) return "FAIL String: 7"
|
||||
@@ -66,8 +66,8 @@ fun box() : String {
|
||||
|
||||
if (::t.compareAndSetField(true, false) != true) return "FAIL Bool: 1"
|
||||
if (::t.compareAndSetField(true, false) != false) return "FAIL Bool: 2"
|
||||
if (::t.compareAndSwapField(false, true) != false) return "FAIL Bool: 3"
|
||||
if (::t.compareAndSwapField(false, true) != true) return "FAIL Bool: 4"
|
||||
if (::t.compareAndExchangeField(false, true) != false) return "FAIL Bool: 3"
|
||||
if (::t.compareAndExchangeField(false, true) != true) return "FAIL Bool: 4"
|
||||
if (::t.getAndSetField(false) != true) return "FAIL Bool: 5"
|
||||
if (::t.getAndSetField(true) != false) return "FAIL Bool: 6"
|
||||
if (t != true) return "FAIL Bool: 7"
|
||||
|
||||
Reference in New Issue
Block a user