mirror of
https://github.com/rui314/mold.git
synced 2026-11-09 04:49:33 -10:00
Borrow test jobs and the work counter in scoped threads
This commit is contained in:
1 parent
df5c9e146d
commit
96ea73e773
1 file changed
+3
-4
+3
-4
@@ -681,15 +681,14 @@ fn run_jobs(root: &Path, jobs: Vec<TestJob>, options: &Options) -> Vec<TestResul
|
||||
if jobs.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let jobs = Arc::new(jobs);
|
||||
let next = Arc::new(AtomicUsize::new(0));
|
||||
let next = AtomicUsize::new(0);
|
||||
let (sender, receiver) = mpsc::channel();
|
||||
let workers = options.jobs.min(jobs.len());
|
||||
|
||||
thread::scope(|scope| {
|
||||
for _ in 0..workers {
|
||||
let jobs = Arc::clone(&jobs);
|
||||
let next = Arc::clone(&next);
|
||||
let jobs = &jobs;
|
||||
let next = &next;
|
||||
let sender = sender.clone();
|
||||
scope.spawn(move || loop {
|
||||
let index = next.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
Reference in new issue
Block a user