Skip to content

Commit

Permalink
Merge pull request #1486 from waywardmonkeys/base-tbb-atomic-to-std
Browse files Browse the repository at this point in the history
base: Use std::atomic instead of tbb.

(Internal change: 2161315)
  • Loading branch information
pixar-oss committed Apr 22, 2021
2 parents d0f8608 + 388e589 commit 3232d10
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pxr/base/tf/diagnosticMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ TfDiagnosticMgr::AppendError(TfError const &e) {
} else {
ErrorList &errorList = _errorList.local();
errorList.push_back(e);
errorList.back()._serial = _nextSerial.fetch_and_increment();
errorList.back()._serial = _nextSerial.fetch_add(1);
_AppendErrorsToLogText(std::prev(errorList.end()));
}
}
Expand All @@ -203,7 +203,7 @@ TfDiagnosticMgr::_SpliceErrors(ErrorList &src)
}
} else {
// Reassign new serial numbers to the errors.
size_t serial = _nextSerial.fetch_and_add(src.size());
size_t serial = _nextSerial.fetch_add(src.size());
for (auto& error : src) {
error._serial = serial++;
}
Expand Down
4 changes: 2 additions & 2 deletions pxr/base/tf/diagnosticMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@

#include <tbb/enumerable_thread_specific.h>
#include <tbb/spin_rw_mutex.h>
#include <tbb/atomic.h>

#include <atomic>
#include <cstdarg>
#include <list>
#include <string>
Expand Down Expand Up @@ -434,7 +434,7 @@ class TfDiagnosticMgr : public TfWeakBase {
mutable tbb::spin_rw_mutex _delegatesMutex;

// Global serial number for sorting.
tbb::atomic<size_t> _nextSerial;
std::atomic<size_t> _nextSerial;

// Thread-specific error list.
tbb::enumerable_thread_specific<ErrorList> _errorList;
Expand Down
2 changes: 1 addition & 1 deletion pxr/base/tf/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TfError::TfError(TfEnum errorCode, const char* errorCodeString,
: TfDiagnosticBase(errorCode, errorCodeString, context, commentary, info,
quiet)
{
_serial = TfDiagnosticMgr::GetInstance()._nextSerial.fetch_and_increment();
_serial = TfDiagnosticMgr::GetInstance()._nextSerial.fetch_add(1);
}

PXR_NAMESPACE_CLOSE_SCOPE
4 changes: 2 additions & 2 deletions pxr/base/work/threadLimits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

#include "pxr/base/tf/envSetting.h"

#include <tbb/atomic.h>
#include <tbb/task_scheduler_init.h>

#include <algorithm>
#include <atomic>

PXR_NAMESPACE_USING_DIRECTIVE

Expand Down Expand Up @@ -63,7 +63,7 @@ PXR_NAMESPACE_OPEN_SCOPE
// if PXR_WORK_THREAD_LIMIT is set to some nonzero value, otherwise we leave it
// up to others. So there's no guarantee that calling
// WorkSetConcurrencyLimit(n) will actually limit Work to n threads.
static tbb::atomic<unsigned> _threadLimit;
static std::atomic<unsigned> _threadLimit;

// We create a task_scheduler_init instance at static initialization time if
// PXR_WORK_THREAD_LIMIT is set to a nonzero value. Otherwise this stays NULL.
Expand Down

0 comments on commit 3232d10

Please sign in to comment.