summaryrefslogtreecommitdiff
path: root/opendc-common/src/test/kotlin/org/opendc/common/util/PacerTest.kt
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-10-05 14:44:43 +0200
committerGitHub <noreply@github.com>2022-10-05 14:44:43 +0200
commitc2047d09b27b0c05f5c203509dde524e17d3b729 (patch)
tree3903d8aed5e87850c92e1b2dce8379ea99bdfa6d /opendc-common/src/test/kotlin/org/opendc/common/util/PacerTest.kt
parentec3b5b462c1b8296ba18a3872f56d569fa70e45b (diff)
parentbe176910eb870209576326ffaad8bf21241fccbd (diff)
merge: Extract scheduler from simulation coroutine dispatcher (#106)
This pull request extracts the scheduler from the `SimulationCoroutineDispatcher` into a separate `SimulationScheduler` class which allows users to re-use the scheduler between different coroutine dispatchers. We implement the `SimulationScheduler` in Java, removing the explicit dependency on Kotlin or `kotlinx-coroutines`. The scheduler uses a separate specialized priority queue implementation that eliminates allocation in the hot path of the simulator. ## Implementation Notes :hammer_and_pick: * Add Java-based simulator core * Use SimulationScheduler in coroutine dispatcher * Rename runBlockingSimulation to runSimulation ## External Dependencies :four_leaf_clover: * N/A ## Breaking API Changes :warning: * The Kotlin API for simulation has been moved to `org.opendc.simulator.kotlin`. * `runBlockingSImulation` renamed to `runSimulation`
Diffstat (limited to 'opendc-common/src/test/kotlin/org/opendc/common/util/PacerTest.kt')
-rw-r--r--opendc-common/src/test/kotlin/org/opendc/common/util/PacerTest.kt12
1 files changed, 6 insertions, 6 deletions
diff --git a/opendc-common/src/test/kotlin/org/opendc/common/util/PacerTest.kt b/opendc-common/src/test/kotlin/org/opendc/common/util/PacerTest.kt
index 1cd435f6..de9fd472 100644
--- a/opendc-common/src/test/kotlin/org/opendc/common/util/PacerTest.kt
+++ b/opendc-common/src/test/kotlin/org/opendc/common/util/PacerTest.kt
@@ -26,7 +26,7 @@ import kotlinx.coroutines.delay
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
-import org.opendc.simulator.core.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
import java.time.Clock
import kotlin.coroutines.EmptyCoroutineContext
@@ -43,7 +43,7 @@ class PacerTest {
fun testSingleEnqueue() {
var count = 0
- runBlockingSimulation {
+ runSimulation {
val pacer = Pacer(coroutineContext, clock, quantum = 100) {
count++
}
@@ -58,7 +58,7 @@ class PacerTest {
fun testCascade() {
var count = 0
- runBlockingSimulation {
+ runSimulation {
val pacer = Pacer(coroutineContext, clock, quantum = 100) {
count++
}
@@ -76,7 +76,7 @@ class PacerTest {
fun testCancel() {
var count = 0
- runBlockingSimulation {
+ runSimulation {
val pacer = Pacer(coroutineContext, clock, quantum = 100) {
count++
}
@@ -94,7 +94,7 @@ class PacerTest {
fun testCancelWithoutPending() {
var count = 0
- runBlockingSimulation {
+ runSimulation {
val pacer = Pacer(coroutineContext, clock, quantum = 100) {
count++
}
@@ -112,7 +112,7 @@ class PacerTest {
fun testSubsequent() {
var count = 0
- runBlockingSimulation {
+ runSimulation {
val pacer = Pacer(coroutineContext, clock, quantum = 100) {
count++
}