diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 6c62ea19a7a..a5457198e10 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -949,7 +949,11 @@ task worker8(type: KonanLocalTest) { task worker9(type: KonanLocalTest) { enabled = (project.testTarget != 'wasm32') // Workers need pthreads. - goldValue = "zzz\n42\nOK\nfirst 2\nsecond 3\nfrozen OK\n" + if (isExperimentalMM) { + goldValue = "zzz\n42\nOK\nfirst 2\nsecond 3\nunfrozen OK\nfrozen OK\n" + } else { + goldValue = "zzz\n42\nOK\nfirst 2\nsecond 3\nfrozen OK\n" + } source = "runtime/workers/worker9.kt" } diff --git a/kotlin-native/backend.native/tests/runtime/workers/worker9.kt b/kotlin-native/backend.native/tests/runtime/workers/worker9.kt index 247780f5e8a..930b851d95d 100644 --- a/kotlin-native/backend.native/tests/runtime/workers/worker9.kt +++ b/kotlin-native/backend.native/tests/runtime/workers/worker9.kt @@ -43,9 +43,15 @@ fun withLock(op: () -> Unit) { @Test fun runTest3() { val worker = Worker.start() - assertFailsWith { + if (Platform.memoryModel == MemoryModel.EXPERIMENTAL) { worker.executeAfter { - println("shall not happen") + println("unfrozen OK") + } + } else { + assertFailsWith { + worker.executeAfter { + println("shall not happen") + } } } assertFailsWith { @@ -81,4 +87,4 @@ fun makeCyclic(): Node { } assert(future.result != null) worker.requestTermination().result -} \ No newline at end of file +} diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Worker.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Worker.kt index 0ff76764566..dd35d614c8c 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Worker.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Worker.kt @@ -106,7 +106,7 @@ public inline class Worker @PublishedApi internal constructor(val id: Int) { */ public fun executeAfter(afterMicroseconds: Long = 0, operation: () -> Unit): Unit { val current = currentInternal() - if (current != id && !operation.isFrozen) throw IllegalStateException("Job for another worker must be frozen") + if (Platform.memoryModel != MemoryModel.EXPERIMENTAL && current != id && !operation.isFrozen) throw IllegalStateException("Job for another worker must be frozen") if (afterMicroseconds < 0) throw IllegalArgumentException("Timeout parameter must be non-negative") executeAfterInternal(id, operation, afterMicroseconds) } @@ -187,4 +187,4 @@ public inline fun withWorker(name: String? = null, errorReporting: Boolean = } finally { worker.requestTermination().result } -} \ No newline at end of file +}