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:
authorHans Goudey <h.goudey@me.com>2022-10-13 06:31:02 +0300
committerHans Goudey <h.goudey@me.com>2022-10-13 06:31:50 +0300
commitc67e5628d22f8348492b6205081fe1798d50689c (patch)
tree01b7b5e46f080f0359c06b389d7d1a544279e325 /source/blender/blenkernel/intern/mesh_runtime.cc
parent375dafe3ef40eb61e831902a1ae45ecca555fec6 (diff)
Cleanup: Use std::mutex for mesh runtime mutexes
Instead of allocating three separate ThreadMutex pointers, just embed std::mutex into the struct directly.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_runtime.cc')
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.cc38
1 files changed, 1 insertions, 37 deletions
diff --git a/source/blender/blenkernel/intern/mesh_runtime.cc b/source/blender/blenkernel/intern/mesh_runtime.cc
index 100b4de9045..e90a298ad8d 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.cc
+++ b/source/blender/blenkernel/intern/mesh_runtime.cc
@@ -36,39 +36,6 @@ void BKE_mesh_runtime_free_data(Mesh *mesh)
BKE_mesh_runtime_clear_cache(mesh);
}
-namespace blender::bke {
-
-MeshRuntime::MeshRuntime()
-{
- this->eval_mutex = MEM_new<ThreadMutex>("mesh runtime eval_mutex");
- BLI_mutex_init(static_cast<ThreadMutex *>(this->eval_mutex));
- this->normals_mutex = MEM_new<ThreadMutex>("mesh runtime normals_mutex");
- BLI_mutex_init(static_cast<ThreadMutex *>(this->normals_mutex));
- this->render_mutex = MEM_new<ThreadMutex>("mesh runtime render_mutex");
- BLI_mutex_init(static_cast<ThreadMutex *>(this->render_mutex));
-}
-
-MeshRuntime::~MeshRuntime()
-{
- if (this->eval_mutex != nullptr) {
- BLI_mutex_end(static_cast<ThreadMutex *>(this->eval_mutex));
- MEM_freeN(this->eval_mutex);
- this->eval_mutex = nullptr;
- }
- if (this->normals_mutex != nullptr) {
- BLI_mutex_end(static_cast<ThreadMutex *>(this->normals_mutex));
- MEM_freeN(this->normals_mutex);
- this->normals_mutex = nullptr;
- }
- if (this->render_mutex != nullptr) {
- BLI_mutex_end(static_cast<ThreadMutex *>(this->render_mutex));
- MEM_freeN(this->render_mutex);
- this->render_mutex = nullptr;
- }
-}
-
-} // namespace blender::bke
-
void BKE_mesh_runtime_clear_cache(Mesh *mesh)
{
if (mesh->runtime->mesh_eval != nullptr) {
@@ -166,8 +133,7 @@ int BKE_mesh_runtime_looptri_len(const Mesh *mesh)
const MLoopTri *BKE_mesh_runtime_looptri_ensure(const Mesh *mesh)
{
- ThreadMutex *mesh_eval_mutex = (ThreadMutex *)mesh->runtime->eval_mutex;
- BLI_mutex_lock(mesh_eval_mutex);
+ std::lock_guard lock{mesh->runtime->eval_mutex};
MLoopTri *looptri = mesh->runtime->looptris.array;
@@ -181,8 +147,6 @@ const MLoopTri *BKE_mesh_runtime_looptri_ensure(const Mesh *mesh)
looptri = mesh->runtime->looptris.array;
}
- BLI_mutex_unlock(mesh_eval_mutex);
-
return looptri;
}