Foundation Classes - Rework atomic and Standard_Condition#598
Merged
dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom Jul 10, 2025
Merged
Foundation Classes - Rework atomic and Standard_Condition#598dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom
Conversation
Refactor atomic operations to use std::atomic for thread safety and performance improvements Update Standard_Condition to use std::condition_variable for better synchronization
…Atomic, Graphic3d_Camera, and Select3D_SensitivePrimitiveArray
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes atomic counters by switching from Standard_Atomic to std::atomic across multiple modules and refactors Standard_Condition to use C++ standard threading primitives instead of platform-specific APIs.
- Replace all
Standard_Atomic_Increment/Decrementcalls andvolatilecounters withstd::atomicusage. - Rewrite
Standard_Conditionheader to usestd::mutex,std::condition_variable, andstd::atomic<bool>; remove its implementation file. - Update build files (CMake lists) and deprecate old atomic APIs in
Standard_Atomic.hxx.
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Visualization/TKV3d/Select3D/Select3D_SensitivePrimitiveArray.cxx | Swapped Standard_Atomic for std::atomic on myNbFailures. |
| src/Visualization/TKService/Graphic3d/Graphic3d_TextureRoot.cxx | Changed static counter to std::atomic and prefix‐increment. |
| src/Visualization/TKService/Graphic3d/Graphic3d_ShaderProgram.cxx | Same atomic counter refactor. |
| src/Visualization/TKService/Graphic3d/Graphic3d_ShaderObject.cxx | Same atomic counter refactor. |
| src/Visualization/TKService/Graphic3d/Graphic3d_MarkerImage.cxx | Same atomic counter refactor for marker IDs. |
| src/Visualization/TKService/Graphic3d/Graphic3d_HatchStyle.cxx | Same atomic counter refactor for hatch styles. |
| src/Visualization/TKService/Graphic3d/Graphic3d_ClipPlane.cxx | Same atomic counter refactor for clip planes. |
| src/Visualization/TKService/Graphic3d/Graphic3d_Camera.cxx | Same atomic counter refactor for camera state IDs. |
| src/Visualization/TKService/Graphic3d/Graphic3d_CLight.cxx | Same atomic counter refactor for light IDs. |
| src/FoundationClasses/TKernel/Standard/Standard_Condition.hxx | Replaced platform-specific condition/event code with STL types. |
| src/FoundationClasses/TKernel/Standard/Standard_Condition.cxx | Removed old pthread/Win32 implementation file. |
| src/FoundationClasses/TKernel/Standard/Standard_Atomic.hxx | Added deprecation macros and includes for <atomic>. |
| src/FoundationClasses/TKernel/Standard/FILES.cmake | Removed Standard_Condition.cxx from build list. |
| src/FoundationClasses/TKernel/OSD/OSD_ThreadPool.hxx | Updated volatile int and atomic helpers to std::atomic<int>. |
| src/FoundationClasses/TKernel/OSD/OSD_ThreadPool.cxx | Replaced Standard_Atomic_CompareAndSwap with exchange/store. |
| src/Draw/TKQADraw/QABugs/QABugs_19.cxx | Updated test atomics to use std::atomic<int>. |
| src/Draw/TKQADraw/QABugs/QABugs_11.cxx | Updated test atomics to use std::atomic<Standard_Integer>. |
Comments suppressed due to low confidence (1)
src/FoundationClasses/TKernel/Standard/Standard_Condition.hxx:36
- The
Standard_EXPORTspecifier was removed from the constructor (and other methods), which can break symbol visibility on Windows. Please re-applyStandard_EXPORTto public methods to preserve the library's ABI.
Standard_Condition(bool theIsSet = false)
AtheneNoctuaPt
approved these changes
Jul 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor atomic operations to use std::atomic for thread safety and performance improvements
Update Standard_Condition to use std::condition_variable for better synchronization