|
@@ -101,15 +101,9 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
|
|
|
|
|
|
/* STEP 2, INITIALIZE AND CONSTRUCT */
|
|
/* STEP 2, INITIALIZE AND CONSTRUCT */
|
|
|
|
|
|
-#ifndef NO_THREADS
|
|
|
|
- GDScriptLanguage::singleton->lock->lock();
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
|
|
+ GDScriptLanguage::singleton->lock.lock();
|
|
instances.insert(instance->owner);
|
|
instances.insert(instance->owner);
|
|
-
|
|
|
|
-#ifndef NO_THREADS
|
|
|
|
- GDScriptLanguage::singleton->lock->unlock();
|
|
|
|
-#endif
|
|
|
|
|
|
+ GDScriptLanguage::singleton->lock.unlock();
|
|
|
|
|
|
initializer->call(instance, p_args, p_argcount, r_error);
|
|
initializer->call(instance, p_args, p_argcount, r_error);
|
|
|
|
|
|
@@ -117,11 +111,11 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
|
|
instance->script = Ref<GDScript>();
|
|
instance->script = Ref<GDScript>();
|
|
instance->owner->set_script_instance(NULL);
|
|
instance->owner->set_script_instance(NULL);
|
|
#ifndef NO_THREADS
|
|
#ifndef NO_THREADS
|
|
- GDScriptLanguage::singleton->lock->lock();
|
|
|
|
|
|
+ GDScriptLanguage::singleton->lock.lock();
|
|
#endif
|
|
#endif
|
|
instances.erase(p_owner);
|
|
instances.erase(p_owner);
|
|
#ifndef NO_THREADS
|
|
#ifndef NO_THREADS
|
|
- GDScriptLanguage::singleton->lock->unlock();
|
|
|
|
|
|
+ GDScriptLanguage::singleton->lock.unlock();
|
|
#endif
|
|
#endif
|
|
|
|
|
|
ERR_FAIL_COND_V(r_error.error != Variant::CallError::CALL_OK, NULL); //error constructing
|
|
ERR_FAIL_COND_V(r_error.error != Variant::CallError::CALL_OK, NULL); //error constructing
|
|
@@ -343,14 +337,9 @@ PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this)
|
|
|
|
|
|
bool GDScript::instance_has(const Object *p_this) const {
|
|
bool GDScript::instance_has(const Object *p_this) const {
|
|
|
|
|
|
-#ifndef NO_THREADS
|
|
|
|
- GDScriptLanguage::singleton->lock->lock();
|
|
|
|
-#endif
|
|
|
|
|
|
+ GDScriptLanguage::singleton->lock.lock();
|
|
bool hasit = instances.has((Object *)p_this);
|
|
bool hasit = instances.has((Object *)p_this);
|
|
-
|
|
|
|
-#ifndef NO_THREADS
|
|
|
|
- GDScriptLanguage::singleton->lock->unlock();
|
|
|
|
-#endif
|
|
|
|
|
|
+ GDScriptLanguage::singleton->lock.unlock();
|
|
|
|
|
|
return hasit;
|
|
return hasit;
|
|
}
|
|
}
|
|
@@ -564,14 +553,9 @@ void GDScript::_set_subclass_path(Ref<GDScript> &p_sc, const String &p_path) {
|
|
|
|
|
|
Error GDScript::reload(bool p_keep_state) {
|
|
Error GDScript::reload(bool p_keep_state) {
|
|
|
|
|
|
-#ifndef NO_THREADS
|
|
|
|
- GDScriptLanguage::singleton->lock->lock();
|
|
|
|
-#endif
|
|
|
|
|
|
+ GDScriptLanguage::singleton->lock.lock();
|
|
bool has_instances = instances.size();
|
|
bool has_instances = instances.size();
|
|
-
|
|
|
|
-#ifndef NO_THREADS
|
|
|
|
- GDScriptLanguage::singleton->lock->unlock();
|
|
|
|
-#endif
|
|
|
|
|
|
+ GDScriptLanguage::singleton->lock.unlock();
|
|
|
|
|
|
ERR_FAIL_COND_V(!p_keep_state && has_instances, ERR_ALREADY_IN_USE);
|
|
ERR_FAIL_COND_V(!p_keep_state && has_instances, ERR_ALREADY_IN_USE);
|
|
|
|
|
|
@@ -926,14 +910,9 @@ GDScript::GDScript() :
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
- if (GDScriptLanguage::get_singleton()->lock) {
|
|
|
|
- GDScriptLanguage::get_singleton()->lock->lock();
|
|
|
|
- }
|
|
|
|
|
|
+ GDScriptLanguage::get_singleton()->lock.lock();
|
|
GDScriptLanguage::get_singleton()->script_list.add(&script_list);
|
|
GDScriptLanguage::get_singleton()->script_list.add(&script_list);
|
|
-
|
|
|
|
- if (GDScriptLanguage::get_singleton()->lock) {
|
|
|
|
- GDScriptLanguage::get_singleton()->lock->unlock();
|
|
|
|
- }
|
|
|
|
|
|
+ GDScriptLanguage::get_singleton()->lock.unlock();
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
@@ -970,18 +949,14 @@ void GDScript::_save_orphaned_subclasses() {
|
|
|
|
|
|
GDScript::~GDScript() {
|
|
GDScript::~GDScript() {
|
|
|
|
|
|
- if (GDScriptLanguage::get_singleton()->lock) {
|
|
|
|
- GDScriptLanguage::get_singleton()->lock->lock();
|
|
|
|
- }
|
|
|
|
|
|
+ GDScriptLanguage::get_singleton()->lock.lock();
|
|
while (SelfList<GDScriptFunctionState> *E = pending_func_states.first()) {
|
|
while (SelfList<GDScriptFunctionState> *E = pending_func_states.first()) {
|
|
// Order matters since clearing the stack may already cause
|
|
// Order matters since clearing the stack may already cause
|
|
// the GDSCriptFunctionState to be destroyed and thus removed from the list.
|
|
// the GDSCriptFunctionState to be destroyed and thus removed from the list.
|
|
pending_func_states.remove(E);
|
|
pending_func_states.remove(E);
|
|
E->self()->_clear_stack();
|
|
E->self()->_clear_stack();
|
|
}
|
|
}
|
|
- if (GDScriptLanguage::get_singleton()->lock) {
|
|
|
|
- GDScriptLanguage::get_singleton()->lock->unlock();
|
|
|
|
- }
|
|
|
|
|
|
+ GDScriptLanguage::get_singleton()->lock.unlock();
|
|
|
|
|
|
for (Map<StringName, GDScriptFunction *>::Element *E = member_functions.front(); E; E = E->next()) {
|
|
for (Map<StringName, GDScriptFunction *>::Element *E = member_functions.front(); E; E = E->next()) {
|
|
memdelete(E->get());
|
|
memdelete(E->get());
|
|
@@ -990,14 +965,9 @@ GDScript::~GDScript() {
|
|
_save_orphaned_subclasses();
|
|
_save_orphaned_subclasses();
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
- if (GDScriptLanguage::get_singleton()->lock) {
|
|
|
|
- GDScriptLanguage::get_singleton()->lock->lock();
|
|
|
|
- }
|
|
|
|
|
|
+ GDScriptLanguage::get_singleton()->lock.lock();
|
|
GDScriptLanguage::get_singleton()->script_list.remove(&script_list);
|
|
GDScriptLanguage::get_singleton()->script_list.remove(&script_list);
|
|
-
|
|
|
|
- if (GDScriptLanguage::get_singleton()->lock) {
|
|
|
|
- GDScriptLanguage::get_singleton()->lock->unlock();
|
|
|
|
- }
|
|
|
|
|
|
+ GDScriptLanguage::get_singleton()->lock.unlock();
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1400,9 +1370,7 @@ GDScriptInstance::GDScriptInstance() {
|
|
}
|
|
}
|
|
|
|
|
|
GDScriptInstance::~GDScriptInstance() {
|
|
GDScriptInstance::~GDScriptInstance() {
|
|
-#ifndef NO_THREADS
|
|
|
|
- GDScriptLanguage::singleton->lock->lock();
|
|
|
|
-#endif
|
|
|
|
|
|
+ GDScriptLanguage::singleton->lock.lock();
|
|
|
|
|
|
while (SelfList<GDScriptFunctionState> *E = pending_func_states.first()) {
|
|
while (SelfList<GDScriptFunctionState> *E = pending_func_states.first()) {
|
|
// Order matters since clearing the stack may already cause
|
|
// Order matters since clearing the stack may already cause
|
|
@@ -1415,9 +1383,7 @@ GDScriptInstance::~GDScriptInstance() {
|
|
script->instances.erase(owner);
|
|
script->instances.erase(owner);
|
|
}
|
|
}
|
|
|
|
|
|
-#ifndef NO_THREADS
|
|
|
|
- GDScriptLanguage::singleton->lock->unlock();
|
|
|
|
-#endif
|
|
|
|
|
|
+ GDScriptLanguage::singleton->lock.unlock();
|
|
}
|
|
}
|
|
|
|
|
|
/************* SCRIPT LANGUAGE **************/
|
|
/************* SCRIPT LANGUAGE **************/
|
|
@@ -1517,9 +1483,7 @@ void GDScriptLanguage::finish() {
|
|
void GDScriptLanguage::profiling_start() {
|
|
void GDScriptLanguage::profiling_start() {
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
- if (lock) {
|
|
|
|
- lock->lock();
|
|
|
|
- }
|
|
|
|
|
|
+ lock.lock();
|
|
|
|
|
|
SelfList<GDScriptFunction> *elem = function_list.first();
|
|
SelfList<GDScriptFunction> *elem = function_list.first();
|
|
while (elem) {
|
|
while (elem) {
|
|
@@ -1536,25 +1500,16 @@ void GDScriptLanguage::profiling_start() {
|
|
}
|
|
}
|
|
|
|
|
|
profiling = true;
|
|
profiling = true;
|
|
- if (lock) {
|
|
|
|
- lock->unlock();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ lock.unlock();
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
void GDScriptLanguage::profiling_stop() {
|
|
void GDScriptLanguage::profiling_stop() {
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
- if (lock) {
|
|
|
|
- lock->lock();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ lock.lock();
|
|
profiling = false;
|
|
profiling = false;
|
|
- if (lock) {
|
|
|
|
- lock->unlock();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ lock.unlock();
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1562,9 +1517,7 @@ int GDScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr,
|
|
|
|
|
|
int current = 0;
|
|
int current = 0;
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
- if (lock) {
|
|
|
|
- lock->lock();
|
|
|
|
- }
|
|
|
|
|
|
+ lock.lock();
|
|
|
|
|
|
SelfList<GDScriptFunction> *elem = function_list.first();
|
|
SelfList<GDScriptFunction> *elem = function_list.first();
|
|
while (elem) {
|
|
while (elem) {
|
|
@@ -1578,10 +1531,7 @@ int GDScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr,
|
|
current++;
|
|
current++;
|
|
}
|
|
}
|
|
|
|
|
|
- if (lock) {
|
|
|
|
- lock->unlock();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ lock.unlock();
|
|
#endif
|
|
#endif
|
|
|
|
|
|
return current;
|
|
return current;
|
|
@@ -1592,9 +1542,7 @@ int GDScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_
|
|
int current = 0;
|
|
int current = 0;
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
- if (lock) {
|
|
|
|
- lock->lock();
|
|
|
|
- }
|
|
|
|
|
|
+ lock.lock();
|
|
|
|
|
|
SelfList<GDScriptFunction> *elem = function_list.first();
|
|
SelfList<GDScriptFunction> *elem = function_list.first();
|
|
while (elem) {
|
|
while (elem) {
|
|
@@ -1610,10 +1558,7 @@ int GDScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_
|
|
elem = elem->next();
|
|
elem = elem->next();
|
|
}
|
|
}
|
|
|
|
|
|
- if (lock) {
|
|
|
|
- lock->unlock();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ lock.unlock();
|
|
#endif
|
|
#endif
|
|
|
|
|
|
return current;
|
|
return current;
|
|
@@ -1644,9 +1589,7 @@ void GDScriptLanguage::reload_all_scripts() {
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
print_verbose("GDScript: Reloading all scripts");
|
|
print_verbose("GDScript: Reloading all scripts");
|
|
- if (lock) {
|
|
|
|
- lock->lock();
|
|
|
|
- }
|
|
|
|
|
|
+ lock.lock();
|
|
|
|
|
|
List<Ref<GDScript> > scripts;
|
|
List<Ref<GDScript> > scripts;
|
|
|
|
|
|
@@ -1659,9 +1602,7 @@ void GDScriptLanguage::reload_all_scripts() {
|
|
elem = elem->next();
|
|
elem = elem->next();
|
|
}
|
|
}
|
|
|
|
|
|
- if (lock) {
|
|
|
|
- lock->unlock();
|
|
|
|
- }
|
|
|
|
|
|
+ lock.unlock();
|
|
|
|
|
|
//as scripts are going to be reloaded, must proceed without locking here
|
|
//as scripts are going to be reloaded, must proceed without locking here
|
|
|
|
|
|
@@ -1680,9 +1621,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
|
|
|
|
- if (lock) {
|
|
|
|
- lock->lock();
|
|
|
|
- }
|
|
|
|
|
|
+ lock.lock();
|
|
|
|
|
|
List<Ref<GDScript> > scripts;
|
|
List<Ref<GDScript> > scripts;
|
|
|
|
|
|
@@ -1695,9 +1634,7 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so
|
|
elem = elem->next();
|
|
elem = elem->next();
|
|
}
|
|
}
|
|
|
|
|
|
- if (lock) {
|
|
|
|
- lock->unlock();
|
|
|
|
- }
|
|
|
|
|
|
+ lock.unlock();
|
|
|
|
|
|
//when someone asks you why dynamically typed languages are easier to write....
|
|
//when someone asks you why dynamically typed languages are easier to write....
|
|
|
|
|
|
@@ -1816,9 +1753,7 @@ void GDScriptLanguage::frame() {
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
if (profiling) {
|
|
if (profiling) {
|
|
- if (lock) {
|
|
|
|
- lock->lock();
|
|
|
|
- }
|
|
|
|
|
|
+ lock.lock();
|
|
|
|
|
|
SelfList<GDScriptFunction> *elem = function_list.first();
|
|
SelfList<GDScriptFunction> *elem = function_list.first();
|
|
while (elem) {
|
|
while (elem) {
|
|
@@ -1831,9 +1766,7 @@ void GDScriptLanguage::frame() {
|
|
elem = elem->next();
|
|
elem = elem->next();
|
|
}
|
|
}
|
|
|
|
|
|
- if (lock) {
|
|
|
|
- lock->unlock();
|
|
|
|
- }
|
|
|
|
|
|
+ lock.unlock();
|
|
}
|
|
}
|
|
|
|
|
|
#endif
|
|
#endif
|
|
@@ -2202,11 +2135,6 @@ GDScriptLanguage::GDScriptLanguage() {
|
|
_debug_parse_err_line = -1;
|
|
_debug_parse_err_line = -1;
|
|
_debug_parse_err_file = "";
|
|
_debug_parse_err_file = "";
|
|
|
|
|
|
-#ifdef NO_THREADS
|
|
|
|
- lock = NULL;
|
|
|
|
-#else
|
|
|
|
- lock = Mutex::create();
|
|
|
|
-#endif
|
|
|
|
profiling = false;
|
|
profiling = false;
|
|
script_frame_time = 0;
|
|
script_frame_time = 0;
|
|
|
|
|
|
@@ -2240,10 +2168,6 @@ GDScriptLanguage::GDScriptLanguage() {
|
|
|
|
|
|
GDScriptLanguage::~GDScriptLanguage() {
|
|
GDScriptLanguage::~GDScriptLanguage() {
|
|
|
|
|
|
- if (lock) {
|
|
|
|
- memdelete(lock);
|
|
|
|
- lock = NULL;
|
|
|
|
- }
|
|
|
|
if (_call_stack) {
|
|
if (_call_stack) {
|
|
memdelete_arr(_call_stack);
|
|
memdelete_arr(_call_stack);
|
|
}
|
|
}
|