From 3774242aa15db96bd4fe5506be5233ddcbc6c0cb Mon Sep 17 00:00:00 2001 From: Matt Kuruc Date: Thu, 28 Dec 2023 10:51:06 -0800 Subject: [PATCH] Replace `boost::intrusive_ptr` with `TfIntrusiveTrackingPtr` in `Usd_Shared` --- pxr/usd/usd/shared.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pxr/usd/usd/shared.h b/pxr/usd/usd/shared.h index d8ccd9b495..295d1c038b 100644 --- a/pxr/usd/usd/shared.h +++ b/pxr/usd/usd/shared.h @@ -27,8 +27,8 @@ #include "pxr/pxr.h" #include "pxr/usd/usd/api.h" #include "pxr/base/tf/hash.h" +#include "pxr/base/tf/trackingPtr.h" -#include #include PXR_NAMESPACE_OPEN_SCOPE @@ -66,11 +66,13 @@ template struct Usd_Shared { // Construct a Usd_Shared with a value-initialized T instance. - Usd_Shared() : _held(new Usd_Counted()) {} + Usd_Shared() : _held(TfIntrusiveMakeTrackingPtr>()) {} // Create a copy of \p obj. - explicit Usd_Shared(T const &obj) : _held(new Usd_Counted(obj)) {} + explicit Usd_Shared(T const &obj) : + _held(TfIntrusiveMakeTrackingPtr>(obj)) {} // Move from \p obj. - explicit Usd_Shared(T &&obj) : _held(new Usd_Counted(std::move(obj))) {} + explicit Usd_Shared(T &&obj) : + _held(TfIntrusiveMakeTrackingPtr>(std::move(obj))) {} // Create an empty shared, which may not be accessed via Get(), // GetMutable(), IsUnique(), Clone(), or MakeUnique(). This is useful when @@ -86,7 +88,7 @@ struct Usd_Shared // Return true if no other Usd_Shared instance shares this instance's data. bool IsUnique() const { return _held->count == 1; } // Make a new copy of the held data and refer to it. - void Clone() { _held.reset(new Usd_Counted(Get())); } + void Clone() { _held = TfIntrusiveMakeTrackingPtr>(Get()); } // Ensure this Usd_Shared instance has unique data. Equivalent to: // \code // if (not shared.IsUnique()) { shared.Clone(); } @@ -108,7 +110,7 @@ struct Usd_Shared return TfHash()(sh._held->data); } private: - boost::intrusive_ptr> _held; + TfIntrusiveTrackingPtr> _held; };