summaryrefslogtreecommitdiffstats
path: root/core/io/resource.h
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2022-06-22 13:46:46 +0200
committerreduz <reduzio@gmail.com>2022-06-22 13:46:46 +0200
commite772b65d92dbd5b36fb003458d7fe0fd528abcea (patch)
treeaca74602fef05e8f80689345af9ba2e33afe846d /core/io/resource.h
parentc18d0f20357a11bd9cfa2f57b8b9b500763413bc (diff)
downloadredot-engine-e772b65d92dbd5b36fb003458d7fe0fd528abcea.tar.gz
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
Diffstat (limited to 'core/io/resource.h')
-rw-r--r--core/io/resource.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/io/resource.h b/core/io/resource.h
index a45bc6e1e4..a2cde87990 100644
--- a/core/io/resource.h
+++ b/core/io/resource.h
@@ -153,7 +153,7 @@ public:
class ResourceCache {
friend class Resource;
friend class ResourceLoader; //need the lock
- static RWLock lock;
+ static Mutex lock;
static HashMap<String, Resource *> resources;
#ifdef TOOLS_ENABLED
static HashMap<String, HashMap<String, String>> resource_path_cache; // Each tscn has a set of resource paths and IDs.
@@ -166,7 +166,7 @@ class ResourceCache {
public:
static void reload_externals();
static bool has(const String &p_path);
- static Resource *get(const String &p_path);
+ static Ref<Resource> get_ref(const String &p_path);
static void dump(const char *p_file = nullptr, bool p_short = false);
static void get_cached_resources(List<Ref<Resource>> *p_resources);
static int get_cached_resource_count();