Naming
This commit is contained in:
parent
309b21f378
commit
eddb744d90
@ -50,7 +50,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FlycheckHandle {
|
pub struct FlycheckHandle {
|
||||||
// XXX: drop order is significant
|
// XXX: drop order is significant
|
||||||
cmd_send: Sender<Restart>,
|
sender: Sender<Restart>,
|
||||||
thread: jod_thread::JoinHandle,
|
thread: jod_thread::JoinHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,16 +60,15 @@ pub fn spawn(
|
|||||||
config: FlycheckConfig,
|
config: FlycheckConfig,
|
||||||
workspace_root: PathBuf,
|
workspace_root: PathBuf,
|
||||||
) -> FlycheckHandle {
|
) -> FlycheckHandle {
|
||||||
let (cmd_send, cmd_recv) = unbounded::<Restart>();
|
let actor = FlycheckActor::new(sender, config, workspace_root);
|
||||||
let thread = jod_thread::spawn(move || {
|
let (sender, receiver) = unbounded::<Restart>();
|
||||||
FlycheckActor::new(sender, config, workspace_root).run(cmd_recv);
|
let thread = jod_thread::spawn(move || actor.run(receiver));
|
||||||
});
|
FlycheckHandle { sender, thread }
|
||||||
FlycheckHandle { cmd_send, thread }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Schedule a re-start of the cargo check worker.
|
/// Schedule a re-start of the cargo check worker.
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
self.cmd_send.send(Restart).unwrap();
|
self.sender.send(Restart).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +124,7 @@ fn next_event(&self, inbox: &Receiver<Restart>) -> Option<Event> {
|
|||||||
recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())),
|
recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn run(&mut self, inbox: Receiver<Restart>) {
|
fn run(mut self, inbox: Receiver<Restart>) {
|
||||||
while let Some(event) = self.next_event(&inbox) {
|
while let Some(event) = self.next_event(&inbox) {
|
||||||
match event {
|
match event {
|
||||||
Event::Restart(Restart) => {
|
Event::Restart(Restart) => {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
use std::convert::{TryFrom, TryInto};
|
use std::convert::{TryFrom, TryInto};
|
||||||
|
|
||||||
use crossbeam_channel::{select, unbounded, Receiver};
|
use crossbeam_channel::{select, unbounded, Receiver, Sender};
|
||||||
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
|
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
|
||||||
use paths::{AbsPath, AbsPathBuf};
|
use paths::{AbsPath, AbsPathBuf};
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
@ -22,8 +22,8 @@
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NotifyHandle {
|
pub struct NotifyHandle {
|
||||||
// Relative order of fields below is significant.
|
// Relative order of fields below is significant.
|
||||||
sender: crossbeam_channel::Sender<Message>,
|
sender: Sender<Message>,
|
||||||
_thread: jod_thread::JoinHandle,
|
thread: jod_thread::JoinHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -37,7 +37,7 @@ fn spawn(sender: loader::Sender) -> NotifyHandle {
|
|||||||
let actor = NotifyActor::new(sender);
|
let actor = NotifyActor::new(sender);
|
||||||
let (sender, receiver) = unbounded::<Message>();
|
let (sender, receiver) = unbounded::<Message>();
|
||||||
let thread = jod_thread::spawn(move || actor.run(receiver));
|
let thread = jod_thread::spawn(move || actor.run(receiver));
|
||||||
NotifyHandle { sender, _thread: thread }
|
NotifyHandle { sender, thread }
|
||||||
}
|
}
|
||||||
fn set_config(&mut self, config: loader::Config) {
|
fn set_config(&mut self, config: loader::Config) {
|
||||||
self.sender.send(Message::Config(config)).unwrap()
|
self.sender.send(Message::Config(config)).unwrap()
|
||||||
|
Loading…
Reference in New Issue
Block a user