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

atomic_ref (#2, p0019r8) #843

Merged
merged 145 commits into from Aug 13, 2020
Merged

atomic_ref (#2, p0019r8) #843

merged 145 commits into from Aug 13, 2020

Conversation

AlexGuteniev
Copy link
Contributor

@AlexGuteniev AlexGuteniev commented May 17, 2020

Fixes #2
Seems like it that simple to reuse existing atomic bases.

@AlexGuteniev
Copy link
Contributor Author

AlexGuteniev commented May 17, 2020

Repository: microsoft/STL
Workflow: Move new PRs to the New column in the Code Reviews Project
Duration: 17.0 seconds
Finished: 2020-05-17 07:57:41 UTC

Whoa, probably it wasn't the right moment

@AlexGuteniev
Copy link
Contributor Author

Still requires to handle generic atomic by a lock via contention table instead of internal lock.

@AlexGuteniev
Copy link
Contributor Author

So two main issues with this change is with mutex for bad size:

  • It is hard to eliminate data member without ABI-unsafe layout change and without [[no_unique_address]] (which we probably will not have soon). So embedded _Spinlock will probably stay for atomic_ref, but will not be used.
  • The mutexes for atomic_ref will have to reside in contention table, so apparently must go to a satellite DLL.

Due to the first issue it may make sense to make the best of the situation, and cache mutex reference in _Spinlock for atomic_ref. This will make (satellite) dll call only on construction, rather than on every operation.

Note that I'm assuming that embedded by value spinlock is not an option because independently constructed atomic_ref from the same object should be safe. Standard is not very clear on this though.

@AlexGuteniev AlexGuteniev marked this pull request as ready for review May 17, 2020 15:41
@AlexGuteniev AlexGuteniev requested a review from a team as a code owner May 17, 2020 15:41
@BillyONeal BillyONeal moved this from Work In Progress to Final Review in Code Reviews Aug 11, 2020
Copy link
Member

@StephanTLavavej StephanTLavavej left a comment

Choose a reason for hiding this comment

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

Looks good, very minor nitpicks.

stl/inc/yvals_core.h Outdated Show resolved Hide resolved
stl/src/atomic_wait.cpp Outdated Show resolved Hide resolved
stl/inc/atomic Show resolved Hide resolved
stl/inc/atomic Outdated Show resolved Hide resolved
stl/inc/atomic Outdated Show resolved Hide resolved
stl/inc/atomic Outdated Show resolved Hide resolved
stl/inc/atomic Outdated Show resolved Hide resolved
Code Reviews automation moved this from Final Review to Work In Progress Aug 12, 2020
AlexGuteniev and others added 3 commits August 12, 2020 11:54
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
@StephanTLavavej StephanTLavavej moved this from Work In Progress to Ready To Merge in Code Reviews Aug 12, 2020
@StephanTLavavej StephanTLavavej removed their assignment Aug 12, 2020
@BillyONeal
Copy link
Member

Thanks for contributing my favorite C++20 feature :D

@BillyONeal BillyONeal merged commit f3ca37d into microsoft:master Aug 13, 2020
Code Reviews automation moved this from Ready To Merge to Done Aug 13, 2020
@AlexGuteniev AlexGuteniev deleted the atomic_ref branch August 13, 2020 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cxx20 C++20 feature
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

P0019R8 atomic_ref
4 participants