An interleaved replay has one global order while each event still belongs to an owner. This program summarizes the ordered prefix.

Program

Play the program to choose a maximum step and watch owner totals accumulate in order.

max_step
interleaved_owner_summary_rust.rs
Replay: real traced execution (multi-file project)
fn main() {
    let max_step: usize = 3;
    let owners = ["main", "worker", "main", "worker"];
    let deltas = [1, 2, 3, 4];
    let mut main_total = 0;
    let mut worker_total = 0;
    for i in 0..max_step {
        if owners[i] == "main" {
            main_total += deltas[i];
        } else {
            worker_total += deltas[i];
        }
    }
    println!("{main_total}:{worker_total}");
}
fn main() {
    let max_step: usize = 2;
    let owners = ["main", "worker", "main", "worker"];
    let deltas = [1, 2, 3, 4];
    let mut main_total = 0;
    let mut worker_total = 0;
    for i in 0..max_step {
        if owners[i] == "main" {
            main_total += deltas[i];
        } else {
            worker_total += deltas[i];
        }
    }
    println!("{main_total}:{worker_total}");
}
fn main() {
    let max_step: usize = 4;
    let owners = ["main", "worker", "main", "worker"];
    let deltas = [1, 2, 3, 4];
    let mut main_total = 0;
    let mut worker_total = 0;
    for i in 0..max_step {
        if owners[i] == "main" {
            main_total += deltas[i];
        } else {
            worker_total += deltas[i];
        }
    }
    println!("{main_total}:{worker_total}");
}
  1. max_step ← 3, owners ← ["main", "worker", "main", "worker"], deltas ← [1, 2, 3, 4]

    1fn main() {2    let max_ste→ 3p: usize = 3; //@max_step=2, 3, 43    let owner→ ["main", "worker", "main", "worker"]s = ["main", "worker", "main", "worker"];4    let delta→ [1, 2, 3, 4]s = [1, 2, 3, 4];5    let mut main_tota→ 0l = 0;6    let mut worker_tota→ 0l = 0;7    for i in 0..max_step {
  2. for i in 0..max_step

    pass 1 of 3
    6let mut worker_total = 0;7for 0i in 0..max_ste3p {8    if owners[i] == "main" {
    All 3 passes — pass 1 is the card above
    passiowners[i]deltas[i]main_totalworker_total
    10"main"10 1
    2120 2
    32"main"31 4
  3. main_total ← 1

    pass 1 of 2
    7for i in 0..max_step {8    if owners[i"main"] == "main" {9        main_tota→ 1l += deltas[i1];10    } else {
  4. worker_total ← 2

    9    main_total += deltas[i];10} else {11    worker_tota→ 2l += deltas[i2];12}
  5. main_total ← 4

    pass 2 of 2
    7for i in 0..max_step {8    if owners[i"main"] == "main" {9        main_tota→ 4l += deltas[i3];10    } else {
  6. println!("{main_total}:{worker_total}");

    13    }14    println!("{main_total}:{worker_total}");15}
    output4:2
  1. max_step ← 2, owners ← ["main", "worker", "main", "worker"], deltas ← [1, 2, 3, 4]

    1fn main() {2    let max_ste→ 2p: usize = 2;3    let owner→ ["main", "worker", "main", "worker"]s = ["main", "worker", "main", "worker"];4    let delta→ [1, 2, 3, 4]s = [1, 2, 3, 4];5    let mut main_tota→ 0l = 0;6    let mut worker_tota→ 0l = 0;7    for i in 0..max_step {
  2. for i in 0..max_step

    pass 1 of 2
    6let mut worker_total = 0;7for 0i in 0..max_ste2p {8    if owners[i] == "main" {
  3. main_total ← 1

    7for i in 0..max_step {8    if owners[i"main"] == "main" {9        main_tota→ 1l += deltas[i1];10    } else {
  4. for i in 0..max_step

    pass 2 of 2
    6let mut worker_total = 0;7for 1i in 0..max_ste2p {8    if owners[i] == "main" {
  5. worker_total ← 2

    9    main_total += deltas[i];10} else {11    worker_tota→ 2l += deltas[i2];12}
  6. println!("{main_total}:{worker_total}");

    13    }14    println!("{main_total}:{worker_total}");15}
    output1:2
  1. max_step ← 4, owners ← ["main", "worker", "main", "worker"], deltas ← [1, 2, 3, 4]

    1fn main() {2    let max_ste→ 4p: usize = 4;3    let owner→ ["main", "worker", "main", "worker"]s = ["main", "worker", "main", "worker"];4    let delta→ [1, 2, 3, 4]s = [1, 2, 3, 4];5    let mut main_tota→ 0l = 0;6    let mut worker_tota→ 0l = 0;7    for i in 0..max_step {
  2. for i in 0..max_step

    pass 1 of 4
    6let mut worker_total = 0;7for 0i in 0..max_ste4p {8    if owners[i] == "main" {
    All 4 passes — pass 1 is the card above
    passiowners[i]deltas[i]main_totalworker_total
    10"main"10 1
    2120 2
    32"main"31 4
    4342 6
  3. main_total ← 1

    pass 1 of 2
    7for i in 0..max_step {8    if owners[i"main"] == "main" {9        main_tota→ 1l += deltas[i1];10    } else {
  4. worker_total ← 2

    pass 1 of 2
    9    main_total += deltas[i];10} else {11    worker_tota→ 2l += deltas[i2];12}
  5. main_total ← 4

    pass 2 of 2
    7for i in 0..max_step {8    if owners[i"main"] == "main" {9        main_tota→ 4l += deltas[i3];10    } else {
  6. worker_total ← 6

    pass 2 of 2
    9    main_total += deltas[i];10} else {11    worker_tota→ 6l += deltas[i4];12}
  7. println!("{main_total}:{worker_total}");

    13    }14    println!("{main_total}:{worker_total}");15}
    output4:6
global order `max_step` selects a prefix of the ordered event list.
owner state Each event updates the total for its owner.
interleaving The loop alternates owners without using real threads.