Updated for the new 3.2 godot branch - Threading/Semaphore refactor - (f15f5b45781eb3de8e5811400f654e3e49580149).

This commit is contained in:
Relintai 2021-02-20 22:42:20 +01:00
parent 72049428df
commit da4e049da0

View File

@ -400,18 +400,10 @@ ThreadPool::ThreadPool() {
ThreadPoolContext *context = memnew(ThreadPoolContext);
context->running = true;
#if VERSION_MAJOR < 4
context->semaphore = Semaphore::create();
#else
context->semaphore = memnew(Semaphore);
#endif
#if VERSION_MAJOR < 4
context->thread = Thread::create(ThreadPool::_worker_thread_func, context);
#else
context->thread = memnew(Thread());
context->thread->start(ThreadPool::_worker_thread_func, context);
#endif
_threads.write[i] = context;
}
@ -431,11 +423,7 @@ ThreadPool::~ThreadPool() {
for (int i = 0; i < _threads.size(); ++i) {
ThreadPoolContext *context = _threads.get(i);
#if VERSION_MAJOR < 4
Thread::wait_to_finish(context->thread);
#else
context->thread->wait_to_finish();
#endif
memdelete(context->thread);
memdelete(context->semaphore);