mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-12 20:16:49 +00:00
Change some function names.
A couple of these are quite long, but they do a much better job of explaining what they do, which was non-obvious before.
This commit is contained in:
parent
4ad5de22d1
commit
bf7078615b
@ -159,10 +159,7 @@ pub struct Config {
|
||||
pub registry: Registry,
|
||||
}
|
||||
|
||||
pub fn run_compiler_in_existing_thread_pool<R>(
|
||||
config: Config,
|
||||
f: impl FnOnce(&Compiler) -> R,
|
||||
) -> R {
|
||||
pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R) -> R {
|
||||
let registry = &config.registry;
|
||||
let (sess, codegen_backend) = util::create_session(
|
||||
config.opts,
|
||||
@ -204,17 +201,20 @@ pub fn run_compiler_in_existing_thread_pool<R>(
|
||||
pub fn run_compiler<R: Send>(mut config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
|
||||
log::trace!("run_compiler");
|
||||
let stderr = config.stderr.take();
|
||||
util::spawn_thread_pool(
|
||||
util::setup_callbacks_and_run_in_thread_pool_with_globals(
|
||||
config.opts.edition,
|
||||
config.opts.debugging_opts.threads,
|
||||
&stderr,
|
||||
|| run_compiler_in_existing_thread_pool(config, f),
|
||||
|| create_compiler_and_run(config, f),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn default_thread_pool<R: Send>(edition: edition::Edition, f: impl FnOnce() -> R + Send) -> R {
|
||||
pub fn setup_callbacks_and_run_in_default_thread_pool_with_globals<R: Send>(
|
||||
edition: edition::Edition,
|
||||
f: impl FnOnce() -> R + Send,
|
||||
) -> R {
|
||||
// the 1 here is duplicating code in config.opts.debugging_opts.threads
|
||||
// which also defaults to 1; it ultimately doesn't matter as the default
|
||||
// isn't threaded, and just ignores this parameter
|
||||
util::spawn_thread_pool(edition, 1, &None, f)
|
||||
util::setup_callbacks_and_run_in_thread_pool_with_globals(edition, 1, &None, f)
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ pub fn scoped_thread<F: FnOnce() -> R + Send, R: Send>(cfg: thread::Builder, f:
|
||||
}
|
||||
|
||||
#[cfg(not(parallel_compiler))]
|
||||
pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
|
||||
pub fn setup_callbacks_and_run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
||||
edition: Edition,
|
||||
_threads: usize,
|
||||
stderr: &Option<Arc<Mutex<Vec<u8>>>>,
|
||||
@ -157,7 +157,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
|
||||
}
|
||||
|
||||
#[cfg(parallel_compiler)]
|
||||
pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
|
||||
pub fn setup_callbacks_and_run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
|
||||
edition: Edition,
|
||||
threads: usize,
|
||||
stderr: &Option<Arc<Mutex<Vec<u8>>>>,
|
||||
@ -186,7 +186,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
|
||||
// span_session_globals are captured and set on the new
|
||||
// threads. ty::tls::with_thread_locals sets up thread local
|
||||
// callbacks from librustc_ast.
|
||||
let main_handler = move |thread: ThreadBuilder| {
|
||||
let main_handler = move |thread: rayon::ThreadBuilder| {
|
||||
rustc_ast::SESSION_GLOBALS.set(ast_session_globals, || {
|
||||
rustc_span::SESSION_GLOBALS.set(span_session_globals, || {
|
||||
ty::tls::GCX_PTR.set(&Lock::new(0), || {
|
||||
|
@ -376,7 +376,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||
registry: rustc_driver::diagnostics_registry(),
|
||||
};
|
||||
|
||||
interface::run_compiler_in_existing_thread_pool(config, |compiler| {
|
||||
interface::create_compiler_and_run(config, |compiler| {
|
||||
compiler.enter(|queries| {
|
||||
let sess = compiler.session();
|
||||
|
||||
|
@ -437,7 +437,10 @@ fn main_args(args: &[String]) -> i32 {
|
||||
Ok(opts) => opts,
|
||||
Err(code) => return code,
|
||||
};
|
||||
rustc_interface::interface::default_thread_pool(options.edition, move || main_options(options))
|
||||
rustc_interface::interface::setup_callbacks_and_run_in_default_thread_pool_with_globals(
|
||||
options.edition,
|
||||
move || main_options(options),
|
||||
)
|
||||
}
|
||||
|
||||
fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> i32 {
|
||||
|
Loading…
Reference in New Issue
Block a user