1 /* 2 * Copyright 2016-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 import kotlinx.atomicfu.* 6 import kotlin.test.assertEquals 7 import kotlin.test.assertTrue 8 9 class IntArithmetic { 10 private val _x = atomic(0) 11 val x get() = _x.value 12 doWorknull13 fun doWork(finalValue: Int) { 14 assertEquals(0, x) 15 assertEquals(0, _x.getAndSet(3)) 16 assertEquals(3, x) 17 assertTrue(_x.compareAndSet(3, finalValue)) 18 } 19 } 20