Compare commits

...

3 Commits

Author SHA1 Message Date
Piotr Osiewicz
b6f43ba45b Worker pool is no longer scoped 2025-11-26 18:33:31 +01:00
Piotr Osiewicz
dc8150d410 project search: Get rid of lifetimes on Worker 2025-11-26 18:21:28 +01:00
Piotr Osiewicz
b9d84e5eef workspace: Fix broken main build after #43518
*cough* merge queue *cough*
2025-11-26 18:21:02 +01:00
2 changed files with 19 additions and 20 deletions

View File

@@ -168,6 +168,7 @@ impl Search {
unnamed_buffers.push(handle)
};
}
let open_buffers = Arc::new(open_buffers);
let executor = cx.background_executor().clone();
let (tx, rx) = unbounded();
let (grab_buffer_snapshot_tx, grab_buffer_snapshot_rx) = unbounded();
@@ -296,24 +297,22 @@ impl Search {
};
let should_find_all_matches = !tx.is_closed();
let num_cpus = executor.num_cpus();
let worker_pool = executor.scoped(|scope| {
let num_cpus = executor.num_cpus();
assert!(num_cpus > 0);
for _ in 0..executor.num_cpus() - 1 {
assert!(num_cpus > 0);
let worker_pool = (0..num_cpus - 1)
.map(|_| {
let worker = Worker {
query: &query,
open_buffers: &open_buffers,
query: query.clone(),
open_buffers: open_buffers.clone(),
candidates: candidate_searcher.clone(),
find_all_matches_rx: find_all_matches_rx.clone(),
};
scope.spawn(worker.run());
}
drop(find_all_matches_rx);
drop(candidate_searcher);
});
executor.spawn(worker.run()).boxed_local()
})
.collect::<Vec<_>>();
drop(find_all_matches_rx);
drop(candidate_searcher);
let (sorted_matches_tx, sorted_matches_rx) = unbounded();
// The caller of `into_handle` decides whether they're interested in all matches (files that matched + all matching ranges) or
@@ -348,7 +347,7 @@ impl Search {
};
futures::future::join_all(
[worker_pool.boxed_local()]
worker_pool
.into_iter()
.chain(buffer_snapshots)
.chain(ensure_matches_are_reported_in_order)
@@ -578,9 +577,9 @@ impl Search {
}
}
struct Worker<'search> {
query: &'search SearchQuery,
open_buffers: &'search HashSet<ProjectEntryId>,
struct Worker {
query: Arc<SearchQuery>,
open_buffers: Arc<HashSet<ProjectEntryId>>,
candidates: FindSearchCandidates,
/// Ok, we're back in background: run full scan & find all matches in a given buffer snapshot.
/// Then, when you're done, share them via the channel you were given.
@@ -591,7 +590,7 @@ struct Worker<'search> {
)>,
}
impl Worker<'_> {
impl Worker {
async fn run(self) {
let (
input_paths_rx,
@@ -629,7 +628,7 @@ impl Worker<'_> {
loop {
let handler = RequestHandler {
query: self.query,
query: &self.query,
open_entries: &self.open_buffers,
fs: fs.as_deref(),
confirm_contents_will_match_tx: &confirm_contents_will_match_tx,

View File

@@ -789,7 +789,7 @@ pub mod simple_message_notification {
.track_scroll(&self.scroll_handle.clone())
.child((self.build_content)(window, cx)),
)
.vertical_scrollbar_for(self.scroll_handle.clone(), window, cx),
.vertical_scrollbar_for(&self.scroll_handle, window, cx),
)
.show_close_button(self.show_close_button)
.show_suppress_button(self.show_suppress_button)