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

Fix Hotswap#get being blocked by Hotswap#swap #3800

Merged
merged 11 commits into from
Sep 18, 2023

Conversation

forkedcancel
Copy link
Contributor

Hotswap#swap currently acquires all permits for its Semaphore during allocation of the next Resource, blocking Hotswap#get until the new Resource has been instantiated. In many use cases this will not be perceptible but if the Resource has a long initialization time, any calls to get will block until the new Resource is ready... effectively undermining the very premise of Hotswap.

…ther than the entire lock and swapFinalizer call
Copy link
Member

@armanbilge armanbilge left a comment

Choose a reason for hiding this comment

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

Can we add another test that swap is cancelable if while waiting for a get to release the old resource and also that the finalizer is run in this case?

Copy link
Member

@armanbilge armanbilge left a comment

Choose a reason for hiding this comment

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

Tests are looking good, sorry just some style nits 😅

@armanbilge armanbilge changed the title Fix Hotswap.get being blocked by Hotswap.swap Fix Hotswap#get being blocked by Hotswap#swap Sep 14, 2023
armanbilge
armanbilge previously approved these changes Sep 14, 2023
Copy link
Member

@armanbilge armanbilge left a comment

Choose a reason for hiding this comment

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

Nice catch and excellent work!

@forkedcancel
Copy link
Contributor Author

Nice catch and excellent work!

Thanks! Didn't want this PR to get lost to the sands of time. Thank you for those tweaks! That use of .mapK was enlightening to me.

durban
durban previously approved these changes Sep 18, 2023
Copy link
Contributor

@durban durban left a comment

Choose a reason for hiding this comment

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

LGTM. I've left a comment, but it's really not that important.

Co-authored-by: Daniel Urban <urban.dani@gmail.com>
@forkedcancel forkedcancel dismissed stale reviews from durban and armanbilge via 854e2b8 September 18, 2023 16:28
@armanbilge armanbilge merged commit 94a9059 into typelevel:series/3.5.x Sep 18, 2023
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants