#![allow( clippy::type_complexity, clippy::too_many_arguments, clippy::large_enum_variant )] use mpstthree::binary::struct_trait::{end::End, recv::Recv, send::Send}; use mpstthree::generate; use mpstthree::role::broadcast::RoleBroadcast; use mpstthree::role::end::RoleEnd; use std::error::Error; static LOOPS: i64 = 100; // Create new roles generate!( "rec_and_cancel", MeshedChannels, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T ); // Types // A enum Branching0fromTtoA { Forward( MeshedChannels< Send<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursAtoT, RoleB>, NameA, >, ), Backward( MeshedChannels< Recv<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursAtoT, RoleB>, NameA, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameA, >, ), } type RecursAtoT = Recv; // B enum Branching0fromTtoB { Forward( MeshedChannels< Recv<(), End>, Send<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursBtoT, RoleA>>, NameB, >, ), Backward( MeshedChannels< Send<(), End>, Recv<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursBtoT, RoleC>>, NameB, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameB, >, ), } type RecursBtoT = Recv; // C enum Branching0fromTtoC { Forward( MeshedChannels< End, Recv<(), End>, Send<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursCtoT, RoleB>>, NameC, >, ), Backward( MeshedChannels< End, Send<(), End>, Recv<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursCtoT, RoleD>>, NameC, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameC, >, ), } type RecursCtoT = Recv; // D enum Branching0fromTtoD { Forward( MeshedChannels< End, End, Recv<(), End>, Send<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursDtoT, RoleC>>, NameD, >, ), Backward( MeshedChannels< End, End, Send<(), End>, Recv<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursDtoT, RoleE>>, NameD, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameD, >, ), } type RecursDtoT = Recv; // E enum Branching0fromTtoE { Forward( MeshedChannels< End, End, End, Recv<(), End>, Send<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursEtoT, RoleD>>, NameE, >, ), Backward( MeshedChannels< End, End, End, Send<(), End>, Recv<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursEtoT, RoleF>>, NameE, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameE, >, ), } type RecursEtoT = Recv; // F enum Branching0fromTtoF { Forward( MeshedChannels< End, End, End, End, Recv<(), End>, Send<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, RecursFtoT, RoleE>>, NameF, >, ), Backward( MeshedChannels< End, End, End, End, Send<(), End>, Recv<(), End>, End, End, End, End, End, End, End, End, End, End, End, End, RecursFtoT, RoleG>>, NameF, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameF, >, ), } type RecursFtoT = Recv; // G enum Branching0fromTtoG { Forward( MeshedChannels< End, End, End, End, End, Recv<(), End>, Send<(), End>, End, End, End, End, End, End, End, End, End, End, End, RecursGtoT, RoleF>>, NameG, >, ), Backward( MeshedChannels< End, End, End, End, End, Send<(), End>, Recv<(), End>, End, End, End, End, End, End, End, End, End, End, End, RecursGtoT, RoleH>>, NameG, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameG, >, ), } type RecursGtoT = Recv; // H enum Branching0fromTtoH { Forward( MeshedChannels< End, End, End, End, End, End, Recv<(), End>, Send<(), End>, End, End, End, End, End, End, End, End, End, End, RecursHtoT, RoleG>>, NameH, >, ), Backward( MeshedChannels< End, End, End, End, End, End, Send<(), End>, Recv<(), End>, End, End, End, End, End, End, End, End, End, End, RecursHtoT, RoleI>>, NameH, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameH, >, ), } type RecursHtoT = Recv; // I enum Branching0fromTtoI { Forward( MeshedChannels< End, End, End, End, End, End, End, Recv<(), End>, Send<(), End>, End, End, End, End, End, End, End, End, End, RecursItoT, RoleH>>, NameI, >, ), Backward( MeshedChannels< End, End, End, End, End, End, End, Send<(), End>, Recv<(), End>, End, End, End, End, End, End, End, End, End, RecursItoT, RoleJ>>, NameI, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameI, >, ), } type RecursItoT = Recv; // J enum Branching0fromTtoJ { Forward( MeshedChannels< End, End, End, End, End, End, End, End, Recv<(), End>, Send<(), End>, End, End, End, End, End, End, End, End, RecursJtoT, RoleI>>, NameJ, >, ), Backward( MeshedChannels< End, End, End, End, End, End, End, End, Send<(), End>, Recv<(), End>, End, End, End, End, End, End, End, End, RecursJtoT, RoleK>>, NameJ, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameJ, >, ), } type RecursJtoT = Recv; // K enum Branching0fromTtoK { Forward( MeshedChannels< End, End, End, End, End, End, End, End, End, Recv<(), End>, Send<(), End>, End, End, End, End, End, End, End, RecursKtoT, RoleJ>>, NameK, >, ), Backward( MeshedChannels< End, End, End, End, End, End, End, End, End, Send<(), End>, Recv<(), End>, End, End, End, End, End, End, End, RecursKtoT, RoleL>>, NameK, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameK, >, ), } type RecursKtoT = Recv; // L enum Branching0fromTtoL { Forward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, Recv<(), End>, Send<(), End>, End, End, End, End, End, End, RecursLtoT, RoleK>>, NameL, >, ), Backward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, Send<(), End>, Recv<(), End>, End, End, End, End, End, End, RecursLtoT, RoleM>>, NameL, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameL, >, ), } type RecursLtoT = Recv; // M enum Branching0fromTtoM { Forward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, Recv<(), End>, Send<(), End>, End, End, End, End, End, RecursMtoT, RoleL>>, NameM, >, ), Backward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, Send<(), End>, Recv<(), End>, End, End, End, End, End, RecursMtoT, RoleN>>, NameM, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameM, >, ), } type RecursMtoT = Recv; // N enum Branching0fromTtoN { Forward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, Recv<(), End>, Send<(), End>, End, End, End, End, RecursNtoT, RoleM>>, NameN, >, ), Backward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, Send<(), End>, Recv<(), End>, End, End, End, End, RecursNtoT, RoleO>>, NameN, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameN, >, ), } type RecursNtoT = Recv; // O enum Branching0fromTtoO { Forward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, Recv<(), End>, Send<(), End>, End, End, End, RecursOtoT, RoleN>>, NameO, >, ), Backward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, Send<(), End>, Recv<(), End>, End, End, End, RecursOtoT, RoleP>>, NameO, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameO, >, ), } type RecursOtoT = Recv; // P enum Branching0fromTtoP { Forward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, Recv<(), End>, Send<(), End>, End, End, RecursPtoT, RoleO>>, NameP, >, ), Backward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, Send<(), End>, Recv<(), End>, End, End, RecursPtoT, RoleQ>>, NameP, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameP, >, ), } type RecursPtoT = Recv; // Q enum Branching0fromTtoQ { Forward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, Recv<(), End>, Send<(), End>, End, RecursQtoT, RoleP>>, NameQ, >, ), Backward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, Send<(), End>, Recv<(), End>, End, RecursQtoT, RoleR>>, NameQ, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameQ, >, ), } type RecursQtoT = Recv; // R enum Branching0fromTtoR { Forward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, Recv<(), End>, Send<(), End>, RecursRtoT, RoleQ>>, NameR, >, ), Backward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, Send<(), End>, Recv<(), End>, RecursRtoT, RoleS>>, NameR, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameR, >, ), } type RecursRtoT = Recv; // S enum Branching0fromTtoS { Forward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, Recv<(), End>, Send<(), RecursStoT>, RoleR>>, NameS, >, ), Backward( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, Send<(), End>, Recv<(), RecursStoT>, RoleT>>, NameS, >, ), Done( MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RoleEnd, NameS, >, ), } type RecursStoT = Recv; // T type Choose0fromTtoA = Send; type Choose0fromTtoB = Send; type Choose0fromTtoC = Send; type Choose0fromTtoD = Send; type Choose0fromTtoE = Send; type Choose0fromTtoF = Send; type Choose0fromTtoG = Send; type Choose0fromTtoH = Send; type Choose0fromTtoI = Send; type Choose0fromTtoJ = Send; type Choose0fromTtoK = Send; type Choose0fromTtoL = Send; type Choose0fromTtoM = Send; type Choose0fromTtoN = Send; type Choose0fromTtoO = Send; type Choose0fromTtoP = Send; type Choose0fromTtoQ = Send; type Choose0fromTtoR = Send; type Choose0fromTtoS = Send; type EndpointForwardT = MeshedChannels< Choose0fromTtoA, Choose0fromTtoB, Choose0fromTtoC, Choose0fromTtoD, Choose0fromTtoE, Choose0fromTtoF, Choose0fromTtoG, Choose0fromTtoH, Choose0fromTtoI, Choose0fromTtoJ, Choose0fromTtoK, Choose0fromTtoL, Choose0fromTtoM, Choose0fromTtoN, Choose0fromTtoO, Choose0fromTtoP, Choose0fromTtoQ, Choose0fromTtoR, Recv<(), Choose0fromTtoS>, RoleS, NameT, >; type EndpointBackwardT = MeshedChannels< Choose0fromTtoA, Choose0fromTtoB, Choose0fromTtoC, Choose0fromTtoD, Choose0fromTtoE, Choose0fromTtoF, Choose0fromTtoG, Choose0fromTtoH, Choose0fromTtoI, Choose0fromTtoJ, Choose0fromTtoK, Choose0fromTtoL, Choose0fromTtoM, Choose0fromTtoN, Choose0fromTtoO, Choose0fromTtoP, Choose0fromTtoQ, Choose0fromTtoR, Send<(), Choose0fromTtoS>, RoleS, NameT, >; // Creating the MP sessions type EndpointA = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursAtoT, RoleT, NameA, >; type EndpointB = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursBtoT, RoleT, NameB, >; type EndpointC = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursCtoT, RoleT, NameC, >; type EndpointD = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursDtoT, RoleT, NameD, >; type EndpointE = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursEtoT, RoleT, NameE, >; type EndpointF = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursFtoT, RoleT, NameF, >; type EndpointG = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursGtoT, RoleT, NameG, >; type EndpointH = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursHtoT, RoleT, NameH, >; type EndpointI = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursItoT, RoleT, NameI, >; type EndpointJ = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursJtoT, RoleT, NameJ, >; type EndpointK = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursKtoT, RoleT, NameK, >; type EndpointL = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursLtoT, RoleT, NameL, >; type EndpointM = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursMtoT, RoleT, NameM, >; type EndpointN = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursNtoT, RoleT, NameN, >; type EndpointO = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursOtoT, RoleT, NameO, >; type EndpointP = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursPtoT, RoleT, NameP, >; type EndpointQ = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursQtoT, RoleT, NameQ, >; type EndpointR = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursRtoT, RoleT, NameR, >; type EndpointS = MeshedChannels< End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, End, RecursStoT, RoleT, NameS, >; type EndpointT = MeshedChannels< Choose0fromTtoA, Choose0fromTtoB, Choose0fromTtoC, Choose0fromTtoD, Choose0fromTtoE, Choose0fromTtoF, Choose0fromTtoG, Choose0fromTtoH, Choose0fromTtoI, Choose0fromTtoJ, Choose0fromTtoK, Choose0fromTtoL, Choose0fromTtoM, Choose0fromTtoN, Choose0fromTtoO, Choose0fromTtoP, Choose0fromTtoQ, Choose0fromTtoR, Choose0fromTtoS, RoleBroadcast, NameT, >; fn endpoint_a(s: EndpointA) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoA::Done(s) => { s.close() }, Branching0fromTtoA::Forward(s) => { let s = s.send(())?; endpoint_a(s) }, Branching0fromTtoA::Backward(s) => { let (_, s) = s.recv()?; endpoint_a(s) }, }) } #[inline] fn endpoint_b(s: EndpointB) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoB::Done(s) => { s.close() }, Branching0fromTtoB::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_b(s) }, Branching0fromTtoB::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_b(s) }, }) } #[inline] fn endpoint_c(s: EndpointC) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoC::Done(s) => { s.close() }, Branching0fromTtoC::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_c(s) }, Branching0fromTtoC::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_c(s) }, }) } #[inline] fn endpoint_d(s: EndpointD) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoD::Done(s) => { s.close() }, Branching0fromTtoD::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_d(s) }, Branching0fromTtoD::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_d(s) }, }) } #[inline] fn endpoint_e(s: EndpointE) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoE::Done(s) => { s.close() }, Branching0fromTtoE::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_e(s) }, Branching0fromTtoE::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_e(s) }, }) } #[inline] fn endpoint_f(s: EndpointF) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoF::Done(s) => { s.close() }, Branching0fromTtoF::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_f(s) }, Branching0fromTtoF::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_f(s) }, }) } #[inline] fn endpoint_g(s: EndpointG) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoG::Done(s) => { s.close() }, Branching0fromTtoG::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_g(s) }, Branching0fromTtoG::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_g(s) }, }) } #[inline] fn endpoint_h(s: EndpointH) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoH::Done(s) => { s.close() }, Branching0fromTtoH::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_h(s) }, Branching0fromTtoH::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_h(s) }, }) } #[inline] fn endpoint_i(s: EndpointI) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoI::Done(s) => { s.close() }, Branching0fromTtoI::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_i(s) }, Branching0fromTtoI::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_i(s) }, }) } #[inline] fn endpoint_j(s: EndpointJ) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoJ::Done(s) => { s.close() }, Branching0fromTtoJ::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_j(s) }, Branching0fromTtoJ::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_j(s) }, }) } #[inline] fn endpoint_k(s: EndpointK) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoK::Done(s) => { s.close() }, Branching0fromTtoK::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_k(s) }, Branching0fromTtoK::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_k(s) }, }) } #[inline] fn endpoint_l(s: EndpointL) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoL::Done(s) => { s.close() }, Branching0fromTtoL::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_l(s) }, Branching0fromTtoL::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_l(s) }, }) } #[inline] fn endpoint_m(s: EndpointM) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoM::Done(s) => { s.close() }, Branching0fromTtoM::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_m(s) }, Branching0fromTtoM::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_m(s) }, }) } #[inline] fn endpoint_n(s: EndpointN) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoN::Done(s) => { s.close() }, Branching0fromTtoN::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_n(s) }, Branching0fromTtoN::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_n(s) }, }) } #[inline] fn endpoint_o(s: EndpointO) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoO::Done(s) => { s.close() }, Branching0fromTtoO::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_o(s) }, Branching0fromTtoO::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_o(s) }, }) } #[inline] fn endpoint_p(s: EndpointP) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoP::Done(s) => { s.close() }, Branching0fromTtoP::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_p(s) }, Branching0fromTtoP::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_p(s) }, }) } #[inline] fn endpoint_q(s: EndpointQ) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoQ::Done(s) => { s.close() }, Branching0fromTtoQ::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_q(s) }, Branching0fromTtoQ::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_q(s) }, }) } #[inline] fn endpoint_r(s: EndpointR) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoR::Done(s) => { s.close() }, Branching0fromTtoR::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_r(s) }, Branching0fromTtoR::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_r(s) }, }) } #[inline] fn endpoint_s(s: EndpointS) -> Result<(), Box> { offer_mpst!(s, { Branching0fromTtoS::Done(s) => { s.close() }, Branching0fromTtoS::Forward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_s(s) }, Branching0fromTtoS::Backward(s) => { let ((), s) = s.recv()?; let s = s.send(())?; endpoint_s(s) }, }) } #[inline] fn endpoint_t(s: EndpointT) -> Result<(), Box> { let mut temp_s = s; for i in 1..LOOPS { temp_s = recurs_t(temp_s, i)?; } let s = choose_mpst_t_to_all!( temp_s, Branching0fromTtoA::Done, Branching0fromTtoB::Done, Branching0fromTtoC::Done, Branching0fromTtoD::Done, Branching0fromTtoE::Done, Branching0fromTtoF::Done, Branching0fromTtoG::Done, Branching0fromTtoH::Done, Branching0fromTtoI::Done, Branching0fromTtoJ::Done, Branching0fromTtoK::Done, Branching0fromTtoL::Done, Branching0fromTtoM::Done, Branching0fromTtoN::Done, Branching0fromTtoO::Done, Branching0fromTtoP::Done, Branching0fromTtoQ::Done, Branching0fromTtoR::Done, Branching0fromTtoS::Done ); s.close() } fn recurs_t(s: EndpointT, index: i64) -> Result> { match index { i if i % 2 == 0 => { let s: EndpointForwardT = choose_mpst_t_to_all!( s, Branching0fromTtoA::Forward, Branching0fromTtoB::Forward, Branching0fromTtoC::Forward, Branching0fromTtoD::Forward, Branching0fromTtoE::Forward, Branching0fromTtoF::Forward, Branching0fromTtoG::Forward, Branching0fromTtoH::Forward, Branching0fromTtoI::Forward, Branching0fromTtoJ::Forward, Branching0fromTtoK::Forward, Branching0fromTtoL::Forward, Branching0fromTtoM::Forward, Branching0fromTtoN::Forward, Branching0fromTtoO::Forward, Branching0fromTtoP::Forward, Branching0fromTtoQ::Forward, Branching0fromTtoR::Forward, Branching0fromTtoS::Forward ); let (_, s) = s.recv()?; Ok(s) } _ => { let s: EndpointBackwardT = choose_mpst_t_to_all!( s, Branching0fromTtoA::Backward, Branching0fromTtoB::Backward, Branching0fromTtoC::Backward, Branching0fromTtoD::Backward, Branching0fromTtoE::Backward, Branching0fromTtoF::Backward, Branching0fromTtoG::Backward, Branching0fromTtoH::Backward, Branching0fromTtoI::Backward, Branching0fromTtoJ::Backward, Branching0fromTtoK::Backward, Branching0fromTtoL::Backward, Branching0fromTtoM::Backward, Branching0fromTtoN::Backward, Branching0fromTtoO::Backward, Branching0fromTtoP::Backward, Branching0fromTtoQ::Backward, Branching0fromTtoR::Backward, Branching0fromTtoS::Backward ); let s = s.send(())?; Ok(s) } } } fn main() { let ( thread_a, thread_b, thread_c, thread_d, thread_e, thread_f, thread_g, thread_h, thread_i, thread_j, thread_k, thread_l, thread_m, thread_n, thread_o, thread_p, thread_q, thread_r, thread_s, thread_t, ) = fork_mpst( endpoint_a, endpoint_b, endpoint_c, endpoint_d, endpoint_e, endpoint_f, endpoint_g, endpoint_h, endpoint_i, endpoint_j, endpoint_k, endpoint_l, endpoint_m, endpoint_n, endpoint_o, endpoint_p, endpoint_q, endpoint_r, endpoint_s, endpoint_t, ); thread_a.join().unwrap(); thread_b.join().unwrap(); thread_c.join().unwrap(); thread_d.join().unwrap(); thread_e.join().unwrap(); thread_f.join().unwrap(); thread_g.join().unwrap(); thread_h.join().unwrap(); thread_i.join().unwrap(); thread_j.join().unwrap(); thread_k.join().unwrap(); thread_l.join().unwrap(); thread_m.join().unwrap(); thread_n.join().unwrap(); thread_o.join().unwrap(); thread_p.join().unwrap(); thread_q.join().unwrap(); thread_r.join().unwrap(); thread_s.join().unwrap(); thread_t.join().unwrap(); }