Skip to content

Shared thread-safe owner#4048

Merged
Fedr merged 4 commits intomasterfrom
SharedThreadSafeOwner
Feb 2, 2025
Merged

Shared thread-safe owner#4048
Fedr merged 4 commits intomasterfrom
SharedThreadSafeOwner

Conversation

@Fedr
Copy link
Contributor

@Fedr Fedr commented Feb 1, 2025

  • New class SharedThreadSafeOwner similar by interface and implementation to existed UniqueThreadSafeOwner, but allowing shared ownership.
  • mutex is replaced on atomic functions of std::shared_ptr (which are already deprecated in C++20, so we define _SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING, but the replacement is not available in Clang).
  • Use new class for storing caches in Mesh, PointCloud, Polyline
  • The main benefit is that if a mesh with cache is copied, then both copies have shared valid cache.

@Fedr Fedr requested a review from andrewerf February 1, 2025 20:41
@Fedr Fedr marked this pull request as ready for review February 1, 2025 20:41

if ( auto p = atomic_load( &obj_ ) ) // already constructed while we setup construction
{
if ( firstConstructor )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could firstConstructor ever be true in this branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very unlikely, indeed. But it can happen, e.g. if update() method just finished its operation in another thread.

@Fedr Fedr merged commit 362c18f into master Feb 2, 2025
31 checks passed
@Fedr Fedr deleted the SharedThreadSafeOwner branch February 2, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants