summaryrefslogtreecommitdiff
path: root/simulator/opendc-simulator/opendc-simulator-core
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-21 16:35:52 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-21 16:37:18 +0200
commit62678b2890a7f3640836b99ca2fec9efd7485929 (patch)
treedc6d6e8bb495c019990513511d7ff042afde0f05 /simulator/opendc-simulator/opendc-simulator-core
parent1c0568c31d60d4e690b4b9aec2e14f660b72a5c8 (diff)
simulator: Migrate to SimulationCoroutineDispatcher
This change migrates the remainder of the codebase to the SimulationCoroutineDispatcher implementation.
Diffstat (limited to 'simulator/opendc-simulator/opendc-simulator-core')
-rw-r--r--simulator/opendc-simulator/opendc-simulator-core/build.gradle.kts2
-rw-r--r--simulator/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/core/DelayControllerClockAdapter.kt46
2 files changed, 1 insertions, 47 deletions
diff --git a/simulator/opendc-simulator/opendc-simulator-core/build.gradle.kts b/simulator/opendc-simulator/opendc-simulator-core/build.gradle.kts
index 309afb19..3ba0d8c3 100644
--- a/simulator/opendc-simulator/opendc-simulator-core/build.gradle.kts
+++ b/simulator/opendc-simulator/opendc-simulator-core/build.gradle.kts
@@ -29,5 +29,5 @@ plugins {
dependencies {
api(platform(project(":opendc-platform")))
- api("org.jetbrains.kotlinx:kotlinx-coroutines-test")
+ api("org.jetbrains.kotlinx:kotlinx-coroutines-core")
}
diff --git a/simulator/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/core/DelayControllerClockAdapter.kt b/simulator/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/core/DelayControllerClockAdapter.kt
deleted file mode 100644
index a81a16e3..00000000
--- a/simulator/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/core/DelayControllerClockAdapter.kt
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2020 AtLarge Research
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package org.opendc.simulator.core
-
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.test.DelayController
-import java.time.Clock
-import java.time.Instant
-import java.time.ZoneId
-
-/**
- * A virtual [Clock] that abstracts accesses to [DelayController]'s virtual clock.
- */
-@OptIn(ExperimentalCoroutinesApi::class)
-public class DelayControllerClockAdapter(
- private val delayController: DelayController,
- private val zone: ZoneId = ZoneId.systemDefault()
-) : Clock() {
- override fun getZone(): ZoneId = zone
-
- override fun withZone(zone: ZoneId): Clock = DelayControllerClockAdapter(delayController, zone)
-
- override fun instant(): Instant = Instant.ofEpochMilli(millis())
-
- override fun millis(): Long = delayController.currentTime
-}