#![allow(dead_code, non_camel_case_types, unused_variables)] use mpstthree::binary::struct_trait::end::End; use mpstthree::binary_atmp::struct_trait::{recv::RecvTimed, send::SendTimed}; use mpstthree::generate_atmp; use mpstthree::role::broadcast::RoleBroadcast; use mpstthree::role::end::RoleEnd; use std::collections::HashMap; use std::error::Error; use std::time::Instant; generate_atmp!(MeshedChannels, A, B, C); // Types of the payloads struct Payload; struct Test0; struct TestInit; struct Test1; struct Test3; struct Test4 { payload: Payload } struct Test2 { payload: Payload } // Binary sessions in depth 0 // Binary sessions for A type Message_0_v_0_FromAToB = SendTimed; type Message_0_v_1_FromAToB = SendTimed; type Message_0_v_2_FromAToB = SendTimed; type Message_0_v_0_FromAToC = SendTimed; // Binary sessions for B type Message_0_v_0_FromBToA = RecvTimed; type Message_0_v_1_FromBToA = RecvTimed; type Message_0_v_2_FromBToA = RecvTimed; type Message_0_v_0_FromBToC = End; // Binary sessions for C type Message_0_v_0_FromCToB = End; type Message_0_v_0_FromCToA = RecvTimed; // Binary sessions in depth 0.1 // Binary sessions for C type Message_0_1_v_0_FromCToB = End; type Message_0_1_v_0_FromCToA = End; // Binary sessions for A type Message_0_1_v_0_FromAToC = End; type Message_0_1_v_0_FromAToB = SendTimed; type Message_0_1_v_1_FromAToB = SendTimed; type Message_0_1_v_2_FromAToB = SendTimed; type Message_0_1_v_3_FromAToB = SendTimed; type Message_0_1_v_4_FromAToB = End; // Binary sessions for B type Message_0_1_v_0_FromBToA = RecvTimed; type Message_0_1_v_1_FromBToA = RecvTimed; type Message_0_1_v_2_FromBToA = RecvTimed; type Message_0_1_v_3_FromBToA = RecvTimed; type Message_0_1_v_4_FromBToA = End; type Message_0_1_v_0_FromBToC = End; // Binary sessions in depth 0.0 // Binary sessions for A type Message_0_0_v_0_FromAToB = SendTimed; type Message_0_0_v_1_FromAToB = SendTimed; type Message_0_0_v_2_FromAToB = SendTimed; type Message_0_0_v_3_FromAToB = SendTimed; type Message_0_0_v_4_FromAToB = SendTimed; type Message_0_0_v_5_FromAToB = SendTimed; type Message_0_0_v_0_FromAToC = SendTimed; // Binary sessions for B type Message_0_0_v_0_FromBToA = RecvTimed; type Message_0_0_v_1_FromBToA = RecvTimed; type Message_0_0_v_2_FromBToA = RecvTimed; type Message_0_0_v_3_FromBToA = RecvTimed; type Message_0_0_v_4_FromBToA = RecvTimed; type Message_0_0_v_5_FromBToA = RecvTimed; type Message_0_0_v_0_FromBToC = End; // Binary sessions for C type Message_0_0_v_0_FromCToA = RecvTimed; type Message_0_0_v_0_FromCToB = End; // Stacks in depth 0 // Stacks for C type Ordering_0_v_0_ForC = RoleA; // Stacks for A type Ordering_0_v_0_ForA = RoleB; type Ordering_0_v_1_ForA = RoleB; type Ordering_0_v_2_ForA = RoleBroadcast; // Stacks for B type Ordering_0_v_0_ForB = RoleA; type Ordering_0_v_1_ForB = RoleA; type Ordering_0_v_2_ForB = RoleA; // Stacks in depth 0.1 // Stacks for B type Ordering_0_1_v_0_ForB = RoleA; type Ordering_0_1_v_1_ForB = RoleA; type Ordering_0_1_v_2_ForB = RoleA; type Ordering_0_1_v_3_ForB = RoleA; type Ordering_0_1_v_4_ForB = RoleEnd; // Stacks for A type Ordering_0_1_v_0_ForA = RoleB; type Ordering_0_1_v_1_ForA = RoleB; type Ordering_0_1_v_2_ForA = RoleB; type Ordering_0_1_v_3_ForA = RoleB; type Ordering_0_1_v_4_ForA = RoleEnd; // Stacks for C type Ordering_0_1_v_0_ForC = RoleEnd; // Stacks in depth 0.0 // Stacks for C type Ordering_0_0_v_0_ForC = RoleA; // Stacks for A type Ordering_0_0_v_0_ForA = RoleB; type Ordering_0_0_v_1_ForA = RoleB; type Ordering_0_0_v_2_ForA = RoleB; type Ordering_0_0_v_3_ForA = RoleB; type Ordering_0_0_v_4_ForA = RoleB; type Ordering_0_0_v_5_ForA = RoleBroadcast; // Stacks for B type Ordering_0_0_v_0_ForB = RoleA; type Ordering_0_0_v_1_ForB = RoleA; type Ordering_0_0_v_2_ForB = RoleA; type Ordering_0_0_v_3_ForB = RoleA; type Ordering_0_0_v_4_ForB = RoleA; type Ordering_0_0_v_5_ForB = RoleA; // Enums (Branchings) in depth 0 // Enums (Branchings) for B enum Choice_0_FromAToB { Branching0(Endpoint_0_0_ForB), Branching1(Endpoint_0_1_ForB), } // Enums (Branchings) for C enum Choice_0_FromAToC { Branching0(Endpoint_0_0_ForC), Branching1(Endpoint_0_1_ForC), } // Endpoints in depth 0 // Endpoint for role A type Endpoint_0_ForA = MeshedChannels; // Endpoint for role B type Endpoint_0_ForB = MeshedChannels; // Endpoint for role C type Endpoint_0_ForC = MeshedChannels; // Endpoints in depth 0.1 // Endpoint for role A type Endpoint_0_1_ForA = MeshedChannels; // Endpoint for role B type Endpoint_0_1_ForB = MeshedChannels; // Endpoint for role C type Endpoint_0_1_ForC = MeshedChannels; // Endpoints in depth 0.0 // Endpoint for role A type Endpoint_0_0_ForA = MeshedChannels; // Endpoint for role B type Endpoint_0_0_ForB = MeshedChannels; // Endpoint for role C type Endpoint_0_0_ForC = MeshedChannels; // Fill in the functions here. fn endpoint_a_0_v_0(s: Endpoint_0_ForA, all_clocks: &mut HashMap) -> Result<(), Box> { all_clocks.insert('a', Instant::now()); Ok(()) } fn endpoint_b_0_v_0(s: Endpoint_0_ForB, all_clocks: &mut HashMap) -> Result<(), Box> { all_clocks.insert('a', Instant::now()); Ok(()) } fn endpoint_c_0_v_0(s: Endpoint_0_ForC, all_clocks: &mut HashMap) -> Result<(), Box> { Ok(()) } fn endpoint_a_0_1_v_0(s: Endpoint_0_1_ForA, all_clocks: &mut HashMap) -> Result<(), Box> { all_clocks.insert('a', Instant::now()); Ok(()) } fn endpoint_a_0_1_v_1(s: Endpoint_0_1_ForA, all_clocks: &mut HashMap) -> Result<(), Box> { all_clocks.insert('a', Instant::now()); Ok(()) } fn endpoint_b_0_1_v_0(s: Endpoint_0_1_ForB, all_clocks: &mut HashMap) -> Result<(), Box> { all_clocks.insert('a', Instant::now()); Ok(()) } fn endpoint_b_0_1_v_1(s: Endpoint_0_1_ForB, all_clocks: &mut HashMap) -> Result<(), Box> { all_clocks.insert('a', Instant::now()); Ok(()) } fn endpoint_c_0_1_v_0(s: Endpoint_0_1_ForC, all_clocks: &mut HashMap) -> Result<(), Box> { Ok(()) } fn endpoint_c_0_1_v_1(s: Endpoint_0_1_ForC, all_clocks: &mut HashMap) -> Result<(), Box> { Ok(()) } fn endpoint_a_0_0_v_0(s: Endpoint_0_0_ForA, all_clocks: &mut HashMap) -> Result<(), Box> { all_clocks.insert('a', Instant::now()); Ok(()) } fn endpoint_b_0_0_v_0(s: Endpoint_0_0_ForB, all_clocks: &mut HashMap) -> Result<(), Box> { all_clocks.insert('a', Instant::now()); Ok(()) } fn endpoint_c_0_0_v_0(s: Endpoint_0_0_ForC, all_clocks: &mut HashMap) -> Result<(), Box> { Ok(()) } fn main() { let (thread_a, thread_b, thread_c, ) = fork_mpst(endpoint_a_0_v_0, endpoint_b_0_v_0, endpoint_c_0_v_0, ); println!("Thread A: {:?}", thread_a.join()); println!("Thread B: {:?}", thread_b.join()); println!("Thread C: {:?}", thread_c.join()); }