summaryrefslogtreecommitdiff
path: root/opendc-experiments
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-30 14:45:42 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-03 17:17:40 +0200
commit4f5a1f88d0c6aa19ce4cab0ec7b9b13a24c92fbe (patch)
tree3b3566e70fa3aa43f31a4b51e52263ec98d4e694 /opendc-experiments
parentb0fc93f818e5e735e972a04f5aa49e0ebe1de181 (diff)
refactor(simulator): Remove capacity event
This change removes the Capacity entry from FlowEvent. Since the source is always pulled on a capacity change, we do not need a separate event for this.
Diffstat (limited to 'opendc-experiments')
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt10
1 files changed, 4 insertions, 6 deletions
diff --git a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt
index 2ba65e90..6f460ef7 100644
--- a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt
+++ b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt
@@ -131,6 +131,8 @@ public class SimTFDevice(
override fun onPull(conn: FlowConnection, now: Long, delta: Long): Long {
val consumedWork = conn.rate * delta / 1000.0
+ capacity = conn.capacity
+
val activeWork = activeWork
if (activeWork != null) {
if (activeWork.consume(consumedWork)) {
@@ -158,12 +160,8 @@ public class SimTFDevice(
override fun onEvent(conn: FlowConnection, now: Long, event: FlowEvent) {
when (event) {
FlowEvent.Start -> {
- this.ctx = conn
- this.capacity = conn.capacity
- }
- FlowEvent.Capacity -> {
- this.capacity = conn.capacity
- conn.pull()
+ ctx = conn
+ capacity = conn.capacity
}
FlowEvent.Converge -> {
_usage.record(conn.rate)