From 599a0e5dc72dc487cfeee9f8cb0b8597daf8c126 Mon Sep 17 00:00:00 2001 From: Folkert Date: Wed, 16 Feb 2022 14:18:28 +0100 Subject: [PATCH] move things out of thread scope --- compiler/load/src/file.rs | 40 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index 2b03eb90d4..6fbaa47a8e 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -1290,18 +1290,29 @@ fn load_multi_threaded<'a>( let it = worker_arenas.iter_mut(); + let mut state = State::new( + root_id, + target_info, + goal_phase, + stdlib, + exposed_types, + arc_modules, + ident_ids_by_module, + ); + + for _ in 0..num_workers { + let worker = Worker::new_lifo(); + + stealers.push(worker.stealer()); + worker_queues.push(worker); + } + + // Get a reference to the completed stealers, so we can send that + // reference to each worker. (Slices are Sync, but bumpalo Vecs are not.) + let stealers = stealers.into_bump_slice(); + { thread::scope(|thread_scope| { - for _ in 0..num_workers { - let worker = Worker::new_lifo(); - - stealers.push(worker.stealer()); - worker_queues.push(worker); - } - - // Get a reference to the completed stealers, so we can send that - // reference to each worker. (Slices are Sync, but bumpalo Vecs are not.) - let stealers = stealers.into_bump_slice(); let mut worker_listeners = bumpalo::collections::Vec::with_capacity_in(num_workers, arena); @@ -1341,15 +1352,6 @@ fn load_multi_threaded<'a>( res_join_handle.unwrap(); } - let mut state = State::new( - root_id, - target_info, - goal_phase, - stdlib, - exposed_types, - arc_modules, - ident_ids_by_module, - ); // We've now distributed one worker queue to each thread. // There should be no queues left to distribute!