Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2015-09-15 13:51:13 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-09-15 14:57:47 +0300
commit860e25fe29c3f6732860c23dccb1f4813d4e387e (patch)
treee8894268e6041e47c2f5b2ff9e9682e345a0812f /source
parent0c2be4d8e853a4c38f073921e9f01a4a7eeae945 (diff)
Fix T46093: Thumbnails/previews of materials/textures not displaying in Blender filebrowser when only one thread is available.
Using the global scheduler here is not a really good idea - `filelist_cache_previewf()` is not a short task that run once, but it's a loop that keeps cheking for work in a TODO queue. This means it won't quickly allow other tasks to start, so it should not be in the global scheduler. In fact, asynchronous tasks (that is, tasks that will live for quite a bit of time, and often sleep a lot) should never use global scheduler, they would steal computing resources from heavy-duty, short-time living ones - and possibly even completely stall threaded tasks (if all worker threads are executing long-life tasks...). We could probably even completely bypass the scheduler/task thing here (and directly use threads), but it does not have that much of an over-head, and still offers easy handling of threading stuff...
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_file/filelist.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index a4fe7952c36..0d1aff09e9c 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -250,6 +250,7 @@ typedef struct FileListEntryCache {
GHash *uuids;
/* Previews handling. */
+ TaskScheduler *previews_scheduler;
TaskPool *previews_pool;
ThreadQueue *previews_todo;
ThreadQueue *previews_done;
@@ -1100,10 +1101,11 @@ static void filelist_cache_previewf(TaskPool *pool, void *taskdata, int UNUSED(t
static void filelist_cache_preview_ensure_running(FileListEntryCache *cache)
{
if (!cache->previews_pool) {
- TaskScheduler *scheduler = BLI_task_scheduler_get();
+ TaskScheduler *scheduler;
TaskPool *pool;
- int num_tasks = max_ii(2, BLI_system_thread_count() / 2);
+ int num_tasks = max_ii(1, (BLI_system_thread_count() / 2) + 1);
+ scheduler = cache->previews_scheduler = BLI_task_scheduler_create(num_tasks + 1);
pool = cache->previews_pool = BLI_task_pool_create(scheduler, NULL);
cache->previews_todo = BLI_thread_queue_init();
cache->previews_done = BLI_thread_queue_init();
@@ -1150,6 +1152,8 @@ static void filelist_cache_previews_free(FileListEntryCache *cache, const bool s
BLI_thread_queue_free(cache->previews_done);
BLI_thread_queue_free(cache->previews_todo);
BLI_task_pool_free(cache->previews_pool);
+ BLI_task_scheduler_free(cache->previews_scheduler);
+ cache->previews_scheduler = NULL;
cache->previews_pool = NULL;
cache->previews_todo = NULL;
cache->previews_done = NULL;