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.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 351e0be1102..de7842727df 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -29,6 +29,7 @@
*/
#include <errno.h>
+#include <string.h>
#include "MEM_guardedalloc.h"
@@ -106,6 +107,8 @@ static pthread_mutex_t _image_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t _preview_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t _viewer_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t _custom1_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t _rcache_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_t mainid;
static int thread_levels= 0; /* threads can be invoked inside threads */
/* just a max for security reasons */
@@ -129,6 +132,11 @@ static void BLI_unlock_malloc_thread(void)
pthread_mutex_unlock(&_malloc_lock);
}
+void BLI_threadapi_init(void)
+{
+ mainid = pthread_self();
+}
+
/* tot = 0 only initializes malloc mutex in a safe way (see sequence.c)
problem otherwise: scene render will kill of the mutex!
*/
@@ -136,7 +144,7 @@ static void BLI_unlock_malloc_thread(void)
void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot)
{
int a;
-
+
if(threadbase != NULL && tot > 0) {
threadbase->first= threadbase->last= NULL;
@@ -204,6 +212,13 @@ static void *tslot_thread_start(void *tslot_p)
return tslot->do_thread(tslot->callerdata);
}
+int BLI_thread_is_main(void) {
+ pthread_t tid;
+ tid = pthread_self();
+
+ return !memcmp(&tid, &mainid, sizeof(pthread_t));
+}
+
void BLI_insert_thread(ListBase *threadbase, void *callerdata)
{
ThreadSlot *tslot;
@@ -327,6 +342,8 @@ void BLI_lock_thread(int type)
pthread_mutex_lock(&_viewer_lock);
else if (type==LOCK_CUSTOM1)
pthread_mutex_lock(&_custom1_lock);
+ else if (type==LOCK_RCACHE)
+ pthread_mutex_lock(&_rcache_lock);
}
void BLI_unlock_thread(int type)
@@ -339,6 +356,8 @@ void BLI_unlock_thread(int type)
pthread_mutex_unlock(&_viewer_lock);
else if(type==LOCK_CUSTOM1)
pthread_mutex_unlock(&_custom1_lock);
+ else if(type==LOCK_RCACHE)
+ pthread_mutex_unlock(&_rcache_lock);
}
/* Mutex Locks */