From c41d201343263346ac84855a0b2254051ed33c21 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Wed, 30 Sep 2020 21:14:20 +0200 Subject: Eliminate use of Domain and simulationContext in OpenDC This change takes the first step in eliminating the explict use of Domain and simulationContext from OpenDC. In this way, we decouple the logic of various datacenter services from simulation logic, which should promote re-use. --- .../odcsim/engine/omega/OmegaSimulationEngine.kt | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'simulator/odcsim/odcsim-engine-omega/src') diff --git a/simulator/odcsim/odcsim-engine-omega/src/main/kotlin/com/atlarge/odcsim/engine/omega/OmegaSimulationEngine.kt b/simulator/odcsim/odcsim-engine-omega/src/main/kotlin/com/atlarge/odcsim/engine/omega/OmegaSimulationEngine.kt index e675b877..e4d0f4ac 100644 --- a/simulator/odcsim/odcsim-engine-omega/src/main/kotlin/com/atlarge/odcsim/engine/omega/OmegaSimulationEngine.kt +++ b/simulator/odcsim/odcsim-engine-omega/src/main/kotlin/com/atlarge/odcsim/engine/omega/OmegaSimulationEngine.kt @@ -28,13 +28,6 @@ import com.atlarge.odcsim.Domain import com.atlarge.odcsim.SimulationContext import com.atlarge.odcsim.SimulationEngine import com.atlarge.odcsim.engine.omega.logging.LoggerImpl -import java.time.Clock -import java.time.Instant -import java.time.ZoneId -import java.util.PriorityQueue -import java.util.UUID -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.coroutineContext import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineExceptionHandler @@ -48,6 +41,13 @@ import kotlinx.coroutines.Runnable import kotlinx.coroutines.SupervisorJob import org.jetbrains.annotations.Async import org.slf4j.Logger +import java.time.Clock +import java.time.Instant +import java.time.ZoneId +import java.util.PriorityQueue +import java.util.UUID +import kotlin.coroutines.CoroutineContext +import kotlin.coroutines.coroutineContext /** * The reference implementation of the [SimulationEngine] instance for the OpenDC simulation core. @@ -71,12 +71,14 @@ public class OmegaSimulationEngine(override val name: String) : SimulationEngine /** * The event queue to process */ - private val queue: PriorityQueue = PriorityQueue(Comparator { lhs, rhs -> - // Note that Comparator gives better performance than Comparable according to - // profiling - val cmp = lhs.time.compareTo(rhs.time) - if (cmp == 0) lhs.id.compareTo(rhs.id) else cmp - }) + private val queue: PriorityQueue = PriorityQueue( + Comparator { lhs, rhs -> + // Note that Comparator gives better performance than Comparable according to +// profiling + val cmp = lhs.time.compareTo(rhs.time) + if (cmp == 0) lhs.id.compareTo(rhs.id) else cmp + } + ) /** * The active processes in the simulation engine. -- cgit v1.2.3