1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

WorkerThreadPool: Enhance lifetime for more flexibility

This commit is contained in:
Pedro J. Estébanez
2024-09-10 11:08:51 +02:00
parent d0dc3896ad
commit 2d1dd41ef5
3 changed files with 23 additions and 8 deletions

View File

@@ -140,6 +140,7 @@ static Engine *engine = nullptr;
static ProjectSettings *globals = nullptr;
static Input *input = nullptr;
static InputMap *input_map = nullptr;
static WorkerThreadPool *worker_thread_pool = nullptr;
static TranslationServer *translation_server = nullptr;
static Performance *performance = nullptr;
static PackedData *packed_data = nullptr;
@@ -690,6 +691,8 @@ Error Main::test_setup() {
register_core_settings(); // Here globals are present.
worker_thread_pool = memnew(WorkerThreadPool);
translation_server = memnew(TranslationServer);
tsman = memnew(TextServerManager);
@@ -800,6 +803,8 @@ void Main::test_cleanup() {
ResourceSaver::remove_custom_savers();
PropertyListHelper::clear_base_helpers();
WorkerThreadPool::get_singleton()->finish();
#ifdef TOOLS_ENABLED
GDExtensionManager::get_singleton()->deinitialize_extensions(GDExtension::INITIALIZATION_LEVEL_EDITOR);
uninitialize_modules(MODULE_INITIALIZATION_LEVEL_EDITOR);
@@ -841,6 +846,9 @@ void Main::test_cleanup() {
if (physics_server_2d_manager) {
memdelete(physics_server_2d_manager);
}
if (worker_thread_pool) {
memdelete(worker_thread_pool);
}
if (globals) {
memdelete(globals);
}
@@ -931,6 +939,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
register_core_settings(); //here globals are present
worker_thread_pool = memnew(WorkerThreadPool);
translation_server = memnew(TranslationServer);
performance = memnew(Performance);
GDREGISTER_CLASS(Performance);
@@ -2620,6 +2629,10 @@ error:
if (translation_server) {
memdelete(translation_server);
}
if (worker_thread_pool) {
worker_thread_pool->finish();
memdelete(worker_thread_pool);
}
if (globals) {
memdelete(globals);
}
@@ -4501,6 +4514,8 @@ void Main::cleanup(bool p_force) {
ResourceLoader::clear_translation_remaps();
ResourceLoader::clear_path_remaps();
WorkerThreadPool::get_singleton()->finish();
ScriptServer::finish_languages();
// Sync pending commands that may have been queued from a different thread during ScriptServer finalization
@@ -4591,6 +4606,9 @@ void Main::cleanup(bool p_force) {
if (physics_server_2d_manager) {
memdelete(physics_server_2d_manager);
}
if (worker_thread_pool) {
memdelete(worker_thread_pool);
}
if (globals) {
memdelete(globals);
}