mirror of
https://github.com/Relintai/thread_pool.git
synced 2024-11-12 10:25:29 +01:00
Setup the ThreadPool singleton.
This commit is contained in:
parent
f89e3c59aa
commit
19b27c3da3
4
SCsub
4
SCsub
@ -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",
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,14 @@ SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
ThreadPool *ThreadPool::_instance;
|
||||
|
||||
ThreadPool *ThreadPool::get_singleton() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
ThreadPool::ThreadPool() {
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
ThreadPool::~ThreadPool() {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user