mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
Use select_biased
This commit is contained in:
parent
cb1c7b3b99
commit
9731fa9fe0
1 changed files with 8 additions and 7 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
use std::{fmt, io, process::Command, time::Duration};
|
||||
|
||||
use crossbeam_channel::{never, select, unbounded, Receiver, Sender};
|
||||
use crossbeam_channel::{select_biased, unbounded, Receiver, Sender};
|
||||
use paths::{AbsPath, AbsPathBuf, Utf8PathBuf};
|
||||
use rustc_hash::FxHashMap;
|
||||
use serde::Deserialize;
|
||||
|
@ -260,13 +260,14 @@ impl FlycheckActor {
|
|||
}
|
||||
|
||||
fn next_event(&self, inbox: &Receiver<StateChange>) -> Option<Event> {
|
||||
if let Ok(msg) = inbox.try_recv() {
|
||||
// give restarts a preference so check outputs don't block a restart or stop
|
||||
return Some(Event::RequestStateChange(msg));
|
||||
}
|
||||
select! {
|
||||
let Some(command_receiver) = &self.command_receiver else {
|
||||
return inbox.recv().ok().map(Event::RequestStateChange);
|
||||
};
|
||||
|
||||
// Biased to give restarts a preference so check outputs don't block a restart or stop
|
||||
select_biased! {
|
||||
recv(inbox) -> msg => msg.ok().map(Event::RequestStateChange),
|
||||
recv(self.command_receiver.as_ref().unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())),
|
||||
recv(command_receiver) -> msg => Some(Event::CheckEvent(msg.ok())),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue