Fix compile for 4.0.

This commit is contained in:
Relintai 2021-02-06 11:53:02 +01:00
parent bc0d2f6deb
commit 72049428df
7 changed files with 57 additions and 10 deletions

View File

@ -125,6 +125,7 @@ If you want Godot 3.2:
If you want Godot 4.0:
```git clone https://github.com/godotengine/godot.git godot```
[last tested commit](https://github.com/godotengine/godot/commit/b7e10141197fdd9b0dbc4cfa7890329510d36540)
2. Go into Godot's modules directory.

View File

@ -24,7 +24,13 @@ SOFTWARE.
*/
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/config/engine.h"
#else
#include "core/engine.h"
#endif
#include "thread_pool.h"
#include "thread_pool_execute_job.h"

View File

@ -24,9 +24,17 @@ SOFTWARE.
*/
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/config/engine.h"
#include "core/config/project_settings.h"
#else
#include "core/engine.h"
#include "core/os/os.h"
#include "core/project_settings.h"
#endif
#include "core/os/os.h"
#include "scene/main/scene_tree.h"
#include "core/version.h"
@ -397,7 +405,13 @@ ThreadPool::ThreadPool() {
#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;
}
@ -416,7 +430,12 @@ 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);

View File

@ -25,12 +25,19 @@ SOFTWARE.
*/
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/object/object.h"
#include "core/templates/vector.h"
#else
#include "core/object.h"
#include "core/vector.h"
#endif
#include "core/os/semaphore.h"
#include "core/os/thread.h"
#include "core/os/thread_safe.h"
#include "core/vector.h"
#include "core/version.h"
#include "thread_pool_execute_job.h"
#include "thread_pool_job.h"

View File

@ -22,11 +22,16 @@ SOFTWARE.
#include "thread_pool_execute_job.h"
#include "core/os/os.h"
#include "core/variant.h"
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/variant/variant.h"
#else
#include "core/variant.h"
#endif
#include "core/os/os.h"
Variant ThreadPoolExecuteJob::get_object() const {
return _object;
}

View File

@ -22,11 +22,16 @@ SOFTWARE.
#include "thread_pool_job.h"
#include "core/os/os.h"
#include "core/variant.h"
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/variant/variant.h"
#else
#include "core/variant.h"
#endif
#include "core/os/os.h"
bool ThreadPoolJob::get_complete() const {
return _complete;
}

View File

@ -23,10 +23,14 @@ SOFTWARE.
#ifndef THREAD_POOL_JOB_H
#define THREAD_POOL_JOB_H
#include "core/reference.h"
#include "core/version.h"
#if VERSION_MAJOR > 3
#include "core/object/reference.h"
#else
#include "core/reference.h"
#endif
class ThreadPoolJob : public Reference {
GDCLASS(ThreadPoolJob, Reference);