From d6d9d37abf17071ff050e45ea37c693e659a4e98 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 28 Sep 2017 03:27:36 +0200 Subject: Implement JPA integration --- .../nl/atlarge/opendc/kernel/omega/OmegaSimulation.kt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'opendc-omega/src/main') diff --git a/opendc-omega/src/main/kotlin/nl/atlarge/opendc/kernel/omega/OmegaSimulation.kt b/opendc-omega/src/main/kotlin/nl/atlarge/opendc/kernel/omega/OmegaSimulation.kt index e3477d3e..caaa335b 100644 --- a/opendc-omega/src/main/kotlin/nl/atlarge/opendc/kernel/omega/OmegaSimulation.kt +++ b/opendc-omega/src/main/kotlin/nl/atlarge/opendc/kernel/omega/OmegaSimulation.kt @@ -70,6 +70,13 @@ internal class OmegaSimulation(override val kernel: OmegaKernel, override val to */ private val queue: Queue = PriorityQueue(Comparator.comparingLong(MessageContainer::time)) + /** + * The observable state of an [Entity] in simulation, which is provided by the simulation context. + */ + @Suppress("UNCHECKED_CAST") + override val , S> E.state: S + get() = (resolve(this) as OmegaContext?)?.state ?: initialState + /** * Initialise the simulator. */ @@ -334,12 +341,7 @@ internal class OmegaSimulation(override val kernel: OmegaKernel, override val to */ suspend override fun wait(duration: Duration) { require(duration >= 0) { "The amount of time to suspend must be a positive number" } - - if (duration == 0.toLong()) - return - schedule(Resume, entity, entity, duration) - while (true) { if (receive() is Resume) return @@ -358,12 +360,7 @@ internal class OmegaSimulation(override val kernel: OmegaKernel, override val to */ suspend override fun wait(duration: Duration, queue: Queue) { require(duration >= 0) { "The amount of time to suspend must be a positive number" } - - if (duration == 0.toLong()) - return - schedule(Resume, entity, entity, duration) - while (true) { val msg = receive() if (msg is Resume) -- cgit v1.2.3