summaryrefslogtreecommitdiff
path: root/modules/mono/csharp_script.h
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2020-02-26 11:28:13 +0100
committerPedro J. Estébanez <pedrojrulez@gmail.com>2020-02-26 20:40:10 +0100
commit18fbdbb456c07a56b358bea2e392765fbcbb3283 (patch)
tree737363d20493afe45e75d932e0c1957dd9a79589 /modules/mono/csharp_script.h
parent1e57b558f215dd4920768e9567b6f55825877c89 (diff)
Reimplement Mutex with C++'s <mutex>
Main: - It's now implemented thanks to `<mutex>`. No more platform-specific implementations. - `BinaryMutex` (non-recursive) is added, as an alternative for special cases. - Doesn't need allocation/deallocation anymore. It can live in the stack and be part of other classes. - Because of that, it's methods are now `const` and the inner mutex is `mutable` so it can be easily used in `const` contexts. - A no-op implementation is provided if `NO_THREADS` is defined. No more need to add `#ifdef NO_THREADS` just for this. - `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`. - Thread-safe utilities are therefore simpler now. Misc.: - `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same. - Every case of lock, do-something, unlock is replaced by `MutexLock` (complex cases where it's not straightfoward are kept as as explicit lock and unlock). - `ShaderRD` contained an `std::mutex`, which has been replaced by `Mutex`.
Diffstat (limited to 'modules/mono/csharp_script.h')
-rw-r--r--modules/mono/csharp_script.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index 627218eaf5..f44c4aebc4 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -325,16 +325,16 @@ class CSharpLanguage : public ScriptLanguage {
GDMono *gdmono;
SelfList<CSharpScript>::List script_list;
- Mutex *script_instances_mutex;
- Mutex *script_gchandle_release_mutex;
- Mutex *language_bind_mutex;
+ Mutex script_instances_mutex;
+ Mutex script_gchandle_release_mutex;
+ Mutex language_bind_mutex;
Map<Object *, CSharpScriptBinding> script_bindings;
#ifdef DEBUG_ENABLED
// List of unsafe object references
Map<ObjectID, int> unsafe_object_references;
- Mutex *unsafe_object_references_lock;
+ Mutex unsafe_object_references_lock;
#endif
struct StringNameCache {
@@ -376,7 +376,7 @@ class CSharpLanguage : public ScriptLanguage {
public:
StringNameCache string_names;
- Mutex *get_language_bind_mutex() { return language_bind_mutex; }
+ const Mutex &get_language_bind_mutex() { return language_bind_mutex; }
_FORCE_INLINE_ int get_language_index() { return lang_idx; }
void set_language_index(int p_idx);