Skip to content

Commit

Permalink
Merge pull request #2464 from brechtvl/onetbb-mutex
Browse files Browse the repository at this point in the history
oneTBB: change tbb::mutex to std::mutex

(Internal change: 2324897)
  • Loading branch information
pixar-oss committed Apr 19, 2024
2 parents d4f99d5 + 40fbc9a commit d616fbf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
22 changes: 10 additions & 12 deletions pxr/usd/usd/clipCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex> lock = (_concurrentPopulationContext) ?
std::unique_lock<std::mutex>(_concurrentPopulationContext->_mutex) :
std::unique_lock<std::mutex>();

// Find nearest ancestor with clips specified.
const std::vector<Usd_ClipSetRefPtr>* ancestralClips = nullptr;
Expand Down Expand Up @@ -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<std::mutex> lock = (_concurrentPopulationContext) ?
std::unique_lock<std::mutex>(_concurrentPopulationContext->_mutex) :
std::unique_lock<std::mutex>();
SdfLayerHandleSet layers;
for (_ClipTable::iterator::value_type const &clipsListIter : _table){
for (Usd_ClipSetRefPtr const &clipSet : clipsListIter.second){
Expand Down Expand Up @@ -342,10 +341,9 @@ const std::vector<Usd_ClipSetRefPtr>&
Usd_ClipCache::GetClipsForPrim(const SdfPath& path) const
{
TRACE_FUNCTION();
tbb::mutex::scoped_lock lock;
if (_concurrentPopulationContext) {
lock.acquire(_concurrentPopulationContext->_mutex);
}
std::unique_lock<std::mutex> lock = (_concurrentPopulationContext) ?
std::unique_lock<std::mutex>(_concurrentPopulationContext->_mutex) :
std::unique_lock<std::mutex>();
return _GetClipsForPrim_NoLock(path);
}

Expand Down
4 changes: 2 additions & 2 deletions pxr/usd/usd/clipCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "pxr/usd/usd/clipSet.h"
#include "pxr/usd/sdf/pathTable.h"

#include <tbb/mutex.h>
#include <mutex>
#include <vector>

PXR_NAMESPACE_OPEN_SCOPE
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d616fbf

Please sign in to comment.