diff options
| author | Celina G. Val <celinval@amazon.com> | 2025-06-11 11:12:32 -0700 |
|---|---|---|
| committer | Celina G. Val <celinval@amazon.com> | 2025-06-11 11:12:32 -0700 |
| commit | 0b9b1df0064396708a5e5ca27fd010ae3ad3a305 (patch) | |
| tree | c854a9e2fd775dba7f0a5e70a2c7be121b5fec0b /compiler/rustc_thread_pool/src/spawn | |
| parent | 35c5144394c1b93784867d330f694fa7c8f480e3 (diff) | |
| download | rust-0b9b1df0064396708a5e5ca27fd010ae3ad3a305.tar.gz rust-0b9b1df0064396708a5e5ca27fd010ae3ad3a305.zip | |
Fix format and tidy for code moved from rayon
Diffstat (limited to 'compiler/rustc_thread_pool/src/spawn')
| -rw-r--r-- | compiler/rustc_thread_pool/src/spawn/mod.rs | 17 | ||||
| -rw-r--r-- | compiler/rustc_thread_pool/src/spawn/tests.rs (renamed from compiler/rustc_thread_pool/src/spawn/test.rs) | 19 |
2 files changed, 14 insertions, 22 deletions
diff --git a/compiler/rustc_thread_pool/src/spawn/mod.rs b/compiler/rustc_thread_pool/src/spawn/mod.rs index 034df30dcfb..f1679a98234 100644 --- a/compiler/rustc_thread_pool/src/spawn/mod.rs +++ b/compiler/rustc_thread_pool/src/spawn/mod.rs @@ -1,9 +1,10 @@ +use std::mem; +use std::sync::Arc; + use crate::job::*; use crate::registry::Registry; use crate::tlv::Tlv; use crate::unwind; -use std::mem; -use std::sync::Arc; /// Puts the task into the Rayon threadpool's job queue in the "static" /// or "global" scope. Just like a standard thread, this task is not @@ -28,9 +29,9 @@ use std::sync::Arc; /// other threads may steal tasks at any time. However, they are /// generally prioritized in a LIFO order on the thread from which /// they were spawned. Other threads always steal from the other end of -/// the deque, like FIFO order. The idea is that "recent" tasks are +/// the deque, like FIFO order. The idea is that "recent" tasks are /// most likely to be fresh in the local CPU's cache, while other -/// threads can steal older "stale" tasks. For an alternate approach, +/// threads can steal older "stale" tasks. For an alternate approach, /// consider [`spawn_fifo()`] instead. /// /// [`spawn_fifo()`]: fn.spawn_fifo.html @@ -39,7 +40,7 @@ use std::sync::Arc; /// /// If this closure should panic, the resulting panic will be /// propagated to the panic handler registered in the `ThreadPoolBuilder`, -/// if any. See [`ThreadPoolBuilder::panic_handler()`][ph] for more +/// if any. See [`ThreadPoolBuilder::panic_handler()`][ph] for more /// details. /// /// [ph]: struct.ThreadPoolBuilder.html#method.panic_handler @@ -103,7 +104,7 @@ where } /// Fires off a task into the Rayon threadpool in the "static" or -/// "global" scope. Just like a standard thread, this task is not +/// "global" scope. Just like a standard thread, this task is not /// tied to the current stack frame, and hence it cannot hold any /// references other than those with `'static` lifetime. If you want /// to spawn a task that references stack data, use [the `scope_fifo()` @@ -124,7 +125,7 @@ where /// /// If this closure should panic, the resulting panic will be /// propagated to the panic handler registered in the `ThreadPoolBuilder`, -/// if any. See [`ThreadPoolBuilder::panic_handler()`][ph] for more +/// if any. See [`ThreadPoolBuilder::panic_handler()`][ph] for more /// details. /// /// [ph]: struct.ThreadPoolBuilder.html#method.panic_handler @@ -152,7 +153,7 @@ where let job_ref = spawn_job(func, registry); // If we're in the pool, use our thread's private fifo for this thread to execute - // in a locally-FIFO order. Otherwise, just use the pool's global injector. + // in a locally-FIFO order. Otherwise, just use the pool's global injector. match registry.current_thread() { Some(worker) => worker.push_fifo(job_ref), None => registry.inject(job_ref), diff --git a/compiler/rustc_thread_pool/src/spawn/test.rs b/compiler/rustc_thread_pool/src/spawn/tests.rs index b7a0535aabf..8a70d2faf9c 100644 --- a/compiler/rustc_thread_pool/src/spawn/test.rs +++ b/compiler/rustc_thread_pool/src/spawn/tests.rs @@ -1,10 +1,9 @@ -use crate::scope; use std::any::Any; -use std::sync::mpsc::channel; use std::sync::Mutex; +use std::sync::mpsc::channel; use super::{spawn, spawn_fifo}; -use crate::ThreadPoolBuilder; +use crate::{ThreadPoolBuilder, scope}; #[test] #[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] @@ -45,10 +44,7 @@ fn panic_fwd() { let builder = ThreadPoolBuilder::new().panic_handler(panic_handler); - builder - .build() - .unwrap() - .spawn(move || panic!("Hello, world!")); + builder.build().unwrap().spawn(move || panic!("Hello, world!")); assert_eq!(1, rx.recv().unwrap()); } @@ -193,10 +189,7 @@ fn fifo_order() { fn lifo_fifo_order() { // LIFO on the outside, FIFO on the inside let vec = test_order!(spawn, spawn_fifo); - let expected: Vec<i32> = (0..10) - .rev() - .flat_map(|i| (0..10).map(move |j| i * 10 + j)) - .collect(); + let expected: Vec<i32> = (0..10).rev().flat_map(|i| (0..10).map(move |j| i * 10 + j)).collect(); assert_eq!(vec, expected); } @@ -205,9 +198,7 @@ fn lifo_fifo_order() { fn fifo_lifo_order() { // FIFO on the outside, LIFO on the inside let vec = test_order!(spawn_fifo, spawn); - let expected: Vec<i32> = (0..10) - .flat_map(|i| (0..10).rev().map(move |j| i * 10 + j)) - .collect(); + let expected: Vec<i32> = (0..10).flat_map(|i| (0..10).rev().map(move |j| i * 10 + j)).collect(); assert_eq!(vec, expected); } |
