<PeterKrull[m]> "Hey, anyone here who have done..." <- > <@peterkrull_:matrix.org> Hey, anyone here who have done "routing" of async channel values within the firmware, or have any ideas on how to do so effectively? I use embassy, and I have some logic that determines how my different tasks inputs and outputs (essentially SPMC channels) connect to each other based on some state. With my current implementation I have a task that is responsible for routing, which uses select\_biased in a loop, where the routing logic lives within each signals branch. I want the router to be mostly fair, so one signal can not starve out the others, though I am not sure if this is the best way to do it. It feels a bit too boilerplatey, and the last branch feels very much like a hack.
> 
> ```rust
>     // Create the futures of signals we want to poll for changes
>     let receive_sig_1_cng = receive_sig_1.changed();
>     let receive_sig_2_cng = receive_sig_2.changed();
>     let receive_sig_3_cng = receive_sig_3.changed();
> 
>     // Pin the futures so they do not move in memory
>     pin_mut!(receive_sig_1_cng);
>     pin_mut!(receive_sig_2_cng);
>     pin_mut!(receive_sig_3_cng);
> 
>     // Fuse the futures so they can all be polled fairly (but biased) in a select
>     let mut receive_sig_1_fuse = (&mut receive_sig_1_cng).fuse();
>     let mut receive_sig_2_fuse = (&mut receive_sig_2_cng).fuse();
>     let mut receive_sig_3_fuse = (&mut receive_sig_3_cng).fuse();
>     
>     loop {
> 
>         select_biased! {
>             
>             value_1 = receive_sig_1_fuse => {
>                 // Routing logic for value_1
>             },
>             value_2 = receive_sig_2_fuse => {
>                 // Routing logic for value_2
>             },
>             value_3 = receive_sig_3_fuse => {
>                 // Routing logic for value_3
>             },
>             
>             // All futures got a chance to be polled, so we fuse them again
>             _ = async {}.fuse() => {
>                 receive_sig_1_fuse = (&mut receive_sig_1_cng).fuse();
>                 receive_sig_2_fuse = (&mut receive_sig_2_cng).fuse();
>                 receive_sig_3_fuse = (&mut receive_sig_3_cng).fuse();
>             }
>         }
>     }
> ```

Generally any time I get myself in a spot like this, the question is: "do I really need channels?"