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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern/threads.c')
-rw-r--r--source/blender/blenlib/intern/threads.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 2812f17d58f..ed3e07b7f7e 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)