Coding - Replace Standard_Mutex with std::mutex and migrate to RAII locks (#766)

- Replace legacy Standard_Mutex usage across many modules with std::mutex.
- Include <mutex> where needed and remove <Standard_Mutex.hxx> includes.
- Replace Standard_Mutex::Sentry / explicit Lock/Unlock with std::lock_guard or std::unique_lock.
- Convert optional/heap mutex holders to std::unique_ptr<std::mutex> and adapt locking accordingly.
- Simplify several singleton initializations (remove manual double-checked locking where safe).
- Use thread_local for per-thread flags instead of ad-hoc mutex protection.
- Fix BVH_BuildQueue Fetch logic to preserve thread counters and wasBusy handling.
- Remove obsolete TopTools_MutexForShapeProvider sources and update FILES.cmake.

This modernizes mutex usage, reduces dependency on custom mutex types and improves clarity of locking patterns.
This commit is contained in:
Pasukhin Dmitry
2025-11-03 16:44:08 +00:00
committed by GitHub
parent d98f74d893
commit 787bee375c
95 changed files with 562 additions and 568 deletions
@@ -259,7 +259,8 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
{
Handle(BRepCheck_HListOfStatus) aHList;
{
Standard_Mutex::Sentry aLock(myMutex.get());
std::unique_lock<std::mutex> aLock =
myMutex ? std::unique_lock<std::mutex>(*myMutex) : std::unique_lock<std::mutex>();
if (myMap.IsBound(S))
{
return;
@@ -327,7 +328,7 @@ void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
constexpr Standard_Real eps = Precision::PConfusion();
Standard_Boolean toRunParallel = !myMutex.IsNull();
const Standard_Boolean toRunParallel = myMutex != nullptr;
while (itcr.More())
{
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
@@ -571,7 +572,8 @@ Standard_Boolean BRepCheck_Edge::GeometricControls() const
void BRepCheck_Edge::SetStatus(const BRepCheck_Status theStatus)
{
Standard_Mutex::Sentry aLock(myMutex.get());
std::unique_lock<std::mutex> aLock =
myMutex ? std::unique_lock<std::mutex>(*myMutex) : std::unique_lock<std::mutex>();
BRepCheck::Add(*myMap(myShape), theStatus);
}