diff options
| author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2023-05-23 11:05:32 +0200 |
|---|---|---|
| committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2023-12-01 16:42:26 +0100 |
| commit | cba15cd62575654b41636e6fcc6c57825f714a54 (patch) | |
| tree | d5e78e794134fcfcaaf837912686e8a93bda5689 | |
| parent | d76c1d0e516fedc535a2e394ab780cac79203477 (diff) | |
| download | redot-engine-cba15cd62575654b41636e6fcc6c57825f714a54.tar.gz | |
Add WorkerThreadPool::get_thread_index()
| -rw-r--r-- | core/object/worker_thread_pool.cpp | 5 | ||||
| -rw-r--r-- | core/object/worker_thread_pool.h | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/core/object/worker_thread_pool.cpp b/core/object/worker_thread_pool.cpp index 784acadab4..631767219f 100644 --- a/core/object/worker_thread_pool.cpp +++ b/core/object/worker_thread_pool.cpp @@ -535,6 +535,11 @@ void WorkerThreadPool::wait_for_group_task_completion(GroupID p_group) { task_mutex.unlock(); } +int WorkerThreadPool::get_thread_index() { + Thread::ID tid = Thread::get_caller_id(); + return singleton->thread_ids.has(tid) ? singleton->thread_ids[tid] : -1; +} + void WorkerThreadPool::init(int p_thread_count, bool p_use_native_threads_low_priority, float p_low_priority_task_ratio) { ERR_FAIL_COND(threads.size() > 0); if (p_thread_count < 0) { diff --git a/core/object/worker_thread_pool.h b/core/object/worker_thread_pool.h index f323a979f7..dd56f95cae 100644 --- a/core/object/worker_thread_pool.h +++ b/core/object/worker_thread_pool.h @@ -197,6 +197,8 @@ public: _FORCE_INLINE_ int get_thread_count() const { return threads.size(); } static WorkerThreadPool *get_singleton() { return singleton; } + static int get_thread_index(); + void init(int p_thread_count = -1, bool p_use_native_threads_low_priority = true, float p_low_priority_task_ratio = 0.3); void finish(); WorkerThreadPool(); |
