mirror of
https://github.com/Relintai/thread_pool.git
synced 2024-11-12 10:25:29 +01:00
4.0 compile fix.
This commit is contained in:
parent
c2aa301896
commit
acc7759682
@ -34,6 +34,8 @@ SOFTWARE.
|
||||
#if VERSION_MAJOR >= 4
|
||||
#define CONNECT(sig, obj, target_method_class, method) connect(sig, callable_mp(obj, &target_method_class::method))
|
||||
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method))
|
||||
|
||||
#define REAL FLOAT
|
||||
#else
|
||||
#define CONNECT(sig, obj, target_method_class, method) connect(sig, obj, #method)
|
||||
#define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, obj, #method)
|
||||
@ -164,7 +166,6 @@ Ref<ThreadPoolJob> ThreadPool::get_queued_job(const Variant &object, const Strin
|
||||
}
|
||||
|
||||
void ThreadPool::add_job(const Ref<ThreadPoolJob> &job) {
|
||||
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
if (_use_threads) {
|
||||
@ -276,7 +277,6 @@ Variant ThreadPool::_create_job_bind(const Variant **p_args, int p_argcount, Cal
|
||||
}
|
||||
|
||||
void ThreadPool::_thread_finished(ThreadPoolContext *context) {
|
||||
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
if (_current_queue_head != _current_queue_tail) {
|
||||
@ -361,7 +361,11 @@ ThreadPool::ThreadPool() {
|
||||
ThreadPoolContext *context = memnew(ThreadPoolContext);
|
||||
|
||||
context->running = true;
|
||||
#if VERSION_MAJOR < 4
|
||||
context->semaphore = Semaphore::create();
|
||||
#else
|
||||
context->semaphore = memnew(Semaphore);
|
||||
#endif
|
||||
context->thread = Thread::create(ThreadPool::_worker_thread_func, context);
|
||||
|
||||
_threads.write[i] = context;
|
||||
|
@ -25,6 +25,8 @@ SOFTWARE.
|
||||
#include "core/os/os.h"
|
||||
#include "core/variant.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
Variant ThreadPoolExecuteJob::get_object() const {
|
||||
return _object;
|
||||
}
|
||||
@ -44,9 +46,16 @@ void ThreadPoolExecuteJob::_execute() {
|
||||
ERR_FAIL_COND(!_object->has_method(_method));
|
||||
|
||||
set_current_run_stage(0);
|
||||
|
||||
#if VERSION_MAJOR < 4
|
||||
set_start_time(OS::get_singleton()->get_system_time_msecs());
|
||||
|
||||
Variant::CallError error;
|
||||
#else
|
||||
set_start_time(OS::get_singleton()->get_ticks_msec());
|
||||
|
||||
Callable::CallError error;
|
||||
#endif
|
||||
|
||||
_object->call(_method, const_cast<const Variant **>(&_argptr), _argcount, error);
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ SOFTWARE.
|
||||
#include "core/os/os.h"
|
||||
#include "core/variant.h"
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
bool ThreadPoolJob::get_complete() const {
|
||||
return _complete;
|
||||
}
|
||||
@ -89,7 +91,11 @@ void ThreadPoolJob::set_method(const StringName &value) {
|
||||
}
|
||||
|
||||
float ThreadPoolJob::get_current_execution_time() {
|
||||
#if VERSION_MAJOR < 4
|
||||
return (OS::get_singleton()->get_system_time_msecs() - _start_time) / 1000.0;
|
||||
#else
|
||||
return (OS::get_singleton()->get_ticks_msec() - _start_time) / 1000.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ThreadPoolJob::should_do(const bool just_check) {
|
||||
|
Loading…
Reference in New Issue
Block a user