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

may have fixed the race #3723

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

may have fixed the race #3723

wants to merge 3 commits into from

Conversation

sunmisc
Copy link

@sunmisc sunmisc commented Dec 20, 2024

If these objects are used inside Atomic, we can assume that they must be thread-safe.
You can't do a check/write, because during the check, the state may change and there will already be an object there. Using synchronization primitives such as:
Acquire/Release (volatile read/write) and CAS you can avoid this, only this way and no other way (or use a locking mechanism that is high level)

@yegor256
Copy link
Member

@sunmisc many thanks for the contribution! It looks reasonable. However, it would be great to have a unit test that confirms that our current implementation has a bug. Can you please add a test? Also, check this please: https://www.yegor256.com/2024/12/15/open-source-beginner-advice.html

@sunmisc sunmisc mentioned this pull request Jan 2, 2025
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.

2 participants