Merge "A couple more runtime expect/actuals in anticipation of mpp targets" into androidx-main
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Expect.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Expect.kt
index 0b6c7e6..a7fff6e 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Expect.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Expect.kt
@@ -22,6 +22,7 @@
 internal expect open class ThreadLocal<T>(initialValue: () -> T) {
     fun get(): T
     fun set(value: T)
+    fun remove()
 }
 
 internal fun <T> ThreadLocal() = ThreadLocal<T?> { null }
@@ -67,6 +68,16 @@
     fun compareAndSet(expect: V, newValue: V): Boolean
 }
 
+internal expect class AtomicInt(value: Int) {
+    fun get(): Int
+    fun set(value: Int)
+    fun add(amount: Int): Int
+}
+
+internal fun AtomicInt.postIncrement(): Int = add(1) - 1
+
+internal expect fun ensureMutable(it: Any)
+
 @MustBeDocumented
 @Retention(AnnotationRetention.SOURCE)
 @Target(
diff --git a/compose/runtime/runtime/src/jvmMain/kotlin/androidx/compose/runtime/ActualJvm.jvm.kt b/compose/runtime/runtime/src/jvmMain/kotlin/androidx/compose/runtime/ActualJvm.jvm.kt
index fad7ebf..31f8ed3 100644
--- a/compose/runtime/runtime/src/jvmMain/kotlin/androidx/compose/runtime/ActualJvm.jvm.kt
+++ b/compose/runtime/runtime/src/jvmMain/kotlin/androidx/compose/runtime/ActualJvm.jvm.kt
@@ -36,6 +36,10 @@
     override fun initialValue(): T? {
         return initialValue.invoke()
     }
+
+    actual override fun remove() {
+        super.remove()
+    }
 }
 
 internal actual class SnapshotThreadLocal<T> {
@@ -78,3 +82,12 @@
     val realFn = composable as Function2<Composer, Int, T>
     return realFn(composer, 1)
 }
+
+internal actual class AtomicInt actual constructor(value: Int) {
+    val delegate = java.util.concurrent.atomic.AtomicInteger(value)
+    actual fun get(): Int = delegate.get()
+    actual fun set(value: Int) = delegate.set(value)
+    actual fun add(amount: Int): Int = delegate.addAndGet(amount)
+}
+
+internal actual fun ensureMutable(it: Any) { /* NOTHING */ }