[K/N] Worker API improvements ^KT-52429
Merge-request: KT-MR-6898 Merged-by: Alexander Shabalin <Alexander.Shabalin@jetbrains.com>
This commit is contained in:
committed by
Space
parent
6e2202ad5a
commit
6f844f15e0
@@ -0,0 +1,38 @@
|
||||
@file:OptIn(kotlin.ExperimentalStdlibApi::class)
|
||||
|
||||
package runtime.workers.worker_list_workers
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
import kotlin.test.*
|
||||
|
||||
const val WORKER_COUNT = 10
|
||||
|
||||
@Test
|
||||
fun getAllWorkers() {
|
||||
val workers = Array(WORKER_COUNT) { Worker.start() }
|
||||
|
||||
val expectedWorkers = listOf(Worker.current) + workers
|
||||
|
||||
assertEquals(expectedWorkers.toSet(), Worker.activeWorkers.toSet())
|
||||
|
||||
workers.forEach {
|
||||
it.requestTermination().result
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getActiveWorkers() {
|
||||
val workers = Array(WORKER_COUNT) { Worker.start() }
|
||||
|
||||
val expectedWorkers = mutableListOf(Worker.current)
|
||||
(0 until WORKER_COUNT step 2).forEach { i ->
|
||||
workers[i].requestTermination().result
|
||||
expectedWorkers.add(workers[i + 1])
|
||||
}
|
||||
|
||||
assertEquals(expectedWorkers.toSet(), Worker.activeWorkers.toSet())
|
||||
|
||||
(0 until WORKER_COUNT step 2).forEach { i ->
|
||||
workers[i + 1].requestTermination().result
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user