summaryrefslogtreecommitdiff
path: root/simulator/opendc-simulator
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-15 14:13:14 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-15 14:25:24 +0200
commite68046465d39611259fa13952add731e80ea7331 (patch)
treea5c74ae02a812e050f4feec778f274705ce66076 /simulator/opendc-simulator
parent288c6c18c24b27dee230d31f0dd036b199722302 (diff)
exp: Prevent re-use of SimWorkload in experiment
This change fixes and issue where a SimWorkload was being re-used across simulation runs. Given that SimWorkload is stateless, this may cause strange issues.
Diffstat (limited to 'simulator/opendc-simulator')
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt4
1 files changed, 3 insertions, 1 deletions
diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
index 694a928b..ffb332d1 100644
--- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
+++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
@@ -34,12 +34,14 @@ import org.opendc.simulator.resources.consumer.SimConsumerBarrier
* consumption for some period of time.
*/
public class SimTraceWorkload(public val trace: Sequence<Fragment>) : SimWorkload {
- private var offset = 0L
+ private var offset = Long.MIN_VALUE
private val iterator = trace.iterator()
private var fragment: Fragment? = null
private lateinit var barrier: SimConsumerBarrier
override fun onStart(ctx: SimMachineContext) {
+ check(offset == Long.MIN_VALUE) { "Workload does not support re-use" }
+
barrier = SimConsumerBarrier(ctx.cpus.size)
fragment = nextFragment()
offset = ctx.clock.millis()