Skip to content

Fix index initialization and loop termination condition of LockFreePool's remove method #44

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

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

nox213
Copy link
Contributor

@nox213 nox213 commented Nov 13, 2023

Hi, I'm reading your book these days (thanks for your interesting book) , and I ran into the error below while I was running LockFreePool example.
image

I think the reason is because the existing implementation incorrectly terminates the loop without checking the bucket at the starting index (start). So, I fixed it by modifying the loop to do-while from while and initializing i with start instead of (start + 1) % buckets.length. It will ensure that the bucket at the starting index is also considered during the scan.

@axel22
Copy link
Member

axel22 commented Nov 13, 2023

Yes, from looking at the code, that looks like a correct analysis and the right fix as far as I can see. Thank you for the patch!

@axel22 axel22 merged commit 95f2b12 into concurrent-programming-in-scala:master Nov 13, 2023
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