diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-04-13 12:37:12 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-04-13 12:41:02 +0300 |
commit | 97ae0f22cd5709e4a1af532d594012426c2b364e (patch) | |
tree | 7f6673ffbc03e928952f7de5bf80cbc84412a394 /source/blender/blenlib | |
parent | 890e533c7695927212a6164c0ca86ff7a314bf5f (diff) |
Depsgraph debug: Remove hardcoded array of BLENDER_MAX_THREADS elements
Allocate statistics array dynamically, so increasing max number of threads does
not increase sloppyness of the memory usage.
For the further cleanups: we can try alloca-ing this array, but it's also not
really safe because we can have quite huge number of threads in the future.
Plus statistics will allocate memory for each individual entry, so using alloca
is not going to give anything beneficial here.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_task.h | 3 | ||||
-rw-r--r-- | source/blender/blenlib/intern/task.c | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h index 2eaec024ce2..780b0bfbbd6 100644 --- a/source/blender/blenlib/BLI_task.h +++ b/source/blender/blenlib/BLI_task.h @@ -88,6 +88,9 @@ void BLI_task_pool_cancel(TaskPool *pool); /* stop all worker threads */ void BLI_task_pool_stop(TaskPool *pool); +/* get number of threads allowed to be used by this pool */ +int BLI_pool_get_num_threads(TaskPool *pool); + /* set number of threads allowed to be used by this pool */ void BLI_pool_set_num_threads(TaskPool *pool, int num_threads); diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c index d187a8d1968..f442a6219a5 100644 --- a/source/blender/blenlib/intern/task.c +++ b/source/blender/blenlib/intern/task.c @@ -417,6 +417,16 @@ void BLI_task_pool_work_and_wait(TaskPool *pool) BLI_mutex_unlock(&pool->num_mutex); } +int BLI_pool_get_num_threads(TaskPool *pool) +{ + if (pool->num_threads != 0) { + return pool->num_threads; + } + else { + return BLI_task_scheduler_num_threads(pool->scheduler); + } +} + void BLI_pool_set_num_threads(TaskPool *pool, int num_threads) { /* NOTE: Don't try to modify threads while tasks are running! */ |