diff options
| author | Rémi Verschelde <remi@verschelde.fr> | 2021-01-31 15:24:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-31 15:24:56 +0100 |
| commit | 5525cd85c60455b0bb9716bbef0ad2ad8111d752 (patch) | |
| tree | 52ff0e2d3e01dd2655feff1cf88f07e10d84aad1 /core/os/threaded_array_processor.h | |
| parent | 02eb11450b4151b02db861b5029783e52e16c603 (diff) | |
| parent | 99fe462452be44efa618e83ad9bbecd722ae6ecd (diff) | |
| download | redot-engine-5525cd85c60455b0bb9716bbef0ad2ad8111d752.tar.gz | |
Merge pull request #45315 from RandomShaper/modernize_thread
Modernize Thread
Diffstat (limited to 'core/os/threaded_array_processor.h')
| -rw-r--r-- | core/os/threaded_array_processor.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/core/os/threaded_array_processor.h b/core/os/threaded_array_processor.h index 57f3de20bf..9538ac5957 100644 --- a/core/os/threaded_array_processor.h +++ b/core/os/threaded_array_processor.h @@ -74,18 +74,17 @@ void thread_process_array(uint32_t p_elements, C *p_instance, M p_method, U p_us data.elements = p_elements; data.process(data.index); //process first, let threads increment for next - Vector<Thread *> threads; + int thread_count = OS::get_singleton()->get_processor_count(); + Thread *threads = memnew_arr(Thread, thread_count); - threads.resize(OS::get_singleton()->get_processor_count()); - - for (int i = 0; i < threads.size(); i++) { - threads.write[i] = Thread::create(process_array_thread<ThreadArrayProcessData<C, U>>, &data); + for (int i = 0; i < thread_count; i++) { + threads[i].start(process_array_thread<ThreadArrayProcessData<C, U>>, &data); } - for (int i = 0; i < threads.size(); i++) { - Thread::wait_to_finish(threads[i]); - memdelete(threads[i]); + for (int i = 0; i < thread_count; i++) { + threads[i].wait_to_finish(); } + memdelete_arr(threads); } #else |
