From 5864cbcbfe2eb8c36ca05c3a39c7e5916aeecaec Mon Sep 17 00:00:00 2001 From: Dante Niewenhuis Date: Tue, 5 Mar 2024 13:23:57 +0100 Subject: Updated package versions, updated web server tests. (#207) * Updated all package versions including kotlin. Updated all web-server tests to run. * Changed the java version of the tests. OpenDC now only supports java 19. * small update * test update * new update * updated docker version to 19 * updated docker version to 19 --- .../org/opendc/simulator/kotlin/SimulationBuilders.kt | 16 +++++++++------- .../opendc/simulator/kotlin/SimulationCoroutineScope.kt | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'opendc-simulator/opendc-simulator-core/src/main') diff --git a/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt b/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt index 271b89e0..bc232ce0 100644 --- a/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt +++ b/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationBuilders.kt @@ -66,14 +66,15 @@ import kotlin.coroutines.EmptyCoroutineContext public fun runSimulation( context: CoroutineContext = EmptyCoroutineContext, scheduler: SimulationDispatcher = SimulationDispatcher(), - body: suspend SimulationCoroutineScope.() -> Unit + body: suspend SimulationCoroutineScope.() -> Unit, ) { val (safeContext, job, dispatcher) = context.checkArguments(scheduler) val startingJobs = job.activeJobs() val scope = SimulationCoroutineScope(safeContext) - val deferred = scope.async { - body(scope) - } + val deferred = + scope.async { + body(scope) + } dispatcher.advanceUntilIdle() deferred.getCompletionExceptionOrNull()?.let { throw it @@ -105,9 +106,10 @@ private fun Job.activeJobs(): Set { * Convert a [ContinuationInterceptor] into a [SimulationDispatcher] if possible. */ internal fun ContinuationInterceptor.asSimulationDispatcher(): SimulationDispatcher { - val provider = this as? DispatcherProvider ?: throw IllegalArgumentException( - "DispatcherProvider such as SimulatorCoroutineDispatcher as the ContinuationInterceptor(Dispatcher) is required" - ) + val provider = + this as? DispatcherProvider ?: throw IllegalArgumentException( + "DispatcherProvider such as SimulatorCoroutineDispatcher as the ContinuationInterceptor(Dispatcher) is required", + ) return provider.dispatcher as? SimulationDispatcher ?: throw IllegalArgumentException("Active dispatcher is not a SimulationDispatcher") } diff --git a/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationCoroutineScope.kt b/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationCoroutineScope.kt index ca49fc53..a29e9404 100644 --- a/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationCoroutineScope.kt +++ b/opendc-simulator/opendc-simulator-core/src/main/kotlin/org/opendc/simulator/kotlin/SimulationCoroutineScope.kt @@ -43,7 +43,7 @@ public interface SimulationCoroutineScope : CoroutineScope, SimulationController */ public fun SimulationCoroutineScope( context: CoroutineContext = EmptyCoroutineContext, - scheduler: SimulationDispatcher = SimulationDispatcher() + scheduler: SimulationDispatcher = SimulationDispatcher(), ): SimulationCoroutineScope { var safeContext = context val simulationDispatcher: SimulationDispatcher -- cgit v1.2.3