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:
authorPeter Schlaile <peter@schlaile.de>2007-11-25 19:35:33 +0300
committerPeter Schlaile <peter@schlaile.de>2007-11-25 19:35:33 +0300
commit4018dfd28f3bfdeba2e10a36401b573a75152cc5 (patch)
tree1e08ae46c8523d77af85d9ce4eb7a9ae0b9c4b76 /source/blender/blenlib
parenta32287ebfbb36b1a3e1bb02563cb096179041f28 (diff)
== Sequencer ==
Added malloc mutex handling. (Sorry, had to patch threads.c a bit, since otherwise scene tracks will completely screw things up...)
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/threads.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index cb10185386a..1f05070b034 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -109,22 +109,26 @@ static void BLI_unlock_malloc_thread(void)
pthread_mutex_unlock(&_malloc_lock);
}
+/* tot = 0 only initializes malloc mutex in a safe way (see sequence.c)
+ problem otherwise: scene render will kill of the mutex!
+*/
+
void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot)
{
int a;
- if(threadbase==NULL)
- return;
- threadbase->first= threadbase->last= NULL;
+ if(threadbase != NULL && tot > 0) {
+ threadbase->first= threadbase->last= NULL;
- if(tot>RE_MAX_THREAD) tot= RE_MAX_THREAD;
- else if(tot<1) tot= 1;
+ if(tot>RE_MAX_THREAD) tot= RE_MAX_THREAD;
+ else if(tot<1) tot= 1;
- for(a=0; a<tot; a++) {
- ThreadSlot *tslot= MEM_callocN(sizeof(ThreadSlot), "threadslot");
- BLI_addtail(threadbase, tslot);
- tslot->do_thread= do_thread;
- tslot->avail= 1;
+ for(a=0; a<tot; a++) {
+ ThreadSlot *tslot= MEM_callocN(sizeof(ThreadSlot), "threadslot");
+ BLI_addtail(threadbase, tslot);
+ tslot->do_thread= do_thread;
+ tslot->avail= 1;
+ }
}
MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread);
@@ -190,12 +194,14 @@ void BLI_end_threads(ListBase *threadbase)
{
ThreadSlot *tslot;
- for(tslot= threadbase->first; tslot; tslot= tslot->next) {
- if(tslot->avail==0) {
- pthread_join(tslot->pthread, NULL);
+ if (threadbase) {
+ for(tslot= threadbase->first; tslot; tslot= tslot->next) {
+ if(tslot->avail==0) {
+ pthread_join(tslot->pthread, NULL);
+ }
}
+ BLI_freelistN(threadbase);
}
- BLI_freelistN(threadbase);
thread_levels--;
if(thread_levels==0)