Skip to content

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

Merged
axel22 merged 1 commit into
concurrent-programming-in-scala:masterfrom
nox213:master
Nov 13, 2023
Merged

axel22 merged 1 commit into
concurrent-programming-in-scala:masterfrom
nox213:master

Conversation

@nox213

@nox213 nox213 commented Nov 13, 2023 •

Copy link
Copy Markdown

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

axel22 commented Nov 13, 2023

Copy link
Copy Markdown
Member

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