Move the WorkerLocal type from the rustc-rayon fork into rustc_data_structures
This commit is contained in:
parent
c6fb7b9815
commit
64474a40b0
5 changed files with 213 additions and 34 deletions
|
@ -4,6 +4,8 @@ use libloading::Library;
|
|||
use rustc_ast as ast;
|
||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
#[cfg(parallel_compiler)]
|
||||
use rustc_data_structures::sync;
|
||||
use rustc_errors::registry::Registry;
|
||||
use rustc_parse::validate_attr;
|
||||
use rustc_session as session;
|
||||
|
@ -170,6 +172,7 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
|||
use rustc_middle::ty::tls;
|
||||
use rustc_query_impl::{deadlock, QueryContext, QueryCtxt};
|
||||
|
||||
let registry = sync::Registry::new(threads);
|
||||
let mut builder = rayon::ThreadPoolBuilder::new()
|
||||
.thread_name(|_| "rustc".to_string())
|
||||
.acquire_thread_handler(jobserver::acquire_thread)
|
||||
|
@ -200,6 +203,9 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
|||
.build_scoped(
|
||||
// Initialize each new worker thread when created.
|
||||
move |thread: rayon::ThreadBuilder| {
|
||||
// Register the thread for use with the `WorkerLocal` type.
|
||||
registry.register();
|
||||
|
||||
rustc_span::set_session_globals_then(session_globals, || thread.run())
|
||||
},
|
||||
// Run `f` on the first thread in the thread pool.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue