Skip to content

Commit

Permalink
Replace boost::intrusive_ptr with TfIntrusiveTrackingPtr in `Usd_…
Browse files Browse the repository at this point in the history
…Shared`
  • Loading branch information
nvmkuruc committed Jan 3, 2024
1 parent 49d6d18 commit 3774242
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pxr/usd/usd/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <boost/smart_ptr/intrusive_ptr.hpp>
#include <atomic>

PXR_NAMESPACE_OPEN_SCOPE
Expand Down Expand Up @@ -66,11 +66,13 @@ template <class T>
struct Usd_Shared
{
// Construct a Usd_Shared with a value-initialized T instance.
Usd_Shared() : _held(new Usd_Counted<T>()) {}
Usd_Shared() : _held(TfIntrusiveMakeTrackingPtr<Usd_Counted<T>>()) {}
// Create a copy of \p obj.
explicit Usd_Shared(T const &obj) : _held(new Usd_Counted<T>(obj)) {}
explicit Usd_Shared(T const &obj) :
_held(TfIntrusiveMakeTrackingPtr<Usd_Counted<T>>(obj)) {}
// Move from \p obj.
explicit Usd_Shared(T &&obj) : _held(new Usd_Counted<T>(std::move(obj))) {}
explicit Usd_Shared(T &&obj) :
_held(TfIntrusiveMakeTrackingPtr<Usd_Counted<T>>(std::move(obj))) {}

// Create an empty shared, which may not be accessed via Get(),
// GetMutable(), IsUnique(), Clone(), or MakeUnique(). This is useful when
Expand All @@ -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<T>(Get())); }
void Clone() { _held = TfIntrusiveMakeTrackingPtr<Usd_Counted<T>>(Get()); }
// Ensure this Usd_Shared instance has unique data. Equivalent to:
// \code
// if (not shared.IsUnique()) { shared.Clone(); }
Expand All @@ -108,7 +110,7 @@ struct Usd_Shared
return TfHash()(sh._held->data);
}
private:
boost::intrusive_ptr<Usd_Counted<T>> _held;
TfIntrusiveTrackingPtr<Usd_Counted<T>> _held;
};


Expand Down

0 comments on commit 3774242

Please sign in to comment.