From 9528caf61c47680a6357631917bb00dedb11015c Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Mon, 31 Oct 2022 13:42:51 +0100 Subject: 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. --- .../src/main/java/org/opendc/simulator/flow2/FlowStage.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'opendc-simulator/opendc-simulator-flow/src') 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 @@ -151,6 +151,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. */ -- cgit v1.2.3