Macro mpstthree::choose_mpst_multi_cancel_to_all

source ·
macro_rules! choose_mpst_multi_cancel_to_all {
    (
        $session: expr,
        $( $label: path , )+ =>
        $( $receiver: ident , )+ =>
        $broadcaster: ident,
        $sender: ident,
        $meshedchannels_name: ident,
        $exclusion: literal
    ) => { ... };
}
Available on crate feature macros_multiple only.
Expand description

Choose among different sessions that are provided, may fail because of a canceled session. Need to exclude the first participant

§Arguments

  • The session to be used
  • The different enum variants which represent the different branches to be sent to each passive role
  • The different passive roles
  • The name of the sender
  • The name of the MeshedChannels type that will be used
  • The index of the active role

§Example

Available on the cancel/cancel_10 test.

match xs.pop() {
   Option::Some(_) => {
       let s = choose_mpst_multi_cancel_to_all!(
           s,
           CBranchesBtoC::Video, =>
           NameA,
           NameB, =>
           NameD,
           MeshedChannels,
           3
       );
       let s = send_mpst_d_to_a(1, s);
       let (_, s) = recv_mpst_d_from_a(s)?;
       client_recurs(s, xs, index + 1)
   }
   Option::None => {
       let s = choose_mpst_multi_cancel_to_all!(
           s,
           CBranchesBtoC::End, =>
           NameA,
           NameB, =>
           NameD,
           MeshedChannels,
           3
       );
       close_mpst_multi(s)
   }
}

§Compile fail

Available on the cancel/cancel_8 test.

use mpstthree::{create_multiple_normal_role, choose_mpst_multi_cancel_to_all,
create_multiple_normal_name};

create_multiple_normal_role!(
    RoleA, RoleADual |
    RoleB, RoleBDual |
    RoleD, RoleDDual |
);

create_multiple_normal_name!(
    NameA,
    NameB,
    NameD
);

bundle_struct_fork_close_multi!(close_mpst, fork_mpst, MeshedChannels, 3);

match xs.pop() {
   Option::Some(_) => {
       let s = choose_mpst_multi_cancel_to_all!(
           s,
           CBranchesAtoC::Video,
           CBranchesBtoC::Video, =>
           NameA,
           NameB, =>
           NameD,
           MeshedChannels,
           3
       );
       client_recurs(s, xs, index + 1)
   }
   Option::None => {
       let s = choose_mpst_multi_cancel_to_all!(
           s,
           CBranchesAtoC::End,
           CBranchesBtoC::End, =>
           NameA,
           NameB, =>
           NameD,
           MeshedChannels,
           3
       );
       close_mpst_multi(s)
   }
}

This macro is available only if MultiCrusty is built with the "macros_multiple" feature.