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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-24 21:31:09 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-24 21:31:09 +0400
commitdbeec2be86db5b4ba440175e59c52ff84eb98462 (patch)
tree8bedb75ea7937279d318b86f5eecc98f8e03a950 /source/blender/blenlib
parent64e28b21ba8472f4fd822b918d6e7d7c1be87dcb (diff)
Fix #34783: smoke simulation crash when changing frame while preview rendering.
Added a mutex lock for smoke data access. The render was already working with a copy of the volume data, so it's just a short lock to copy things and should not block the UI much.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_threads.h12
-rw-r--r--source/blender/blenlib/intern/threads.c26
2 files changed, 36 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index ec8e567c0ef..614cd4ee59d 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -92,9 +92,13 @@ typedef pthread_mutex_t ThreadMutex;
#define BLI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
void BLI_mutex_init(ThreadMutex *mutex);
+void BLI_mutex_end(ThreadMutex *mutex);
+
+ThreadMutex *BLI_mutex_alloc(void);
+void BLI_mutex_free(ThreadMutex *mutex);
+
void BLI_mutex_lock(ThreadMutex *mutex);
void BLI_mutex_unlock(ThreadMutex *mutex);
-void BLI_mutex_end(ThreadMutex *mutex);
/* Spin Lock */
@@ -117,9 +121,13 @@ void BLI_spin_end(SpinLock *spin);
typedef pthread_rwlock_t ThreadRWMutex;
void BLI_rw_mutex_init(ThreadRWMutex *mutex);
+void BLI_rw_mutex_end(ThreadRWMutex *mutex);
+
+ThreadRWMutex *BLI_rw_mutex_alloc(void);
+void BLI_rw_mutex_free(ThreadRWMutex *mutex);
+
void BLI_rw_mutex_lock(ThreadRWMutex *mutex, int mode);
void BLI_rw_mutex_unlock(ThreadRWMutex *mutex);
-void BLI_rw_mutex_end(ThreadRWMutex *mutex);
/* ThreadedWorker
*
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 1d3312fafb1..8b1ba38a35a 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -399,6 +399,19 @@ void BLI_mutex_end(ThreadMutex *mutex)
pthread_mutex_destroy(mutex);
}
+ThreadMutex *BLI_mutex_alloc(void)
+{
+ ThreadMutex *mutex = MEM_callocN(sizeof(ThreadMutex), "ThreadMutex");
+ BLI_mutex_init(mutex);
+ return mutex;
+}
+
+void BLI_mutex_free(ThreadMutex *mutex)
+{
+ BLI_mutex_end(mutex);
+ MEM_freeN(mutex);
+}
+
/* Spin Locks */
void BLI_spin_init(SpinLock *spin)
@@ -464,6 +477,19 @@ void BLI_rw_mutex_end(ThreadRWMutex *mutex)
pthread_rwlock_destroy(mutex);
}
+ThreadRWMutex *BLI_rw_mutex_alloc(void)
+{
+ ThreadRWMutex *mutex = MEM_callocN(sizeof(ThreadRWMutex), "ThreadRWMutex");
+ BLI_rw_mutex_init(mutex);
+ return mutex;
+}
+
+void BLI_rw_mutex_free(ThreadRWMutex *mutex)
+{
+ BLI_rw_mutex_end(mutex);
+ MEM_freeN(mutex);
+}
+
/* ************************************************ */
typedef struct ThreadedWorker {