mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
cleanup + detect num cpus
This commit is contained in:
parent
0b0bfc6fdd
commit
f83c0166be
6 changed files with 13 additions and 38 deletions
|
@ -87,7 +87,7 @@ pub use crate::{
|
|||
moniker::{MonikerKind, MonikerResult, PackageInformation},
|
||||
move_item::Direction,
|
||||
navigation_target::NavigationTarget,
|
||||
prime_caches::{ParallelPrimeCachesProgress, PrimeCachesProgress},
|
||||
prime_caches::ParallelPrimeCachesProgress,
|
||||
references::ReferenceSearchResult,
|
||||
rename::RenameError,
|
||||
runnables::{Runnable, RunnableKind, TestId},
|
||||
|
@ -244,13 +244,6 @@ impl Analysis {
|
|||
self.with_db(|db| status::status(&*db, file_id))
|
||||
}
|
||||
|
||||
pub fn prime_caches<F>(&self, cb: F) -> Cancellable<()>
|
||||
where
|
||||
F: Fn(PrimeCachesProgress) + Sync + std::panic::UnwindSafe,
|
||||
{
|
||||
self.with_db(move |db| prime_caches::prime_caches(db, &cb))
|
||||
}
|
||||
|
||||
pub fn parallel_prime_caches<F>(&self, num_worker_threads: u8, cb: F) -> Cancellable<()>
|
||||
where
|
||||
F: Fn(ParallelPrimeCachesProgress) + Sync + std::panic::UnwindSafe,
|
||||
|
|
|
@ -16,29 +16,6 @@ use rustc_hash::FxHashSet;
|
|||
|
||||
use crate::RootDatabase;
|
||||
|
||||
/// We started indexing a crate.
|
||||
#[derive(Debug)]
|
||||
pub struct PrimeCachesProgress {
|
||||
pub on_crate: String,
|
||||
pub n_done: usize,
|
||||
pub n_total: usize,
|
||||
}
|
||||
|
||||
pub(crate) fn prime_caches(db: &RootDatabase, cb: &(dyn Fn(PrimeCachesProgress) + Sync)) {
|
||||
let _p = profile::span("prime_caches");
|
||||
let graph = db.crate_graph();
|
||||
let to_prime = compute_crates_to_prime(db, &graph);
|
||||
|
||||
let n_total = to_prime.len();
|
||||
for (n_done, &crate_id) in to_prime.iter().enumerate() {
|
||||
let crate_name = graph[crate_id].display_name.as_deref().unwrap_or_default().to_string();
|
||||
|
||||
cb(PrimeCachesProgress { on_crate: crate_name, n_done, n_total });
|
||||
// This also computes the DefMap
|
||||
db.import_map(crate_id);
|
||||
}
|
||||
}
|
||||
|
||||
/// We're indexing many crates.
|
||||
#[derive(Debug)]
|
||||
pub struct ParallelPrimeCachesProgress {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue