diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2017-09-28 03:27:36 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2017-09-28 03:27:36 +0200 |
| commit | d6d9d37abf17071ff050e45ea37c693e659a4e98 (patch) | |
| tree | 248d11c478ee71a6bc47cf3f5c73870c73b4c210 /opendc-omega/src/main | |
| parent | 23a476613b000bf04194ec2962d270fa3cabfc5d (diff) | |
Implement JPA integration
Diffstat (limited to 'opendc-omega/src/main')
| -rw-r--r-- | opendc-omega/src/main/kotlin/nl/atlarge/opendc/kernel/omega/OmegaSimulation.kt | 17 |
1 files changed, 7 insertions, 10 deletions
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 @@ -71,6 +71,13 @@ internal class OmegaSimulation(override val kernel: OmegaKernel, override val to private val queue: Queue<MessageContainer> = 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 <E : Entity<S>, S> E.state: S + get() = (resolve(this) as OmegaContext<E, S>?)?.state ?: initialState + + /** * Initialise the simulator. */ init { @@ -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<Any>) { 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) |
