Skip to content

Commit

Permalink
pull out of option in select
Browse files Browse the repository at this point in the history
  • Loading branch information
jmpesp committed Feb 5, 2025
1 parent 912e376 commit 446bd1e
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions upstairs/src/notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,22 @@ async fn notify_task_nexus(
.unwrap();

loop {
let r = {
if stored_notification.is_some() {
stored_notification.take()
} else {
tokio::select! {
biased;

i = rx_high.recv() => i.map(|message| Notification {
message,
qos: NotifyQos::High,
retries: 0,
}),

i = rx_low.recv() => i.map(|message| Notification {
message,
qos: NotifyQos::Low,
retries: 0,
}),
}
}
let r = tokio::select! {
biased;

Some(n) = async { stored_notification.take() } => Some(n),

i = rx_high.recv() => i.map(|message| Notification {
message,
qos: NotifyQos::High,
retries: 0,
}),

i = rx_low.recv() => i.map(|message| Notification {
message,
qos: NotifyQos::Low,
retries: 0,
}),
};

let Some(Notification {
Expand Down Expand Up @@ -208,8 +204,8 @@ async fn notify_task_nexus(
DownstairsClientStoppedReason::ConnectionTimeout
}
ClientRunResult::ConnectionFailed(_) => {
// skip this notification, it's too noisy during connection
// retries
// skip this notification, it's too noisy during
// connection retries
//DownstairsClientStoppedReason::ConnectionFailed
continue;
}
Expand Down

0 comments on commit 446bd1e

Please sign in to comment.