Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from deprecated tbb::mutex to std::mutex #3

Open
wants to merge 1 commit into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dso/map/DeformationMap/DeformationMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ DeformationMap::DeformationMap(const scene_rdl2::rdl2::SceneClass& sceneClass,
// To allow for the possibility that we may someday create image maps
// on multiple threads, we'll protect the writes of the class statics
// with a mutex.
static tbb::mutex errorMutex;
tbb::mutex::scoped_lock lock(errorMutex);
static std::mutex errorMutex;
std::scoped_lock lock(errorMutex);

MOONRAY_START_THREADSAFE_STATIC_WRITE

Expand Down
4 changes: 2 additions & 2 deletions dso/map/DirectionalMap/DirectionalMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ DirectionalMap::DirectionalMap(const SceneClass& sceneClass, const std::string&
// to allow for the possibility that we may someday create image maps
// on multiple threads, we'll protect the writes of the class statics
// with a mutex.
static tbb::mutex errorMutex;
tbb::mutex::scoped_lock lock(errorMutex);
static std::mutex errorMutex;
std::scoped_lock lock(errorMutex);
MOONRAY_START_THREADSAFE_STATIC_WRITE

sDirectionalMapData.sErrorMissingRefN = mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
Expand Down
4 changes: 2 additions & 2 deletions dso/map/GradientMap/GradientMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ GradientMap::GradientMap(const scene_rdl2::rdl2::SceneClass &sceneClass,
// to allow for the possibility that we may someday create image maps
// on multiple threads, we'll protect the writes of the class statics
// with a mutex.
static tbb::mutex errorMutex;
tbb::mutex::scoped_lock lock(errorMutex);
static std::mutex errorMutex;
std::scoped_lock lock(errorMutex);
MOONRAY_START_THREADSAFE_STATIC_WRITE
sStaticGradientMapData.sErrorMissingReferenceData =
mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
Expand Down
4 changes: 2 additions & 2 deletions dso/map/HairColumnMap/HairColumnMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ HairColumnMap::HairColumnMap(const SceneClass &sceneClass, const std::string &na
// to allow for the possibility that we may someday create image maps
// on multiple threads, we'll protect the writes of the class statics
// with a mutex.
static tbb::mutex errorMutex;
tbb::mutex::scoped_lock lock(errorMutex);
static std::mutex errorMutex;
std::scoped_lock lock(errorMutex);
MOONRAY_START_THREADSAFE_STATIC_WRITE
sErrorScatterTagMissing =
mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
Expand Down
4 changes: 2 additions & 2 deletions dso/map/NoiseMap/v2/NoiseMap_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ NoiseMap_v2::NoiseMap_v2(SceneClass const &sceneClass,
// to allow for the possibility that we may someday create image maps
// on multiple threads, we'll protect the writes of the class statics
// with a mutex.
static tbb::mutex errorMutex;
tbb::mutex::scoped_lock lock(errorMutex);
static std::mutex errorMutex;
std::scoped_lock lock(errorMutex);
MOONRAY_START_THREADSAFE_STATIC_WRITE
sStaticNoiseMapData.sErrorMissingReferenceData =
mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
Expand Down
4 changes: 2 additions & 2 deletions dso/map/NoiseWorleyMap/v2/NoiseWorleyMap_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ NoiseWorleyMap_v2::NoiseWorleyMap_v2(SceneClass const &sceneClass, std::string c
// to allow for the possibility that we may someday create image maps
// on multiple threads, we'll protect the writes of the class statics
// with a mutex.
static tbb::mutex errorMutex;
tbb::mutex::scoped_lock lock(errorMutex);
static std::mutex errorMutex;
std::scoped_lock lock(errorMutex);
MOONRAY_START_THREADSAFE_STATIC_WRITE
sStaticNoiseWorleyMapData.sErrorMissingReferenceData =
mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
Expand Down
4 changes: 2 additions & 2 deletions dso/map/UVTransformMap/UVTransformMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ UVTransformMap::UVTransformMap(const SceneClass& sceneClass,
// to allow for the possibility that we may someday create image maps
// on multiple threads, we'll protect the writes of the class statics
// with a mutex.
static tbb::mutex errorMutex;
tbb::mutex::scoped_lock lock(errorMutex);
static std::mutex errorMutex;
std::scoped_lock lock(errorMutex);
MOONRAY_START_THREADSAFE_STATIC_WRITE
sStaticUVTransformMapData.sErrorMissingReferenceData =
mLogEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
Expand Down
4 changes: 2 additions & 2 deletions dso/material/HairLayer/HairLayerMaterial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ HairLayerMaterial::HairLayerMaterial(const scene_rdl2::rdl2::SceneClass& sceneCl
// with a mutex.
mIspc.mStaticData = (ispc::HairLayerMaterialStaticData*)&sStaticHairLayerMaterialData;

static tbb::mutex errorMutex;
tbb::mutex::scoped_lock lock(errorMutex);
static std::mutex errorMutex;
std::scoped_lock lock(errorMutex);
MOONRAY_START_THREADSAFE_STATIC_WRITE

mIspc.mStaticData->sErrorMismatchedFresnelType =
Expand Down
4 changes: 2 additions & 2 deletions lib/common/noise/Noise.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace scene_rdl2::math;

bool Noise::sNoiseIsDataInitialized = false;
scene_rdl2::util::Random Noise::sNoiseRandom = scene_rdl2::util::Random(0xbeadceef);
tbb::mutex Noise::sNoiseInitDataMutex;
std::mutex Noise::sNoiseInitDataMutex;
std::vector<int> Noise::sNoisePermutationTable;

Noise::Noise(const int seed,
Expand All @@ -25,7 +25,7 @@ Noise::Noise(const int seed,
mIspc.mTableSize = tableSize;

if (useStaticTables) {
tbb::mutex::scoped_lock dataLock(sNoiseInitDataMutex); // Lock this part that initializes static data
std::scoped_lock dataLock(sNoiseInitDataMutex); // Lock this part that initializes static data
// Only construct the static data once to share across all instances
if (!sNoiseIsDataInitialized) {
buildStaticTables(tableSize);
Expand Down
4 changes: 2 additions & 2 deletions lib/common/noise/Noise.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#pragma warning disable 1711 // Warnings about assignemnt to statically allocated data

#include "Noise_ispc_stubs.h"
#include <tbb/mutex.h>
#include <scene_rdl2/common/math/Vec3.h>
#include <scene_rdl2/common/math/Xform.h>
#include <mutex>

// Forward declaration
namespace scene_rdl2 {
Expand Down Expand Up @@ -71,7 +71,7 @@ class Noise
// Static data
static bool sNoiseIsDataInitialized;
static scene_rdl2::util::Random sNoiseRandom;
static tbb::mutex sNoiseInitDataMutex;
static std::mutex sNoiseInitDataMutex;
static std::vector<int> sNoisePermutationTable;

private:
Expand Down
4 changes: 2 additions & 2 deletions lib/common/noise/Worley.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ collectPoints(const Worley_PointArray::iterator tmpWorleyPointsBeg,

// Static data
bool Worley::sIsWorleyDataInitialized = false;
tbb::mutex Worley::sWorleyInitDataMutex;
std::mutex Worley::sWorleyInitDataMutex;
std::vector<float> Worley::sWorleyPointsX;
std::vector<float> Worley::sWorleyPointsY;
std::vector<float> Worley::sWorleyPointsZ;
Expand Down Expand Up @@ -255,7 +255,7 @@ Worley::Worley(const int seed,
initPointProbabilities();

if (useStaticTables) {
tbb::mutex::scoped_lock dataLock(sWorleyInitDataMutex); // Lock this part that initializes static data
std::scoped_lock dataLock(sWorleyInitDataMutex); // Lock this part that initializes static data
// Only construct the static data once to share across all instances
if (!sIsWorleyDataInitialized) {
buildStaticPointTables(addNormals, tableSize);
Expand Down
2 changes: 1 addition & 1 deletion lib/common/noise/Worley.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class Worley : public Noise

// Static data
static bool sIsWorleyDataInitialized;
static tbb::mutex sWorleyInitDataMutex;
static std::mutex sWorleyInitDataMutex;

static std::vector<float> sWorleyPointsX;
static std::vector<float> sWorleyPointsY;
Expand Down
4 changes: 2 additions & 2 deletions lib/map/projection/ProjectionUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ initLogEvents(ispc::PROJECTION_StaticData& staticData,
// to allow for the possibility that we may someday create image maps
// on multiple threads, we'll protect the writes of the class statics
// with a mutex.
static tbb::mutex errorMutex;
tbb::mutex::scoped_lock lock(errorMutex);
static std::mutex errorMutex;
std::scoped_lock lock(errorMutex);
MOONRAY_START_THREADSAFE_STATIC_WRITE

staticData.sErrorMissingProjector = logEventRegistry.createEvent(scene_rdl2::logging::ERROR_LEVEL,
Expand Down
4 changes: 2 additions & 2 deletions lib/material/dwabase/DwaBaseLayerable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ DwaBaseLayerable::registerShadeTimeEventMessages()
// To allow for the possibility that we may someday create materials
// on multiple threads, we'll protect the writes of the class statics
// with a mutex.
static tbb::mutex errorMutex;
tbb::mutex::scoped_lock lock(errorMutex);
static std::mutex errorMutex;
std::scoped_lock lock(errorMutex);
MOONRAY_START_THREADSAFE_STATIC_WRITE

sEventMessages.sErrorNoRefN =
Expand Down