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:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-06-26 12:55:40 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-06-26 13:22:21 +0400
commit6135556f4556f0416f7ded737b26e342986ae1bf (patch)
tree9a9468c7770b7eb26f659bc704dc41132b305b7b /source/blender/blenkernel/intern/library.c
parent33e8451d4b15d04872ee0923600aad0627ab040e (diff)
Replace Main->lock with an anoynous structure pointer
This way it's not needed to include BLI_threads.h from the BKE_main.h which helps avoiding adding PThreads includes to each library which uses Main on Windows. From the API point of view it's now MainLock* and to lock or unlock the main you're to use BKE_main_(un)lock(). This solves compilation error on Windows with SCons.
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r--source/blender/blenkernel/intern/library.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 9a74edb03c9..a5c52e9d7e8 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -71,6 +71,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLI_threads.h"
#include "BLF_translation.h"
#include "BKE_action.h"
@@ -747,14 +748,14 @@ void *BKE_libblock_alloc(Main *bmain, short type, const char *name)
id = alloc_libblock_notest(type);
if (id) {
- BLI_spin_lock(&bmain->lock);
+ BKE_main_lock(bmain);
BLI_addtail(lb, id);
id->us = 1;
id->icon_id = 0;
*( (short *)id->name) = type;
new_id(lb, id, name);
/* alphabetic insertion: is in new_id */
- BLI_spin_unlock(&bmain->lock);
+ BKE_main_unlock(bmain);
}
DAG_id_type_tag(bmain, type);
return id;
@@ -1008,7 +1009,7 @@ void BKE_libblock_free_ex(Main *bmain, void *idv, bool do_id_user)
}
/* avoid notifying on removed data */
- BLI_spin_lock(&bmain->lock);
+ BKE_main_lock(bmain);
if (free_notifier_reference_cb)
free_notifier_reference_cb(id);
@@ -1016,7 +1017,7 @@ void BKE_libblock_free_ex(Main *bmain, void *idv, bool do_id_user)
BLI_remlink(lb, id);
BKE_libblock_free_data(bmain, id);
- BLI_spin_unlock(&bmain->lock);
+ BKE_main_unlock(bmain);
MEM_freeN(id);
}
@@ -1048,7 +1049,8 @@ Main *BKE_main_new(void)
Main *bmain = MEM_callocN(sizeof(Main), "new main");
bmain->eval_ctx = MEM_callocN(sizeof(EvaluationContext),
"EvaluationContext");
- BLI_spin_init(&bmain->lock);
+ bmain->lock = MEM_mallocN(sizeof(SpinLock), "main lock");
+ BLI_spin_init(bmain->lock);
return bmain;
}
@@ -1111,11 +1113,22 @@ void BKE_main_free(Main *mainvar)
}
}
- BLI_spin_end(&mainvar->lock);
+ BLI_spin_end(mainvar->lock);
+ MEM_freeN(mainvar->lock);
MEM_freeN(mainvar->eval_ctx);
MEM_freeN(mainvar);
}
+void BKE_main_lock(struct Main *bmain)
+{
+ BLI_spin_lock(bmain->lock);
+}
+
+void BKE_main_unlock(struct Main *bmain)
+{
+ BLI_spin_unlock(bmain->lock);
+}
+
/* ***************** ID ************************ */