pub fn should_interrupt<S: State>(
pending_tasks: &[PendingTask<S>],
interrupt_before: &HashSet<String>,
interrupt_after: &HashSet<String>,
channel_versions: &HashMap<String, u64>,
versions_seen_for_interrupt: &HashMap<String, u64>,
) -> Option<Vec<InterruptSignal>>Expand description
Check if execution should interrupt based on the current state
Two-step check:
- Version gating: Only fire if any channel was updated since the last
interrupt (comparing
channel_versionsagainstversions_seen_for_interrupt). - Node name check: Verify that a pending task targets a node listed
in
interrupt_beforeorinterrupt_after.
The version gate prevents infinite interrupt loops after checkpoint restore when no state actually changed.
§Arguments
pending_tasks- Tasks scheduled for the next superstepinterrupt_before- Nodes that should interrupt before executioninterrupt_after- Nodes that should interrupt after executionchannel_versions- Current field version map (channel -> version)versions_seen_for_interrupt- Last-seen channel versions at the time of the previous interrupt (flat map: channel -> single version)
§Returns
Some(Vec<InterruptSignal>) if interruption is needed, None otherwise