Updated register_types.h and cpp to the current godot 4 style.

This commit is contained in:
Relintai 2023-01-08 15:55:39 +01:00
parent 6990f8201a
commit 652dbff8bf
2 changed files with 21 additions and 18 deletions

View File

@ -26,11 +26,9 @@ SOFTWARE.
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/object/class_db.h"
#include "core/config/engine.h"
#else
#include "core/engine.h"
#endif
#include "thread_pool.h"
#include "thread_pool_execute_job.h"
@ -38,18 +36,21 @@ SOFTWARE.
static ThreadPool *thread_pool = NULL;
void register_thread_pool_types() {
void initialize_thread_pool_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
GDREGISTER_CLASS(ThreadPoolJob);
GDREGISTER_CLASS(ThreadPoolExecuteJob);
GDREGISTER_CLASS(ThreadPool);
ClassDB::register_class<ThreadPoolJob>();
ClassDB::register_class<ThreadPoolExecuteJob>();
thread_pool = memnew(ThreadPool);
ClassDB::register_class<ThreadPool>();
Engine::get_singleton()->add_singleton(Engine::Singleton("ThreadPool", ThreadPool::get_singleton()));
}
void unregister_thread_pool_types() {
if (thread_pool) {
memdelete(thread_pool);
thread_pool = memnew(ThreadPool);
Engine::get_singleton()->add_singleton(Engine::Singleton("ThreadPool", ThreadPool::get_singleton()));
}
}
void uninitialize_thread_pool_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
if (thread_pool) {
memdelete(thread_pool);
}
}
}

View File

@ -25,7 +25,9 @@ SOFTWARE.
*/
void register_thread_pool_types();
void unregister_thread_pool_types();
#include "modules/register_module_types.h"
void initialize_thread_pool_module(ModuleInitializationLevel p_level);
void uninitialize_thread_pool_module(ModuleInitializationLevel p_level);
#endif