From 40fbc9a4e8c0e619b792a611850cd8060ad6a655 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 18 May 2023 00:51:24 +0200 Subject: [PATCH] oneTBB: change tbb::mutex to std::mutex --- pxr/usd/usd/clipCache.cpp | 22 ++++++++++------------ pxr/usd/usd/clipCache.h | 4 ++-- pxr/usd/usd/instanceCache.h | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pxr/usd/usd/clipCache.cpp b/pxr/usd/usd/clipCache.cpp index c582e1d8be..b8215378ed 100644 --- a/pxr/usd/usd/clipCache.cpp +++ b/pxr/usd/usd/clipCache.cpp @@ -218,10 +218,9 @@ Usd_ClipCache::PopulateClipsForPrim( const bool primHasClips = !allClips.empty(); if (primHasClips) { TRACE_SCOPE("Usd_ClipCache::PopulateClipsForPrim (primHasClips)"); - tbb::mutex::scoped_lock lock; - if (_concurrentPopulationContext) { - lock.acquire(_concurrentPopulationContext->_mutex); - } + std::unique_lock lock = (_concurrentPopulationContext) ? + std::unique_lock(_concurrentPopulationContext->_mutex) : + std::unique_lock(); // Find nearest ancestor with clips specified. const std::vector* ancestralClips = nullptr; @@ -260,10 +259,10 @@ Usd_ClipCache::PopulateClipsForPrim( SdfLayerHandleSet Usd_ClipCache::GetUsedLayers() const { - tbb::mutex::scoped_lock lock; - if (_concurrentPopulationContext) { - lock.acquire(_concurrentPopulationContext->_mutex); - } + std::unique_lock lock = (_concurrentPopulationContext) ? + std::unique_lock(_concurrentPopulationContext->_mutex) : + std::unique_lock(); + SdfLayerHandleSet layers; for (_ClipTable::iterator::value_type const &clipsListIter : _table){ for (Usd_ClipSetRefPtr const &clipSet : clipsListIter.second){ @@ -342,10 +341,9 @@ const std::vector& Usd_ClipCache::GetClipsForPrim(const SdfPath& path) const { TRACE_FUNCTION(); - tbb::mutex::scoped_lock lock; - if (_concurrentPopulationContext) { - lock.acquire(_concurrentPopulationContext->_mutex); - } + std::unique_lock lock = (_concurrentPopulationContext) ? + std::unique_lock(_concurrentPopulationContext->_mutex) : + std::unique_lock(); return _GetClipsForPrim_NoLock(path); } diff --git a/pxr/usd/usd/clipCache.h b/pxr/usd/usd/clipCache.h index 2bff0833aa..fbe2ea72dc 100644 --- a/pxr/usd/usd/clipCache.h +++ b/pxr/usd/usd/clipCache.h @@ -30,7 +30,7 @@ #include "pxr/usd/usd/clipSet.h" #include "pxr/usd/sdf/pathTable.h" -#include +#include #include PXR_NAMESPACE_OPEN_SCOPE @@ -61,7 +61,7 @@ class Usd_ClipCache explicit ConcurrentPopulationContext(Usd_ClipCache &cache); ~ConcurrentPopulationContext(); Usd_ClipCache &_cache; - tbb::mutex _mutex; + std::mutex _mutex; }; /// Populate the cache with clips for \p prim. Returns true if clips diff --git a/pxr/usd/usd/instanceCache.h b/pxr/usd/usd/instanceCache.h index 0a25a7e30c..4b7c948de2 100644 --- a/pxr/usd/usd/instanceCache.h +++ b/pxr/usd/usd/instanceCache.h @@ -30,7 +30,7 @@ #include "pxr/usd/sdf/path.h" #include "pxr/base/tf/hashmap.h" -#include +#include #include #include #include