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 #4

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
18 changes: 9 additions & 9 deletions lib/scene/rdl2/SceneContext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <scene_rdl2/render/logging/logging.h>

#include <tbb/concurrent_hash_map.h>
#include <tbb/mutex.h>
#include <tbb/parallel_for_each.h>

#include <algorithm>
Expand All @@ -41,6 +40,7 @@
#include <sstream>
#include <string>
#include <vector>
#include <mutex>

#include <dirent.h>
#include <errno.h>
Expand Down Expand Up @@ -185,7 +185,7 @@ const rdl2::Camera*
SceneContext::getPrimaryCamera() const
{
// Prevent possible race condition with mCameras.push_back() in createSceneObject().
tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
std::scoped_lock lock(mCreateSceneObjectMutex);

if (mCameras.size() == 0) {
return nullptr;
Expand All @@ -205,7 +205,7 @@ std::vector<const rdl2::Camera*>
SceneContext::getCameras() const
{
// Prevent possible race condition with mCameras.push_back() in createSceneObject().
tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
std::scoped_lock lock(mCreateSceneObjectMutex);

std::vector<const rdl2::Camera*> cameras;

Expand Down Expand Up @@ -236,7 +236,7 @@ std::vector<const rdl2::Camera*>
SceneContext::getActiveCameras(void) const
{
// Prevent possible race condition with mCameras.push_back() in createSceneObject().
tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
std::scoped_lock lock(mCreateSceneObjectMutex);

std::vector<const rdl2::Camera*> cameras;

Expand Down Expand Up @@ -447,16 +447,16 @@ SceneContext::createSceneObject(const std::string& className,

// Do any type-specific setup.
if (obj->isA<Geometry>()) {
tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
std::scoped_lock lock(mCreateSceneObjectMutex);
mGeometries.push_back(obj->asA<Geometry>());
} else if (obj->isA<GeometrySet>()) {
tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
std::scoped_lock lock(mCreateSceneObjectMutex);
mGeometrySets.push_back(obj->asA<GeometrySet>());
} else if (obj->isA<Camera>()) {
tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
std::scoped_lock lock(mCreateSceneObjectMutex);
mCameras.push_back(obj->asA<Camera>());
} else if (obj->isA<RenderOutput>()) {
tbb::mutex::scoped_lock lock(mCreateSceneObjectMutex);
std::scoped_lock lock(mCreateSceneObjectMutex);
mRenderOutputs.push_back(obj->asA<RenderOutput>());
}

Expand Down Expand Up @@ -770,7 +770,7 @@ SceneContext::computeTimeRescalingCoeffs(float shutterOpen, float shutterClose,
{
// See declaration of TimeRescalingCoeffs in Types.h for details.

tbb::mutex::scoped_lock lock(mTimeRescalingCoeffsMutex);
std::scoped_lock lock(mTimeRescalingCoeffsMutex);

MNRY_ASSERT_REQUIRE(motionSteps.size() >= 1 && motionSteps.size() <= 2);
if (motionSteps.size() == 1 || motionSteps[0] == motionSteps[1]) {
Expand Down
5 changes: 2 additions & 3 deletions lib/scene/rdl2/SceneContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <scene_rdl2/render/util/Alloc.h>
#include <scene_rdl2/common/platform/Platform.h>
#include <tbb/concurrent_hash_map.h>
#include <tbb/mutex.h>

#include <string>

Expand Down Expand Up @@ -382,7 +381,7 @@ class SceneContext
// it's being updated. In other words, doing an interpolated get() against
// ANY object while the camera's shutter interval or SceneVariables motion
// steps are being updated is a recipe for threading errors.
tbb::mutex mTimeRescalingCoeffsMutex;
std::mutex mTimeRescalingCoeffsMutex;

// All cameras in the rdl context (including the primary camera).
// This is in creation order. The primary camera can't be assumed to be
Expand Down Expand Up @@ -414,7 +413,7 @@ class SceneContext
// Mutex to sync write access to thread unsafe vectors like mGeometries only in
// conditioning time. Those vectors will remain lock free for reading and reading / writing
// at the same time is not allowed or protected in any way
mutable tbb::mutex mCreateSceneObjectMutex;
mutable std::mutex mCreateSceneObjectMutex;

RenderOutputVector mRenderOutputs;
std::string mDsoPath;
Expand Down
6 changes: 3 additions & 3 deletions lib/scene/rdl2/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Shader : public SceneObject

// Copy existing attributes into a cache
void cacheAttributes() const {
tbb::mutex::scoped_lock lock(mCachedAttributesMutex);
std::scoped_lock lock(mCachedAttributesMutex);

mCachedRequiredAttributes.clear();
if (!mRequiredAttributes.empty()) {
Expand Down Expand Up @@ -127,7 +127,7 @@ class Shader : public SceneObject
}

void clearCachedAttributes() const {
tbb::mutex::scoped_lock lock(mCachedAttributesMutex);
std::scoped_lock lock(mCachedAttributesMutex);

mCachedRequiredAttributes.clear();
mCachedOptionalAttributes.clear();
Expand Down Expand Up @@ -176,7 +176,7 @@ class Shader : public SceneObject
/**
* Mutex to protect the attribute caches.
*/
mutable tbb::mutex mCachedAttributesMutex;
mutable std::mutex mCachedAttributesMutex;
};

template <>
Expand Down