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

Some is_locked checks are unnecessary #5

Open
skoppe opened this issue Jan 18, 2021 · 0 comments
Open

Some is_locked checks are unnecessary #5

skoppe opened this issue Jan 18, 2021 · 0 comments

Comments

@skoppe
Copy link
Collaborator

skoppe commented Jan 18, 2021

Due to a small semantic change in porting the C++ code over to D we are calling is_locked more than we need to.

D didn't have compare_exchange_weak so I used casWeak. The difference is that compare_exchange_weak also loads the value if the compare fails, whereas casWeak only compares and doesn't load the value.

That means that these checks

while (is_locked(oldState)) {

while (is_locked(oldState)) {

could be skipped (they are always false) AFTER the casWeak in the outer while failed.

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

No branches or pull requests

1 participant