summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-flow
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-10-31 13:42:51 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-10-31 13:42:51 +0100
commit9528caf61c47680a6357631917bb00dedb11015c (patch)
treec8a58137d081a470fcb8af01ccae5914572052cd /opendc-simulator/opendc-simulator-flow
parentb96acc687f59b698fbc4d4c984d77b008cd4051b (diff)
feat(sim/flow): Support synchronous update of FlowStage
This change adds a new method to `FlowStage` called `sync()` which enables users to synchronously update the stage at the current timestamp. This functionality is neccessary to support snapshotting since we need to synchronize the state of the `FlowStage` before creating a snapshot of the workload.
Diffstat (limited to 'opendc-simulator/opendc-simulator-flow')
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/flow2/FlowStage.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/flow2/FlowStage.java b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/flow2/FlowStage.java
index 4d098043..ed5579ea 100644
--- a/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/flow2/FlowStage.java
+++ b/opendc-simulator/opendc-simulator-flow/src/main/java/org/opendc/simulator/flow2/FlowStage.java
@@ -152,6 +152,15 @@ public final class FlowStage {
}
/**
+ * Synchronously update the {@link FlowStage} at the current timestamp.
+ */
+ public void sync() {
+ this.flags |= STAGE_INVALIDATE;
+ onUpdate(clock.millis());
+ engine.scheduleDelayed(this);
+ }
+
+ /**
* Close the {@link FlowStage} and disconnect all inlets and outlets.
*/
public void close() {