// Test for parametrisation on the name of the roles use mpstthree::binary::struct_trait::{end::End, recv::Recv, send::Send}; use mpstthree::role::end::RoleEnd; use std::error::Error; use mpstthree::generate; // Create new roles generate!("basic", MeshedChannels, A, B, D); type StackA = RoleA; type StackD = RoleD; type SendMeshedChannelsD = MeshedChannels, End, StackA, NameD>; type SendMeshedChannelsA = MeshedChannels, StackD, NameA>; type RecvMeshedChannelsD = MeshedChannels, End, StackA, NameD>; type RecvMeshedChannelsA = MeshedChannels, StackD, NameA>; // Create an B dummy type Dummy = MeshedChannels; // The functions for the basic exchanges fn send_a_to_d(s: SendMeshedChannelsA) -> Result<(), Box> { s.send(0).close() } fn send_d_to_a(s: SendMeshedChannelsD) -> Result<(), Box> { s.send(0).close() } fn recv_a_to_d(s: RecvMeshedChannelsA) -> Result<(), Box> { let (_, s) = s.recv(); s.close() } fn recv_d_to_a(s: RecvMeshedChannelsD) -> Result<(), Box> { let (_, s) = s.recv(); s.close() } fn dummy(s: Dummy) -> Result<(), Box> { s.close() } ///////////////////////////////////////// pub fn basic_macros_send() { let (thread_a, thread_dummy, thread_d) = fork_mpst(send_a_to_d, dummy, recv_d_to_a); assert!(thread_a.join().is_ok()); assert!(thread_dummy.join().is_ok()); assert!(thread_d.join().is_ok()); } pub fn basic_macros_recv() { let (thread_a, thread_dummy, thread_d) = fork_mpst(recv_a_to_d, dummy, send_d_to_a); assert!(thread_a.join().is_ok()); assert!(thread_dummy.join().is_ok()); assert!(thread_d.join().is_ok()); }