You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Remake resource thread safety and API
* Ensures thread safety when resources are destroyed. * Simplified API by always forcing `ResourceCache::get_ref`, which needs less hacks and is fully thread safe. * Removed RWLock for resources because its not possible to use for the new logic. Should not be a problem. Supersedes #57533
This commit is contained in:
@@ -693,7 +693,7 @@ Error ResourceLoaderBinary::load() {
|
||||
}
|
||||
|
||||
if (cache_mode == ResourceFormatLoader::CACHE_MODE_REUSE && ResourceCache::has(path)) {
|
||||
Ref<Resource> cached = ResourceCache::get(path);
|
||||
Ref<Resource> cached = ResourceCache::get_ref(path);
|
||||
if (cached.is_valid()) {
|
||||
//already loaded, don't do anything
|
||||
error = OK;
|
||||
@@ -717,10 +717,10 @@ Error ResourceLoaderBinary::load() {
|
||||
|
||||
if (cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE && ResourceCache::has(path)) {
|
||||
//use the existing one
|
||||
Resource *r = ResourceCache::get(path);
|
||||
if (r->get_class() == t) {
|
||||
r->reset_state();
|
||||
res = Ref<Resource>(r);
|
||||
Ref<Resource> cached = ResourceCache::get_ref(path);
|
||||
if (cached->get_class() == t) {
|
||||
cached->reset_state();
|
||||
res = cached;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user