Skip to content

Commit

Permalink
change Arc to immutable reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Hsu committed Apr 14, 2022
1 parent ffe2c95 commit 88331ca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/bevy_tasks/src/single_threaded_task_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ impl TaskPool {
let executor: &'env async_executor::LocalExecutor<'env> =
unsafe { mem::transmute(executor) };

let results: Mutex<Vec<Arc<Mutex<Option<T>>>>> = Mutex::new(Vec::new());
let results: &'env Mutex<Vec<Arc<Mutex<Option<T>>>>> = unsafe { mem::transmute(&results) };

let mut scope = Scope {
executor,
results: Arc::new(Mutex::new(Vec::new())),
results,
scope: PhantomData,
};

Expand Down Expand Up @@ -126,7 +129,7 @@ impl FakeTask {
pub struct Scope<'scope, 'env: 'scope, T> {
executor: &'env async_executor::LocalExecutor<'env>,
// Vector to gather results of all futures spawned during scope run
results: Arc<Mutex<Vec<Arc<Mutex<Option<T>>>>>>,
results: &'env Mutex<Vec<Arc<Mutex<Option<T>>>>>,
scope: PhantomData<&'scope ()>,
}

Expand Down

0 comments on commit 88331ca

Please sign in to comment.