Setup the ThreadPool singleton.

This commit is contained in:
Relintai 2020-05-24 10:54:15 +02:00
parent f89e3c59aa
commit 19b27c3da3
4 changed files with 22 additions and 6 deletions

4
SCsub
View File

@ -4,10 +4,6 @@ Import('env')
module_env = env.Clone()
#Should work with just arrays
#if os.path.isdir('../mesh_data_resource'):
# module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT'])
sources = [
"register_types.cpp",

View File

@ -1,7 +1,5 @@
#include "register_types.h"
#include "thread_pool.h"
/*
Copyright (c) 2020 Péter Magyar
@ -26,9 +24,21 @@ SOFTWARE.
*/
#include "core/engine.h"
#include "thread_pool.h"
static ThreadPool *thread_pool = NULL;
void register_thread_pool_types() {
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);
}
}

View File

@ -24,7 +24,14 @@ SOFTWARE.
*/
ThreadPool *ThreadPool::_instance;
ThreadPool *ThreadPool::get_singleton() {
return _instance;
}
ThreadPool::ThreadPool() {
_instance = this;
}
ThreadPool::~ThreadPool() {

View File

@ -31,6 +31,8 @@ class ThreadPool : public Object {
GDCLASS(ThreadPool, Object);
public:
static ThreadPool *get_singleton();
ThreadPool();
~ThreadPool();
@ -38,6 +40,7 @@ protected:
static void _bind_methods();
private:
static ThreadPool *_instance;
};
#endif