Hey, i've got the following function which is responsible for calling self.on_start, self.on_refresh, and self.on_stop, which are all async. There's a tokio::sync::mpsc::Receiver for when to refresh and when to stop, but for whatever reason, when i'm emitting to the receiver for stopping, it's sometimes matching on the refresh arm instead (seemingly 50/50 randomly). is a biased select what I'm looking for? is a tokio::select the wrong tool to use in the first place?
async fn start(
&mut self,
mut refresh_rx: Receiver<()>,
mut stop_rx: Receiver<()>,
) {
tokio::select! {
output = self.on_start() => output,
_ = refresh_rx.recv() => {
println!("refresh called");
_ = self.on_refresh();
},
_ = stop_rx.recv() => {
println!("stop called");
_ = self.on_stop();
},
}