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(SimpleResolver): Function loadOrResolve should be atomically performed #11

Closed
wants to merge 2 commits into from

Conversation

adrien-coye
Copy link
Contributor

@adrien-coye adrien-coye commented Mar 18, 2025

Abstract

func loadOrResolve() can be called from any arbitrary thread, and can recursively be called within a factory to resolve other types.

The current implementation does allow for re-entry but can break under the right conditions.
Eg. Two objects 1 and 2 within a factory resolve the same root object A, we can end up with multiple calls to the A factory and have A and A-2 in memory

This PR aims at making sure loadOrResolve() is performed in a single queue.sync call while correctly handling the re-entry issue by not context switching to the internal serial queue if already on it.

@adrien-coye adrien-coye force-pushed the fix/race-condition-in-loadOrResolve branch from bb41451 to 83b9b96 Compare March 18, 2025 15:09
@adrien-coye
Copy link
Contributor Author

This was an exploration of a potential bugfix, now superseded by a refactor branch #12

@adrien-coye adrien-coye deleted the fix/race-condition-in-loadOrResolve branch March 19, 2025 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant