mirror of
https://github.com/godotengine/godot.git
synced 2025-10-22 17:33:33 +00:00
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`.
This commit is contained in:
parent
1e57b558f2
commit
18fbdbb456
98 changed files with 739 additions and 1754 deletions
|
@ -1769,13 +1769,10 @@ GDScriptFunction::GDScriptFunction() :
|
|||
#ifdef DEBUG_ENABLED
|
||||
_func_cname = NULL;
|
||||
|
||||
if (GDScriptLanguage::get_singleton()->lock) {
|
||||
GDScriptLanguage::get_singleton()->lock->lock();
|
||||
}
|
||||
GDScriptLanguage::get_singleton()->function_list.add(&function_list);
|
||||
{
|
||||
MutexLock lock(GDScriptLanguage::get_singleton()->lock);
|
||||
|
||||
if (GDScriptLanguage::get_singleton()->lock) {
|
||||
GDScriptLanguage::get_singleton()->lock->unlock();
|
||||
GDScriptLanguage::get_singleton()->function_list.add(&function_list);
|
||||
}
|
||||
|
||||
profile.call_count = 0;
|
||||
|
@ -1793,14 +1790,10 @@ GDScriptFunction::GDScriptFunction() :
|
|||
|
||||
GDScriptFunction::~GDScriptFunction() {
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (GDScriptLanguage::get_singleton()->lock) {
|
||||
GDScriptLanguage::get_singleton()->lock->lock();
|
||||
}
|
||||
GDScriptLanguage::get_singleton()->function_list.remove(&function_list);
|
||||
|
||||
if (GDScriptLanguage::get_singleton()->lock) {
|
||||
GDScriptLanguage::get_singleton()->lock->unlock();
|
||||
}
|
||||
MutexLock lock(GDScriptLanguage::get_singleton()->lock);
|
||||
|
||||
GDScriptLanguage::get_singleton()->function_list.remove(&function_list);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue