Core: new blenlib library for implicit-sharing #105994
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include <atomic>
|
||||
|
||||
#include "BLI_implicit_sharing_user.hh"
|
||||
#include "BLI_implicit_sharing_ptr.hh"
|
||||
#include "BLI_set.hh"
|
||||
#include "BLI_string_ref.hh"
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace blender::bke {
|
|||
* because that is not available in C code. If possible, the #AutoAnonymousAttributeID wrapper
|
||||
* should be used to avoid manual reference counting in C++ code.
|
||||
*/
|
||||
class AnonymousAttributeID : public ImplicitShareMixin {
|
||||
class AnonymousAttributeID : public ImplicitSharingMixin {
|
||||
protected:
|
||||
std::string name_;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class Instances;
|
|||
* copy-on-write behavior to avoid read-only copies. It also integrates with attribute API, which
|
||||
* generalizes storing and modifying generic information on a geometry.
|
||||
*/
|
||||
class GeometryComponent : public blender::ImplicitShareMixin {
|
||||
class GeometryComponent : public blender::ImplicitSharingMixin {
|
||||
private:
|
||||
GeometryComponentType type_;
|
||||
|
||||
|
|
|
@ -32,18 +32,18 @@ namespace blender {
|
|||
* #bCopyOnWrite is used in two ways:
|
||||
* - It can be allocated separately from the referenced data as is typically the case with raw
|
||||
* arrays (e.g. for mesh attributes).
|
||||
* - It can be embedded into another struct. For that it's best to use #ImplicitShareMixin.
|
||||
* - It can be embedded into another struct. For that it's best to use #ImplicitSharingMixin.
|
||||
*/
|
||||
struct ImplicitShareInfo : blender::NonCopyable, blender::NonMovable {
|
||||
struct ImplicitSharingInfo : blender::NonCopyable, blender::NonMovable {
|
||||
private:
|
||||
mutable std::atomic<int> users_;
|
||||
|
||||
public:
|
||||
ImplicitShareInfo(const int initial_users) : users_(initial_users)
|
||||
ImplicitSharingInfo(const int initial_users) : users_(initial_users)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~ImplicitShareInfo()
|
||||
virtual ~ImplicitSharingInfo()
|
||||
{
|
||||
BLI_assert(this->is_mutable());
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ struct ImplicitShareInfo : blender::NonCopyable, blender::NonMovable {
|
|||
BLI_assert(old_user_count >= 1);
|
||||
const bool was_last_user = old_user_count == 1;
|
||||
if (was_last_user) {
|
||||
const_cast<ImplicitShareInfo *>(this)->delete_self_with_data();
|
||||
const_cast<ImplicitSharingInfo *>(this)->delete_self_with_data();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,9 +81,9 @@ struct ImplicitShareInfo : blender::NonCopyable, blender::NonMovable {
|
|||
/**
|
||||
* Makes it easy to embed copy-on-write behavior into a struct.
|
||||
*/
|
||||
JacquesLucke marked this conversation as resolved
Outdated
|
||||
struct ImplicitShareMixin : public ImplicitShareInfo {
|
||||
struct ImplicitSharingMixin : public ImplicitSharingInfo {
|
||||
public:
|
||||
ImplicitShareMixin() : ImplicitShareInfo(1)
|
||||
ImplicitSharingMixin() : ImplicitSharingInfo(1)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ set(SRC
|
|||
BLI_console.h
|
||||
BLI_convexhull_2d.h
|
||||
BLI_implicit_sharing.hh
|
||||
BLI_implicit_sharing_user.hh
|
||||
BLI_implicit_sharing_ptr.hh
|
||||
BLI_cpp_type.hh
|
||||
BLI_cpp_type_make.hh
|
||||
BLI_cpp_types.hh
|
||||
|
|
Loading…
Reference in New Issue
This comment is a bit hard to follow, maybe replacing
the subclass
with something more specific would help (like saying the ptr class can be used with a class that derives from the mixin class).