Do not require freezing for Worker.executeAfter on experimental MM
This commit is contained in:
committed by
Space
parent
16e9c74523
commit
cc71069a3a
@@ -949,7 +949,11 @@ task worker8(type: KonanLocalTest) {
|
|||||||
|
|
||||||
task worker9(type: KonanLocalTest) {
|
task worker9(type: KonanLocalTest) {
|
||||||
enabled = (project.testTarget != 'wasm32') // Workers need pthreads.
|
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"
|
source = "runtime/workers/worker9.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,9 +43,15 @@ fun withLock(op: () -> Unit) {
|
|||||||
|
|
||||||
@Test fun runTest3() {
|
@Test fun runTest3() {
|
||||||
val worker = Worker.start()
|
val worker = Worker.start()
|
||||||
assertFailsWith<IllegalStateException> {
|
if (Platform.memoryModel == MemoryModel.EXPERIMENTAL) {
|
||||||
worker.executeAfter {
|
worker.executeAfter {
|
||||||
println("shall not happen")
|
println("unfrozen OK")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assertFailsWith<IllegalStateException> {
|
||||||
|
worker.executeAfter {
|
||||||
|
println("shall not happen")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertFailsWith<IllegalArgumentException> {
|
assertFailsWith<IllegalArgumentException> {
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public inline class Worker @PublishedApi internal constructor(val id: Int) {
|
|||||||
*/
|
*/
|
||||||
public fun executeAfter(afterMicroseconds: Long = 0, operation: () -> Unit): Unit {
|
public fun executeAfter(afterMicroseconds: Long = 0, operation: () -> Unit): Unit {
|
||||||
val current = currentInternal()
|
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")
|
if (afterMicroseconds < 0) throw IllegalArgumentException("Timeout parameter must be non-negative")
|
||||||
executeAfterInternal(id, operation, afterMicroseconds)
|
executeAfterInternal(id, operation, afterMicroseconds)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user