1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-14 13:41:12 +00:00

Merge pull request #62309 from reduz/remake-resource-thread-safety

Remake ResourceCache thread safety code and API
This commit is contained in:
Rémi Verschelde
2022-06-25 14:09:28 +02:00
committed by GitHub
15 changed files with 117 additions and 126 deletions

View File

@@ -526,9 +526,9 @@ Error ResourceLoaderText::load() {
if (cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE && ResourceCache::has(path)) {
//reuse existing
Resource *r = ResourceCache::get(path);
if (r && r->get_class() == type) {
res = Ref<Resource>(r);
Ref<Resource> cache = ResourceCache::get_ref(path);
if (cache.is_valid() && cache->get_class() == type) {
res = cache;
res->reset_state();
do_assign = true;
}
@@ -537,10 +537,10 @@ Error ResourceLoaderText::load() {
MissingResource *missing_resource = nullptr;
if (res.is_null()) { //not reuse
if (cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE && ResourceCache::has(path)) { //only if it doesn't exist
Ref<Resource> cache = ResourceCache::get_ref(path);
if (cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE && cache.is_valid()) { //only if it doesn't exist
//cached, do not assign
Resource *r = ResourceCache::get(path);
res = Ref<Resource>(r);
res = cache;
} else {
//create
@@ -650,12 +650,10 @@ Error ResourceLoaderText::load() {
return error;
}
if (cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE && ResourceCache::has(local_path)) {
Resource *r = ResourceCache::get(local_path);
if (r->get_class() == res_type) {
r->reset_state();
resource = Ref<Resource>(r);
}
Ref<Resource> cache = ResourceCache::get_ref(local_path);
if (cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE && cache.is_valid() && cache->get_class() == res_type) {
cache->reset_state();
resource = cache;
}
MissingResource *missing_resource = nullptr;