diff options
Diffstat (limited to 'source/blender/blenlib/intern/threads.c')
-rw-r--r-- | source/blender/blenlib/intern/threads.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index 2812f17d58f..ce9f9adeb90 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -142,10 +142,10 @@ void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot) tslot->do_thread= do_thread; tslot->avail= 1; } + + MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread); + thread_levels++; } - - MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread); - thread_levels++; } /* amount of available threads */ @@ -235,18 +235,21 @@ void BLI_end_threads(ListBase *threadbase) { ThreadSlot *tslot; - if (threadbase) { + /* only needed if there's actually some stuff to end + * this way we don't end up decrementing thread_levels on an empty threadbase + * */ + if (threadbase && threadbase->first != NULL) { for(tslot= threadbase->first; tslot; tslot= tslot->next) { if(tslot->avail==0) { pthread_join(tslot->pthread, NULL); } } BLI_freelistN(threadbase); + + thread_levels--; + if(thread_levels==0) + MEM_set_lock_callback(NULL, NULL); } - - thread_levels--; - if(thread_levels==0) - MEM_set_lock_callback(NULL, NULL); } void BLI_lock_thread(int type) @@ -313,7 +316,7 @@ typedef struct WorkParam { int index; } WorkParam; -void *exec_work_fnct(void *v_param) +static void *exec_work_fnct(void *v_param) { WorkParam *p = (WorkParam*)v_param; void *value; |