mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-09-05 04:07:58 +08:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user