[Bf-blender-cvs] [d11b9c7239c] functions: cleanup
Jacques Lucke
noreply at git.blender.org
Thu Mar 7 12:57:55 CET 2019
Commit: d11b9c7239ccc1c9ad35c0d900b1542e7d60b0a7
Author: Jacques Lucke
Date: Thu Mar 7 11:38:48 2019 +0100
Branches: functions
https://developer.blender.org/rBd11b9c7239ccc1c9ad35c0d900b1542e7d60b0a7
cleanup
===================================================================
M source/blender/blenlib/BLI_shared.hpp
M source/blender/blenlib/BLI_shared_immutable.hpp
===================================================================
diff --git a/source/blender/blenlib/BLI_shared.hpp b/source/blender/blenlib/BLI_shared.hpp
index 168642c42ad..ba86319f41a 100644
--- a/source/blender/blenlib/BLI_shared.hpp
+++ b/source/blender/blenlib/BLI_shared.hpp
@@ -1,3 +1,5 @@
+#pragma once
+
#include <atomic>
#include <utility>
#include "BLI_utildefines.h"
diff --git a/source/blender/blenlib/BLI_shared_immutable.hpp b/source/blender/blenlib/BLI_shared_immutable.hpp
index 6935339b09f..14996375ab7 100644
--- a/source/blender/blenlib/BLI_shared_immutable.hpp
+++ b/source/blender/blenlib/BLI_shared_immutable.hpp
@@ -1,49 +1,43 @@
#pragma once
-#include <atomic>
-#include "BLI_utildefines.h"
+#include "BLI_shared.hpp"
namespace BLI {
- class SharedImmutable {
+ class SharedImmutable : protected RefCountedBase {
private:
- std::atomic<int> m_users;
-
SharedImmutable(SharedImmutable &other) = delete;
public:
SharedImmutable()
- : m_users(1) {}
+ : RefCountedBase() {}
virtual ~SharedImmutable() {}
void new_user()
{
- std::atomic_fetch_add(&m_users, 1);
+ this->incref();
}
void remove_user()
{
- int previous = std::atomic_fetch_sub(&m_users, 1);
- if (previous == 1) {
- delete this;
- }
+ this->decref();
}
int users() const
{
- return m_users;
+ return this->refcount();
}
bool is_mutable() const
{
- return m_users == 1;
+ return this->users() == 1;
}
bool is_immutable() const
{
- return m_users > 1;
+ return this->users() > 1;
}
void assert_mutable() const
More information about the Bf-blender-cvs
mailing list