Skip to main content

should_interrupt

Function should_interrupt 

Source
pub fn should_interrupt<S>(
    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>>
where S: State,
Expand description

Check if execution should interrupt based on the current state

Two-step check:

  1. Version gating: Only fire if any channel was updated since the last interrupt (comparing channel_versions against versions_seen_for_interrupt).
  2. Node name check: Verify that a pending task targets a node listed in interrupt_before or interrupt_after.

The version gate prevents infinite interrupt loops after checkpoint restore when no state actually changed.

§Arguments

  • pending_tasks - Tasks scheduled for the next superstep
  • interrupt_before - Nodes that should interrupt before execution
  • interrupt_after - Nodes that should interrupt after execution
  • channel_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