Removed limit execution time, and made everything a simple stub when ThreadPool is not present.

This commit is contained in:
Relintai 2020-08-04 10:52:27 +02:00
parent f1bee24803
commit b0a888d595
2 changed files with 8 additions and 52 deletions

View File

@ -24,10 +24,6 @@ SOFTWARE.
#include "voxel_chunk_default.h"
#include "core/os/os.h"
#include "core/version.h"
void VoxelJob::set_chunk(const Ref<VoxelChunkDefault> &chunk) {
_chunk = chunk;
@ -53,14 +49,15 @@ void VoxelJob::_execute() {
//_chunk->set_build_step_in_progress(true);
while (!get_cancelled() && _in_tree && _chunk->has_next_phase() && _chunk->get_active_build_phase_type() == VoxelChunkDefault::BUILD_PHASE_TYPE_NORMAL) {
if (should_return())
return;
//int phase = _chunk->get_current_build_phase();
int phase = _chunk->get_current_build_phase();
_chunk->build_phase();
//print_error(String::num(get_current_execution_time()) + " phase: " + String::num(phase));
print_error(String::num(get_current_execution_time()) + " phase: " + String::num(phase));
if (should_return())
return;
if (!_chunk->get_build_phase_done())
break;
@ -83,7 +80,6 @@ VoxelJob::VoxelJob() {
_complete = true;
_cancelled = false;
_limit_execution_time = false;
_max_allocated_time = 0;
_start_time = 0;
@ -104,10 +100,6 @@ void VoxelJob::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_complete", "value"), &VoxelJob::set_complete);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "complete"), "set_complete", "get_complete");
ClassDB::bind_method(D_METHOD("get_limit_execution_time"), &VoxelJob::get_limit_execution_time);
ClassDB::bind_method(D_METHOD("set_limit_execution_time", "value"), &VoxelJob::set_limit_execution_time);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "limit_execution_time"), "set_limit_execution_time", "get_limit_execution_time");
ClassDB::bind_method(D_METHOD("get_start_time"), &VoxelJob::get_start_time);
ClassDB::bind_method(D_METHOD("set_start_time", "value"), &VoxelJob::set_start_time);
ADD_PROPERTY(PropertyInfo(Variant::INT, "start_time"), "set_start_time", "get_start_time");
@ -147,13 +139,6 @@ void VoxelJob::set_cancelled(const bool value) {
_cancelled = value;
}
bool VoxelJob::get_limit_execution_time() const {
return _limit_execution_time;
}
void VoxelJob::set_limit_execution_time(const bool value) {
_limit_execution_time = value;
}
float VoxelJob::get_max_allocated_time() const {
return _max_allocated_time;
}
@ -183,47 +168,22 @@ void VoxelJob::set_stage(const int value) {
}
float VoxelJob::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
return 0;
}
bool VoxelJob::should_do(const bool just_check) {
if (just_check) {
return _current_run_stage == _stage;
}
if (_current_run_stage < _stage) {
++_current_run_stage;
return false;
}
++_current_run_stage;
++_stage;
return false;
return true;
}
bool VoxelJob::should_return() {
if (_cancelled)
return true;
if (!_limit_execution_time)
return false;
return get_current_execution_time() >= _limit_execution_time;
return false;
}
void VoxelJob::execute() {
ERR_FAIL_COND(!has_method("_execute"));
#if VERSION_MAJOR < 4
_start_time = OS::get_singleton()->get_system_time_msecs();
#else
_start_time = OS::get_singleton()->get_ticks_msec();
#endif
call("_execute");
}

View File

@ -67,9 +67,6 @@ public:
bool get_cancelled() const;
void set_cancelled(const bool value);
bool get_limit_execution_time() const;
void set_limit_execution_time(const bool value);
float get_max_allocated_time() const;
void set_max_allocated_time(const float value);
@ -93,7 +90,6 @@ private:
bool _complete;
bool _cancelled;
bool _limit_execution_time;
float _max_allocated_time;
uint64_t _start_time;