Use 'deferred task' terminology consistently
This commit is contained in:
parent
b35a995a8e
commit
61712e71ae
4 changed files with 29 additions and 29 deletions
|
|
@ -45,7 +45,7 @@ use crate::{
|
|||
op_queue::{Cause, OpQueue},
|
||||
reload,
|
||||
target_spec::{CargoTargetSpec, ProjectJsonTargetSpec, TargetSpec},
|
||||
task_pool::{TaskPool, TaskQueue},
|
||||
task_pool::{DeferredTaskQueue, TaskPool},
|
||||
test_runner::{CargoTestHandle, CargoTestMessage},
|
||||
};
|
||||
|
||||
|
|
@ -186,7 +186,8 @@ pub(crate) struct GlobalState {
|
|||
/// For certain features, such as [`GlobalState::handle_discover_msg`],
|
||||
/// this queue should run only *after* [`GlobalState::process_changes`] has
|
||||
/// been called.
|
||||
pub(crate) deferred_task_queue: TaskQueue,
|
||||
pub(crate) deferred_task_queue: DeferredTaskQueue,
|
||||
|
||||
/// HACK: Workaround for https://github.com/rust-lang/rust-analyzer/issues/19709
|
||||
/// This is marked true if we failed to load a crate root file at crate graph creation,
|
||||
/// which will usually end up causing a bunch of incorrect diagnostics on startup.
|
||||
|
|
@ -241,9 +242,9 @@ impl GlobalState {
|
|||
};
|
||||
let cancellation_pool = thread::Pool::new(1);
|
||||
|
||||
let task_queue = {
|
||||
let deferred_task_queue = {
|
||||
let (sender, receiver) = unbounded();
|
||||
TaskQueue { sender, receiver }
|
||||
DeferredTaskQueue { sender, receiver }
|
||||
};
|
||||
|
||||
let mut analysis_host = AnalysisHost::new(config.lru_parse_query_capacity());
|
||||
|
|
@ -314,7 +315,7 @@ impl GlobalState {
|
|||
prime_caches_queue: OpQueue::default(),
|
||||
discover_workspace_queue: OpQueue::default(),
|
||||
|
||||
deferred_task_queue: task_queue,
|
||||
deferred_task_queue,
|
||||
incomplete_crate_graph: false,
|
||||
|
||||
minicore: MiniCoreRustAnalyzerInternalOnly::default(),
|
||||
|
|
@ -540,10 +541,9 @@ impl GlobalState {
|
|||
// didn't find anything (to make up for the lack of precision).
|
||||
{
|
||||
if !matches!(&workspace_structure_change, Some((.., true))) {
|
||||
_ = self
|
||||
.deferred_task_queue
|
||||
.sender
|
||||
.send(crate::main_loop::QueuedTask::CheckProcMacroSources(modified_rust_files));
|
||||
_ = self.deferred_task_queue.sender.send(
|
||||
crate::main_loop::DeferredTask::CheckProcMacroSources(modified_rust_files),
|
||||
);
|
||||
}
|
||||
// FIXME: ideally we should only trigger a workspace fetch for non-library changes
|
||||
// but something's going wrong with the source root business when we add a new local
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ pub(crate) fn handle_did_open_text_document(
|
|||
let _ = state
|
||||
.deferred_task_queue
|
||||
.sender
|
||||
.send(crate::main_loop::QueuedTask::CheckIfIndexed(params.text_document.uri));
|
||||
.send(crate::main_loop::DeferredTask::CheckIfIndexed(params.text_document.uri));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ pub fn main_loop(config: Config, connection: Connection) -> anyhow::Result<()> {
|
|||
enum Event {
|
||||
Lsp(lsp_server::Message),
|
||||
Task(Task),
|
||||
QueuedTask(QueuedTask),
|
||||
DeferredTask(DeferredTask),
|
||||
Vfs(vfs::loader::Message),
|
||||
Flycheck(FlycheckMessage),
|
||||
TestResult(CargoTestMessage),
|
||||
|
|
@ -89,7 +89,7 @@ impl fmt::Display for Event {
|
|||
Event::Task(_) => write!(f, "Event::Task"),
|
||||
Event::Vfs(_) => write!(f, "Event::Vfs"),
|
||||
Event::Flycheck(_) => write!(f, "Event::Flycheck"),
|
||||
Event::QueuedTask(_) => write!(f, "Event::QueuedTask"),
|
||||
Event::DeferredTask(_) => write!(f, "Event::DeferredTask"),
|
||||
Event::TestResult(_) => write!(f, "Event::TestResult"),
|
||||
Event::DiscoverProject(_) => write!(f, "Event::DiscoverProject"),
|
||||
Event::FetchWorkspaces(_) => write!(f, "Event::SwitchWorkspaces"),
|
||||
|
|
@ -98,7 +98,7 @@ impl fmt::Display for Event {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum QueuedTask {
|
||||
pub(crate) enum DeferredTask {
|
||||
CheckIfIndexed(lsp_types::Url),
|
||||
CheckProcMacroSources(Vec<FileId>),
|
||||
}
|
||||
|
|
@ -164,7 +164,7 @@ impl fmt::Debug for Event {
|
|||
match self {
|
||||
Event::Lsp(it) => fmt::Debug::fmt(it, f),
|
||||
Event::Task(it) => fmt::Debug::fmt(it, f),
|
||||
Event::QueuedTask(it) => fmt::Debug::fmt(it, f),
|
||||
Event::DeferredTask(it) => fmt::Debug::fmt(it, f),
|
||||
Event::Vfs(it) => fmt::Debug::fmt(it, f),
|
||||
Event::Flycheck(it) => fmt::Debug::fmt(it, f),
|
||||
Event::TestResult(it) => fmt::Debug::fmt(it, f),
|
||||
|
|
@ -279,7 +279,7 @@ impl GlobalState {
|
|||
task.map(Event::Task),
|
||||
|
||||
recv(self.deferred_task_queue.receiver) -> task =>
|
||||
task.map(Event::QueuedTask),
|
||||
task.map(Event::DeferredTask),
|
||||
|
||||
recv(self.fmt_pool.receiver) -> task =>
|
||||
task.map(Event::Task),
|
||||
|
|
@ -323,12 +323,12 @@ impl GlobalState {
|
|||
lsp_server::Message::Notification(not) => self.on_notification(not),
|
||||
lsp_server::Message::Response(resp) => self.complete_request(resp),
|
||||
},
|
||||
Event::QueuedTask(task) => {
|
||||
Event::DeferredTask(task) => {
|
||||
let _p = tracing::info_span!("GlobalState::handle_event/queued_task").entered();
|
||||
self.handle_queued_task(task);
|
||||
// Coalesce multiple task events into one loop turn
|
||||
self.handle_deferred_task(task);
|
||||
// Coalesce multiple deferred task events into one loop turn
|
||||
while let Ok(task) = self.deferred_task_queue.receiver.try_recv() {
|
||||
self.handle_queued_task(task);
|
||||
self.handle_deferred_task(task);
|
||||
}
|
||||
}
|
||||
Event::Task(task) => {
|
||||
|
|
@ -981,9 +981,9 @@ impl GlobalState {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_queued_task(&mut self, task: QueuedTask) {
|
||||
fn handle_deferred_task(&mut self, task: DeferredTask) {
|
||||
match task {
|
||||
QueuedTask::CheckIfIndexed(uri) => {
|
||||
DeferredTask::CheckIfIndexed(uri) => {
|
||||
let snap = self.snapshot();
|
||||
|
||||
self.task_pool.handle.spawn_with_sender(ThreadIntent::Worker, move |sender| {
|
||||
|
|
@ -1007,7 +1007,7 @@ impl GlobalState {
|
|||
}
|
||||
});
|
||||
}
|
||||
QueuedTask::CheckProcMacroSources(modified_rust_files) => {
|
||||
DeferredTask::CheckProcMacroSources(modified_rust_files) => {
|
||||
let analysis = AssertUnwindSafe(self.snapshot().analysis);
|
||||
self.task_pool.handle.spawn_with_sender(stdx::thread::ThreadIntent::Worker, {
|
||||
move |sender| {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::panic::UnwindSafe;
|
|||
use crossbeam_channel::Sender;
|
||||
use stdx::thread::{Pool, ThreadIntent};
|
||||
|
||||
use crate::main_loop::QueuedTask;
|
||||
use crate::main_loop::DeferredTask;
|
||||
|
||||
pub(crate) struct TaskPool<T> {
|
||||
sender: Sender<T>,
|
||||
|
|
@ -45,11 +45,11 @@ impl<T> TaskPool<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// `TaskQueue`, like its name suggests, queues tasks.
|
||||
/// `DeferredTaskQueue` holds deferred tasks.
|
||||
///
|
||||
/// This should only be used if a task must run after [`GlobalState::process_changes`]
|
||||
/// has been called.
|
||||
pub(crate) struct TaskQueue {
|
||||
pub(crate) sender: crossbeam_channel::Sender<QueuedTask>,
|
||||
pub(crate) receiver: crossbeam_channel::Receiver<QueuedTask>,
|
||||
/// These are tasks that must be run after
|
||||
/// [`GlobalState::process_changes`] has been called.
|
||||
pub(crate) struct DeferredTaskQueue {
|
||||
pub(crate) sender: crossbeam_channel::Sender<DeferredTask>,
|
||||
pub(crate) receiver: crossbeam_channel::Receiver<DeferredTask>,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue