Fix potential deadlock in AssetServer
on single-threaded modes. (#15808)
# Objective Fixes #15807 ## Solution We move the guard into this function. ## Testing N/A, This is just reverting to the old behavior before #15509.
This commit is contained in:
parent
cdd71afde5
commit
60a9a81602
@ -36,7 +36,7 @@ use either::Either;
|
|||||||
use futures_lite::{FutureExt, StreamExt};
|
use futures_lite::{FutureExt, StreamExt};
|
||||||
use info::*;
|
use info::*;
|
||||||
use loaders::*;
|
use loaders::*;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::{RwLock, RwLockWriteGuard};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
/// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader). This can be used to kick off new asset loads and
|
/// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader). This can be used to kick off new asset loads and
|
||||||
@ -383,7 +383,7 @@ impl AssetServer {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if should_load {
|
if should_load {
|
||||||
self.spawn_load_task(handle.clone().untyped(), path, &mut infos, guard);
|
self.spawn_load_task(handle.clone().untyped(), path, infos, guard);
|
||||||
}
|
}
|
||||||
|
|
||||||
handle
|
handle
|
||||||
@ -407,7 +407,7 @@ impl AssetServer {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if should_load {
|
if should_load {
|
||||||
self.spawn_load_task(handle.clone(), path, &mut infos, guard);
|
self.spawn_load_task(handle.clone(), path, infos, guard);
|
||||||
}
|
}
|
||||||
|
|
||||||
handle
|
handle
|
||||||
@ -417,7 +417,7 @@ impl AssetServer {
|
|||||||
&self,
|
&self,
|
||||||
handle: UntypedHandle,
|
handle: UntypedHandle,
|
||||||
path: AssetPath<'static>,
|
path: AssetPath<'static>,
|
||||||
infos: &mut AssetInfos,
|
mut infos: RwLockWriteGuard<AssetInfos>,
|
||||||
guard: G,
|
guard: G,
|
||||||
) {
|
) {
|
||||||
// drop the lock on `AssetInfos` before spawning a task that may block on it in single-threaded
|
// drop the lock on `AssetInfos` before spawning a task that may block on it in single-threaded
|
||||||
|
Loading…
Reference in New Issue
Block a user