Merge pull request #84847 from RandomShaper/lang_init_term

Let languages init & finish run without locks held
This commit is contained in:
Rémi Verschelde 2023-11-14 19:31:37 +01:00
commit a28476d1cd
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -223,26 +223,48 @@ void ScriptServer::init_languages() {
}
}
HashSet<ScriptLanguage *> langs_to_init;
{
MutexLock lock(languages_mutex);
for (int i = 0; i < _language_count; i++) {
_languages[i]->init();
if (_languages[i]) {
langs_to_init.insert(_languages[i]);
}
}
}
for (ScriptLanguage *E : langs_to_init) {
E->init();
}
{
MutexLock lock(languages_mutex);
languages_ready = true;
}
}
void ScriptServer::finish_languages() {
MutexLock lock(languages_mutex);
HashSet<ScriptLanguage *> langs_to_finish;
for (int i = 0; i < _language_count; i++) {
_languages[i]->finish();
{
MutexLock lock(languages_mutex);
for (int i = 0; i < _language_count; i++) {
if (_languages[i]) {
langs_to_finish.insert(_languages[i]);
}
}
}
global_classes_clear();
languages_ready = false;
for (ScriptLanguage *E : langs_to_finish) {
E->finish();
}
{
MutexLock lock(languages_mutex);
languages_ready = false;
}
global_classes_clear();
}
bool ScriptServer::are_languages_initialized() {