mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
Modernize Mutex
- Based on C++11's `mutex` - No more need to allocate-deallocate or check for null - No pointer anymore, just a member variable - Platform-specific implementations no longer needed - Simpler for `NO_THREADS` - `BinaryMutex` added for special cases as the non-recursive version - `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`. - `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
This commit is contained in:
parent
b450036120
commit
4ddcdc031b
99 changed files with 472 additions and 1391 deletions
|
@ -926,13 +926,9 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) {
|
|||
VisualScriptInstance *instance = memnew(VisualScriptInstance);
|
||||
instance->create(Ref<VisualScript>(this), p_this);
|
||||
|
||||
if (VisualScriptLanguage::singleton->lock)
|
||||
VisualScriptLanguage::singleton->lock->lock();
|
||||
|
||||
VisualScriptLanguage::singleton->lock.lock();
|
||||
instances[p_this] = instance;
|
||||
|
||||
if (VisualScriptLanguage::singleton->lock)
|
||||
VisualScriptLanguage::singleton->lock->unlock();
|
||||
VisualScriptLanguage::singleton->lock.unlock();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
@ -2298,13 +2294,9 @@ VisualScriptInstance::VisualScriptInstance() {
|
|||
|
||||
VisualScriptInstance::~VisualScriptInstance() {
|
||||
|
||||
if (VisualScriptLanguage::singleton->lock)
|
||||
VisualScriptLanguage::singleton->lock->lock();
|
||||
|
||||
VisualScriptLanguage::singleton->lock.lock();
|
||||
script->instances.erase(owner);
|
||||
|
||||
if (VisualScriptLanguage::singleton->lock)
|
||||
VisualScriptLanguage::singleton->lock->unlock();
|
||||
VisualScriptLanguage::singleton->lock.unlock();
|
||||
|
||||
for (Map<int, VisualScriptNodeInstance *>::Element *E = instances.front(); E; E = E->next()) {
|
||||
memdelete(E->get());
|
||||
|
@ -2743,9 +2735,6 @@ VisualScriptLanguage::VisualScriptLanguage() {
|
|||
_step = "_step";
|
||||
_subcall = "_subcall";
|
||||
singleton = this;
|
||||
#ifndef NO_THREADS
|
||||
lock = Mutex::create();
|
||||
#endif
|
||||
|
||||
_debug_parse_err_node = -1;
|
||||
_debug_parse_err_file = "";
|
||||
|
@ -2766,9 +2755,6 @@ VisualScriptLanguage::VisualScriptLanguage() {
|
|||
|
||||
VisualScriptLanguage::~VisualScriptLanguage() {
|
||||
|
||||
if (lock)
|
||||
memdelete(lock);
|
||||
|
||||
if (_call_stack) {
|
||||
memdelete_arr(_call_stack);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue