removed scoped threads, cleanup

This commit is contained in:
Jake Heinz 2022-01-14 10:06:28 +00:00
parent f83c0166be
commit c3f30ae4f0
4 changed files with 69 additions and 74 deletions

1
Cargo.lock generated
View file

@ -578,7 +578,6 @@ dependencies = [
"cfg",
"cov-mark",
"crossbeam-channel",
"crossbeam-utils",
"dot",
"either",
"expect-test",

View file

@ -12,7 +12,6 @@ doctest = false
[dependencies]
cov-mark = "2.0.0-pre.1"
crossbeam-channel = "0.5.0"
crossbeam-utils = "0.8.5"
either = "1.5.3"
itertools = "0.10.0"
tracing = "0.1"

View file

@ -8,7 +8,7 @@ use hir::db::DefDatabase;
use ide_db::{
base_db::{
salsa::{Database, ParallelDatabase, Snapshot},
CrateGraph, CrateId, SourceDatabase, SourceDatabaseExt,
Cancelled, CrateGraph, CrateId, SourceDatabase, SourceDatabaseExt,
},
FxIndexMap,
};
@ -54,7 +54,6 @@ pub(crate) fn parallel_prime_caches(
builder.build()
};
crossbeam_utils::thread::scope(move |s| {
let (work_sender, work_receiver) = crossbeam_channel::unbounded();
let (progress_sender, progress_receiver) = crossbeam_channel::unbounded();
@ -80,10 +79,10 @@ pub(crate) fn parallel_prime_caches(
for _ in 0..num_worker_threads {
let worker = prime_caches_worker.clone();
let db = db.snapshot();
s.spawn(move |_| worker(db));
std::thread::spawn(move || Cancelled::catch(|| worker(db)));
}
let crates_total = crates_to_prime.len();
let crates_total = crates_to_prime.pending();
let mut crates_done = 0;
// an index map is used to preserve ordering so we can sort the progress report in order of
@ -130,8 +129,6 @@ pub(crate) fn parallel_prime_caches(
cb(progress);
}
})
.unwrap();
}
fn compute_crates_to_prime(db: &RootDatabase, graph: &CrateGraph) -> FxHashSet<CrateId> {

View file

@ -56,12 +56,12 @@ where
TopologicSortIterBuilder::new()
}
pub(crate) fn len(&self) -> usize {
pub(crate) fn pending(&self) -> usize {
self.nodes.len()
}
pub(crate) fn is_empty(&self) -> bool {
self.len() == 0
self.nodes.len() == 0 && self.ready.len() == 0
}
pub(crate) fn mark_done(&mut self, item: T) {