diff --git a/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/Freezer.kt b/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/Freezer.kt new file mode 100644 index 00000000..7d9a7afd --- /dev/null +++ b/common/src/commonMain/kotlin/net/dankito/utils/multiplatform/Freezer.kt @@ -0,0 +1,14 @@ +package net.dankito.utils.multiplatform + + +expect class Freezer() { + + companion object { + + fun freeze(obj: T): T + + fun isFrozen(obj: Any): Boolean + + } + +} \ No newline at end of file diff --git a/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/Freezer.kt b/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/Freezer.kt new file mode 100644 index 00000000..c7edba73 --- /dev/null +++ b/common/src/iosMain/kotlin/net/dankito/utils/multiplatform/Freezer.kt @@ -0,0 +1,21 @@ +package net.dankito.utils.multiplatform + +import kotlin.native.concurrent.freeze +import kotlin.native.concurrent.isFrozen + + +actual class Freezer { + + actual companion object { + + actual fun freeze(obj: T): T { + return obj.freeze() + } + + actual fun isFrozen(obj: Any): Boolean { + return obj.isFrozen + } + + } + +} \ No newline at end of file diff --git a/common/src/jvmMain/kotlin/net/dankito/utils/multiplatform/Freezer.kt b/common/src/jvmMain/kotlin/net/dankito/utils/multiplatform/Freezer.kt new file mode 100644 index 00000000..72c52a04 --- /dev/null +++ b/common/src/jvmMain/kotlin/net/dankito/utils/multiplatform/Freezer.kt @@ -0,0 +1,18 @@ +package net.dankito.utils.multiplatform + + +actual class Freezer { + + actual companion object { + + actual fun freeze(obj: T): T { + return obj // no op + } + + actual fun isFrozen(obj: Any): Boolean { + return false // freezing is only possible on Kotlin/Native + } + + } + +} \ No newline at end of file