From e0acaa1bf7a279650a58627cc33554ea15a391db Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 13 Jun 2022 22:49:38 -0700 Subject: [PATCH] From tbb::atomic to std::atomic --- extras/usd/examples/usdObj/pch.h | 1 - extras/usd/examples/usdSchemaExamples/pch.h | 1 - pxr/base/plug/pch.h | 1 - pxr/base/tf/pch.h | 1 - pxr/base/trace/pch.h | 1 - pxr/base/vt/pch.h | 1 - pxr/base/work/pch.h | 1 - pxr/imaging/garch/pch.h | 1 - pxr/imaging/glf/pch.h | 1 - pxr/imaging/hd/pch.h | 1 - pxr/imaging/hdMtlx/pch.h | 1 - pxr/imaging/hdSt/pch.h | 1 - pxr/imaging/hdx/pch.h | 1 - pxr/imaging/hgiMetal/pch.h | 1 - pxr/imaging/plugin/hdEmbree/pch.h | 1 - pxr/imaging/plugin/hdStorm/pch.h | 1 - pxr/imaging/plugin/hioOiio/pch.h | 1 - pxr/usd/ar/pch.h | 1 - pxr/usd/ndr/pch.h | 1 - pxr/usd/pcp/cache.cpp | 1 - pxr/usd/pcp/mapExpression.cpp | 4 +-- pxr/usd/pcp/mapExpression.h | 3 +-- pxr/usd/pcp/pch.h | 1 - pxr/usd/plugin/usdAbc/pch.h | 1 - pxr/usd/plugin/usdDraco/pch.h | 1 - pxr/usd/sdf/changeManager.cpp | 10 ++++---- pxr/usd/sdf/pathNode.cpp | 4 +-- pxr/usd/sdf/pathNode.h | 6 ++--- pxr/usd/sdf/pch.h | 1 - pxr/usd/usd/pch.h | 1 - pxr/usd/usdGeom/bboxCache.cpp | 21 +++++++++++++--- pxr/usd/usdGeom/pch.h | 1 - pxr/usd/usdHydra/pch.h | 1 - pxr/usd/usdLux/pch.h | 1 - pxr/usd/usdMedia/pch.h | 1 - pxr/usd/usdMtlx/pch.h | 1 - pxr/usd/usdPhysics/pch.h | 1 - pxr/usd/usdRender/pch.h | 1 - pxr/usd/usdRi/pch.h | 1 - pxr/usd/usdShade/pch.h | 1 - pxr/usd/usdSkel/pch.h | 1 - pxr/usd/usdUI/pch.h | 1 - pxr/usd/usdUtils/pch.h | 1 - pxr/usd/usdVol/pch.h | 1 - pxr/usdImaging/plugin/usdShaders/pch.h | 1 - pxr/usdImaging/usdAppUtils/pch.h | 1 - pxr/usdImaging/usdImaging/pch.h | 1 - .../usdImaging/resolvedAttributeCache.h | 25 +++++++++++++++---- pxr/usdImaging/usdImagingGL/pch.h | 1 - pxr/usdImaging/usdRiImaging/pch.h | 1 - pxr/usdImaging/usdSkelImaging/pch.h | 1 - pxr/usdImaging/usdVolImaging/pch.h | 1 - pxr/usdImaging/usdviewq/pch.h | 1 - 53 files changed, 50 insertions(+), 69 deletions(-) diff --git a/extras/usd/examples/usdObj/pch.h b/extras/usd/examples/usdObj/pch.h index 6a8744cbc7..5e95273058 100644 --- a/extras/usd/examples/usdObj/pch.h +++ b/extras/usd/examples/usdObj/pch.h @@ -166,7 +166,6 @@ #include #include #include -#include #include #include #include diff --git a/extras/usd/examples/usdSchemaExamples/pch.h b/extras/usd/examples/usdSchemaExamples/pch.h index 47666439a2..ef31dc083d 100644 --- a/extras/usd/examples/usdSchemaExamples/pch.h +++ b/extras/usd/examples/usdSchemaExamples/pch.h @@ -168,7 +168,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/base/plug/pch.h b/pxr/base/plug/pch.h index 98b6fc7825..64ffff9b92 100644 --- a/pxr/base/plug/pch.h +++ b/pxr/base/plug/pch.h @@ -183,7 +183,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/base/tf/pch.h b/pxr/base/tf/pch.h index 11cb840f30..5adebe4961 100644 --- a/pxr/base/tf/pch.h +++ b/pxr/base/tf/pch.h @@ -243,7 +243,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/base/trace/pch.h b/pxr/base/trace/pch.h index 25f4b5d6cf..e98e183088 100644 --- a/pxr/base/trace/pch.h +++ b/pxr/base/trace/pch.h @@ -178,7 +178,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/base/vt/pch.h b/pxr/base/vt/pch.h index 75f03bee27..3924c8f020 100644 --- a/pxr/base/vt/pch.h +++ b/pxr/base/vt/pch.h @@ -171,7 +171,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/base/work/pch.h b/pxr/base/work/pch.h index 228b18d0d8..79030be79e 100644 --- a/pxr/base/work/pch.h +++ b/pxr/base/work/pch.h @@ -110,7 +110,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/imaging/garch/pch.h b/pxr/imaging/garch/pch.h index 7ef3bd8afd..7d13f55560 100644 --- a/pxr/imaging/garch/pch.h +++ b/pxr/imaging/garch/pch.h @@ -145,7 +145,6 @@ #include #include #include -#include #include #include #ifdef PXR_PYTHON_SUPPORT_ENABLED diff --git a/pxr/imaging/glf/pch.h b/pxr/imaging/glf/pch.h index 9a7e85a6c4..9e396e34bf 100644 --- a/pxr/imaging/glf/pch.h +++ b/pxr/imaging/glf/pch.h @@ -199,7 +199,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/imaging/hd/pch.h b/pxr/imaging/hd/pch.h index 604861b7b1..fe94789a2e 100644 --- a/pxr/imaging/hd/pch.h +++ b/pxr/imaging/hd/pch.h @@ -152,7 +152,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/imaging/hdMtlx/pch.h b/pxr/imaging/hdMtlx/pch.h index bf8ff6a368..dd22c8c14c 100644 --- a/pxr/imaging/hdMtlx/pch.h +++ b/pxr/imaging/hdMtlx/pch.h @@ -139,7 +139,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/imaging/hdSt/pch.h b/pxr/imaging/hdSt/pch.h index 196960f7b7..d4377da1cc 100644 --- a/pxr/imaging/hdSt/pch.h +++ b/pxr/imaging/hdSt/pch.h @@ -170,7 +170,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/imaging/hdx/pch.h b/pxr/imaging/hdx/pch.h index 33ddb1b5da..8fcf02aace 100644 --- a/pxr/imaging/hdx/pch.h +++ b/pxr/imaging/hdx/pch.h @@ -152,7 +152,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/imaging/hgiMetal/pch.h b/pxr/imaging/hgiMetal/pch.h index 877bc45ee5..dd9f067dd3 100644 --- a/pxr/imaging/hgiMetal/pch.h +++ b/pxr/imaging/hgiMetal/pch.h @@ -141,7 +141,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/imaging/plugin/hdEmbree/pch.h b/pxr/imaging/plugin/hdEmbree/pch.h index 7710229804..733d83b218 100644 --- a/pxr/imaging/plugin/hdEmbree/pch.h +++ b/pxr/imaging/plugin/hdEmbree/pch.h @@ -154,7 +154,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/imaging/plugin/hdStorm/pch.h b/pxr/imaging/plugin/hdStorm/pch.h index 33c5124a97..081338138a 100644 --- a/pxr/imaging/plugin/hdStorm/pch.h +++ b/pxr/imaging/plugin/hdStorm/pch.h @@ -141,7 +141,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/imaging/plugin/hioOiio/pch.h b/pxr/imaging/plugin/hioOiio/pch.h index 9a7e85a6c4..9e396e34bf 100644 --- a/pxr/imaging/plugin/hioOiio/pch.h +++ b/pxr/imaging/plugin/hioOiio/pch.h @@ -199,7 +199,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/ar/pch.h b/pxr/usd/ar/pch.h index b3333376f4..4f60d1b768 100644 --- a/pxr/usd/ar/pch.h +++ b/pxr/usd/ar/pch.h @@ -166,7 +166,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/ndr/pch.h b/pxr/usd/ndr/pch.h index 897ad796bf..8aefd88ee2 100644 --- a/pxr/usd/ndr/pch.h +++ b/pxr/usd/ndr/pch.h @@ -198,7 +198,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/pcp/cache.cpp b/pxr/usd/pcp/cache.cpp index 00346b2c30..22853bd724 100644 --- a/pxr/usd/pcp/cache.cpp +++ b/pxr/usd/pcp/cache.cpp @@ -53,7 +53,6 @@ #include "pxr/base/tf/envSetting.h" #include "pxr/base/tf/registryManager.h" -#include #include #include #include diff --git a/pxr/usd/pcp/mapExpression.cpp b/pxr/usd/pcp/mapExpression.cpp index 4ab6e669c0..f419206374 100644 --- a/pxr/usd/pcp/mapExpression.cpp +++ b/pxr/usd/pcp/mapExpression.cpp @@ -238,7 +238,7 @@ PcpMapExpression::_Node::New( _Op op_, // Check for existing instance to re-use _NodeMap::accessor accessor; if (_nodeRegistry->map.insert(accessor, key) || - accessor->second->_refCount.fetch_and_increment() == 0) { + accessor->second->_refCount.fetch_add(1) == 0) { // Either there was no node in the table, or there was but it had // begun dying (another client dropped its refcount to 0). We have // to create a new node in the table. When the client that is @@ -387,7 +387,7 @@ intrusive_ptr_add_ref(PcpMapExpression::_Node* p) void intrusive_ptr_release(PcpMapExpression::_Node* p) { - if (p->_refCount.fetch_and_decrement() == 1) + if (p->_refCount.fetch_sub(1) == 1) delete p; } diff --git a/pxr/usd/pcp/mapExpression.h b/pxr/usd/pcp/mapExpression.h index c91250a65c..e61475ea59 100644 --- a/pxr/usd/pcp/mapExpression.h +++ b/pxr/usd/pcp/mapExpression.h @@ -30,7 +30,6 @@ #include -#include #include #include @@ -265,7 +264,7 @@ class PcpMapExpression struct _NodeMap; static TfStaticData<_NodeMap> _nodeRegistry; - mutable tbb::atomic _refCount; + mutable std::atomic _refCount; mutable Value _cachedValue; mutable std::set<_Node*> _dependentExpressions; Value _valueForVariable; diff --git a/pxr/usd/pcp/pch.h b/pxr/usd/pcp/pch.h index a7180637dd..220c3ef386 100644 --- a/pxr/usd/pcp/pch.h +++ b/pxr/usd/pcp/pch.h @@ -194,7 +194,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/plugin/usdAbc/pch.h b/pxr/usd/plugin/usdAbc/pch.h index f5c7e6fb6c..33cc2cacb4 100644 --- a/pxr/usd/plugin/usdAbc/pch.h +++ b/pxr/usd/plugin/usdAbc/pch.h @@ -206,7 +206,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/plugin/usdDraco/pch.h b/pxr/usd/plugin/usdDraco/pch.h index aff99924d4..ce6d0d1149 100644 --- a/pxr/usd/plugin/usdDraco/pch.h +++ b/pxr/usd/plugin/usdDraco/pch.h @@ -169,7 +169,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/sdf/changeManager.cpp b/pxr/usd/sdf/changeManager.cpp index 16c67e51c1..36f59ca05b 100644 --- a/pxr/usd/sdf/changeManager.cpp +++ b/pxr/usd/sdf/changeManager.cpp @@ -34,7 +34,7 @@ #include "pxr/base/tf/instantiateSingleton.h" #include "pxr/base/tf/stackTrace.h" -#include +#include using std::string; using std::vector; @@ -149,9 +149,9 @@ Sdf_ChangeManager::_ProcessRemoveIfInert(_Data *data) TF_VERIFY(data->outermostBlock); } -static tbb::atomic & +static std::atomic & _InitChangeSerialNumber() { - static tbb::atomic value; + static std::atomic value; value = 1; return value; } @@ -190,8 +190,8 @@ Sdf_ChangeManager::_SendNotices(_Data *data) } // Obtain a serial number for this round of change processing. - static tbb::atomic &changeSerialNumber = _InitChangeSerialNumber(); - size_t serialNumber = changeSerialNumber.fetch_and_increment(); + static std::atomic &changeSerialNumber = _InitChangeSerialNumber(); + size_t serialNumber = changeSerialNumber.fetch_add(1); // Send global notice. SdfNotice::LayersDidChange(changes, serialNumber).Send(); diff --git a/pxr/usd/sdf/pathNode.cpp b/pxr/usd/sdf/pathNode.cpp index b923ba9dd6..4d6eb693df 100644 --- a/pxr/usd/sdf/pathNode.cpp +++ b/pxr/usd/sdf/pathNode.cpp @@ -62,7 +62,7 @@ static_assert(sizeof(Sdf_PrimPropertyPathNode) == 3 * sizeof(void *), ""); struct Sdf_PathNodePrivateAccess { template - static inline tbb::atomic & + static inline std::atomic & GetRefCount(Handle h) { Sdf_PathNode const *p = reinterpret_cast(h.GetPtr()); @@ -265,7 +265,7 @@ _FindOrCreate(Table &table, if (iresult.second || (Table::NodeHandle::IsCounted && Access::GetRefCount( - iresult.first->second).fetch_and_increment() == 0)) { + iresult.first->second).fetch_add(1) == 0)) { // There was either no entry, or there was one but it had begun dying // (another client dropped its refcount to 0). We have to create a new // entry in the table. When the client that is deleting the other node diff --git a/pxr/usd/sdf/pathNode.h b/pxr/usd/sdf/pathNode.h index 1fdd1ba0d0..e4849b6d99 100644 --- a/pxr/usd/sdf/pathNode.h +++ b/pxr/usd/sdf/pathNode.h @@ -33,7 +33,7 @@ #include #include -#include +#include PXR_NAMESPACE_OPEN_SCOPE @@ -311,7 +311,7 @@ class Sdf_PathNode { // Instance variables. PathNode's size is important to keep small. Please // be mindful of that when making any changes here. const Sdf_PathNodeConstRefPtr _parent; - mutable tbb::atomic _refCount; + mutable std::atomic _refCount; const short _elementCount; const unsigned char _nodeType; @@ -751,7 +751,7 @@ inline void intrusive_ptr_add_ref(const PXR_NS::Sdf_PathNode* p) { ++p->_refCount; } inline void intrusive_ptr_release(const PXR_NS::Sdf_PathNode* p) { - if (p->_refCount.fetch_and_decrement() == 1) + if (p->_refCount.fetch_sub(1) == 1) p->_Destroy(); } diff --git a/pxr/usd/sdf/pch.h b/pxr/usd/sdf/pch.h index 0728ebe683..6af480e7e3 100644 --- a/pxr/usd/sdf/pch.h +++ b/pxr/usd/sdf/pch.h @@ -225,7 +225,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usd/pch.h b/pxr/usd/usd/pch.h index bd515aa438..96a656e809 100644 --- a/pxr/usd/usd/pch.h +++ b/pxr/usd/usd/pch.h @@ -228,7 +228,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdGeom/bboxCache.cpp b/pxr/usd/usdGeom/bboxCache.cpp index 711bc825ab..1d4883c373 100644 --- a/pxr/usd/usdGeom/bboxCache.cpp +++ b/pxr/usd/usdGeom/bboxCache.cpp @@ -45,6 +45,7 @@ #include #include +#include PXR_NAMESPACE_OPEN_SCOPE @@ -100,11 +101,24 @@ class UsdGeomBBoxCache::_PrototypeBBoxResolver struct _PrototypeTask { - _PrototypeTask() : numDependencies(0) { } + _PrototypeTask() noexcept + : numDependencies(0) { } + + _PrototypeTask(const _PrototypeTask &other) noexcept + : dependentPrototypes(other.dependentPrototypes) + { + numDependencies.store(other.numDependencies.load()); + } + + _PrototypeTask(_PrototypeTask &&other) noexcept + : dependentPrototypes(std::move(other.dependentPrototypes)) + { + numDependencies.store(other.numDependencies.load()); + } // Number of dependencies -- prototype prims that must be resolved // before this prototype can be resolved. - tbb::atomic numDependencies; + std::atomic numDependencies; // List of prototype prims that depend on this prototype. std::vector<_PrimContext> dependentPrototypes; @@ -196,7 +210,7 @@ class UsdGeomBBoxCache::_PrototypeBBoxResolver _PrototypeTask& dependentPrototypeData = prototypeTasks->find(dependentPrototype)->second; if (dependentPrototypeData.numDependencies - .fetch_and_decrement() == 1){ + .fetch_sub(1) == 1){ dispatcher->Run( &_PrototypeBBoxResolver::_ExecuteTaskForPrototype, this, dependentPrototype, prototypeTasks, xfCaches, @@ -1484,4 +1498,3 @@ size_t hash_value(const UsdGeomBBoxCache::_PrimContext &key) PXR_NAMESPACE_CLOSE_SCOPE - diff --git a/pxr/usd/usdGeom/pch.h b/pxr/usd/usdGeom/pch.h index 824c5b0f93..1a5fd65073 100644 --- a/pxr/usd/usdGeom/pch.h +++ b/pxr/usd/usdGeom/pch.h @@ -181,7 +181,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdHydra/pch.h b/pxr/usd/usdHydra/pch.h index 5ba9df4c20..61ffecdf05 100644 --- a/pxr/usd/usdHydra/pch.h +++ b/pxr/usd/usdHydra/pch.h @@ -162,7 +162,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdLux/pch.h b/pxr/usd/usdLux/pch.h index 8fe34cb954..e503ef1049 100644 --- a/pxr/usd/usdLux/pch.h +++ b/pxr/usd/usdLux/pch.h @@ -177,7 +177,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdMedia/pch.h b/pxr/usd/usdMedia/pch.h index 7802ec3e2d..8388208cd4 100644 --- a/pxr/usd/usdMedia/pch.h +++ b/pxr/usd/usdMedia/pch.h @@ -170,7 +170,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdMtlx/pch.h b/pxr/usd/usdMtlx/pch.h index 5eba44e7ed..88f7872389 100644 --- a/pxr/usd/usdMtlx/pch.h +++ b/pxr/usd/usdMtlx/pch.h @@ -193,7 +193,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdPhysics/pch.h b/pxr/usd/usdPhysics/pch.h index 824c5b0f93..1a5fd65073 100644 --- a/pxr/usd/usdPhysics/pch.h +++ b/pxr/usd/usdPhysics/pch.h @@ -181,7 +181,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdRender/pch.h b/pxr/usd/usdRender/pch.h index 7802ec3e2d..8388208cd4 100644 --- a/pxr/usd/usdRender/pch.h +++ b/pxr/usd/usdRender/pch.h @@ -170,7 +170,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdRi/pch.h b/pxr/usd/usdRi/pch.h index 905d2a1236..ba6c609881 100644 --- a/pxr/usd/usdRi/pch.h +++ b/pxr/usd/usdRi/pch.h @@ -173,7 +173,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdShade/pch.h b/pxr/usd/usdShade/pch.h index 698ab0ca65..8e0433d34b 100644 --- a/pxr/usd/usdShade/pch.h +++ b/pxr/usd/usdShade/pch.h @@ -179,7 +179,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdSkel/pch.h b/pxr/usd/usdSkel/pch.h index a4205ac46d..63975be9db 100644 --- a/pxr/usd/usdSkel/pch.h +++ b/pxr/usd/usdSkel/pch.h @@ -180,7 +180,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdUI/pch.h b/pxr/usd/usdUI/pch.h index 47666439a2..ef31dc083d 100644 --- a/pxr/usd/usdUI/pch.h +++ b/pxr/usd/usdUI/pch.h @@ -168,7 +168,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdUtils/pch.h b/pxr/usd/usdUtils/pch.h index 3a108ee5ef..e76753154e 100644 --- a/pxr/usd/usdUtils/pch.h +++ b/pxr/usd/usdUtils/pch.h @@ -215,7 +215,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usd/usdVol/pch.h b/pxr/usd/usdVol/pch.h index 7802ec3e2d..8388208cd4 100644 --- a/pxr/usd/usdVol/pch.h +++ b/pxr/usd/usdVol/pch.h @@ -170,7 +170,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usdImaging/plugin/usdShaders/pch.h b/pxr/usdImaging/plugin/usdShaders/pch.h index 2037e25b8b..c5836624f4 100644 --- a/pxr/usdImaging/plugin/usdShaders/pch.h +++ b/pxr/usdImaging/plugin/usdShaders/pch.h @@ -160,7 +160,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usdImaging/usdAppUtils/pch.h b/pxr/usdImaging/usdAppUtils/pch.h index 70b9602d5e..f403f45009 100644 --- a/pxr/usdImaging/usdAppUtils/pch.h +++ b/pxr/usdImaging/usdAppUtils/pch.h @@ -173,7 +173,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usdImaging/usdImaging/pch.h b/pxr/usdImaging/usdImaging/pch.h index 35ea5620ec..0419c53efa 100644 --- a/pxr/usdImaging/usdImaging/pch.h +++ b/pxr/usdImaging/usdImaging/pch.h @@ -173,7 +173,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usdImaging/usdImaging/resolvedAttributeCache.h b/pxr/usdImaging/usdImaging/resolvedAttributeCache.h index 5d29eced7c..b8cd2cd944 100644 --- a/pxr/usdImaging/usdImaging/resolvedAttributeCache.h +++ b/pxr/usdImaging/usdImaging/resolvedAttributeCache.h @@ -286,22 +286,36 @@ class UsdImaging_ResolvedAttributeCache // non-time varying data, entries may exist in the cache with invalid // values. The version is used to determine validity. struct _Entry { - _Entry() + _Entry() noexcept : value(Strategy::MakeDefault()) , version(_GetInitialEntryVersion()) { } _Entry(const query_type & query_, const value_type& value_, - unsigned version_) + unsigned version_) noexcept : query(query_) , value(value_) , version(version_) { } + _Entry(const _Entry &other) noexcept + : query(other.query) + , value(other.value) + { + version.store(other.version.load()); + } + + _Entry(_Entry &&other) noexcept + : query(std::move(other.query)) + , value(std::move(other.value)) + { + version.store(other.version.load()); + } + query_type query; value_type value; - tbb::atomic version; + std::atomic version; }; // Returns the version number for a valid cache entry @@ -341,7 +355,7 @@ class UsdImaging_ResolvedAttributeCache // A serial number indicating the valid state of entries in the cache. When // an entry has an equal or greater value, the entry is valid. - tbb::atomic _cacheVersion; + std::atomic _cacheVersion; // Value overrides for a set of descendents. ValueOverridesMap _valueOverrides; @@ -359,8 +373,9 @@ UsdImaging_ResolvedAttributeCache::_SetCacheEntryForPrim( { // Note: _cacheVersion is not allowed to change during cache access. unsigned v = entry->version; + unsigned cv = _cacheVersion.load(); if (v < _cacheVersion - && entry->version.compare_and_swap(_cacheVersion, v) == v) + && entry->version.compare_exchange_strong(cv, v)) { entry->value = value; entry->version = _GetValidVersion(); diff --git a/pxr/usdImaging/usdImagingGL/pch.h b/pxr/usdImaging/usdImagingGL/pch.h index b9dfa7e416..78b92909e3 100644 --- a/pxr/usdImaging/usdImagingGL/pch.h +++ b/pxr/usdImaging/usdImagingGL/pch.h @@ -186,7 +186,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usdImaging/usdRiImaging/pch.h b/pxr/usdImaging/usdRiImaging/pch.h index 6ad2d403bb..09a7a06cc8 100644 --- a/pxr/usdImaging/usdRiImaging/pch.h +++ b/pxr/usdImaging/usdRiImaging/pch.h @@ -169,7 +169,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usdImaging/usdSkelImaging/pch.h b/pxr/usdImaging/usdSkelImaging/pch.h index 69caaac23b..7086fc4124 100644 --- a/pxr/usdImaging/usdSkelImaging/pch.h +++ b/pxr/usdImaging/usdSkelImaging/pch.h @@ -169,7 +169,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usdImaging/usdVolImaging/pch.h b/pxr/usdImaging/usdVolImaging/pch.h index 0fd54d571b..b286bc7592 100644 --- a/pxr/usdImaging/usdVolImaging/pch.h +++ b/pxr/usdImaging/usdVolImaging/pch.h @@ -167,7 +167,6 @@ #include #include #include -#include #include #include #include diff --git a/pxr/usdImaging/usdviewq/pch.h b/pxr/usdImaging/usdviewq/pch.h index 1e55e66893..905a6bbc14 100644 --- a/pxr/usdImaging/usdviewq/pch.h +++ b/pxr/usdImaging/usdviewq/pch.h @@ -167,7 +167,6 @@ #include #include #include -#include #include #include #include