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

Add GetOrBuild on the session factory factory #3668

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fredericDelaporte
Copy link
Member

fix #3657

@fredericDelaporte fredericDelaporte added this to the 5.6 milestone Apr 6, 2025
@fredericDelaporte fredericDelaporte force-pushed the fixes/sess-fact-fact-thr-gh3657 branch from 1015c2a to d36824c Compare April 6, 2025 15:20
/// built, which may lead to threading issues.</para>
/// </remarks>
[MethodImpl(MethodImplOptions.Synchronized)]
public static ISessionFactory GetOrBuildNamedInstance(string name, Func<ISessionFactory> instanceBuilder)
Copy link
Member Author

Choose a reason for hiding this comment

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

To allow threadsafe use of the factory, a get or build is needed. Some applications do use it in a multi-thread context. They were always exposed to threading bugs due to the get being able of yielding a not yet fully built instance in such case, but this was worsen by #2190. With this GetOrBuild, provided the application only build factories through it, fully built instances will be yielded.

@fredericDelaporte fredericDelaporte changed the title Add GetOrAdd on the session factory factory Add GetOrBuild on the session factory factory Apr 6, 2025
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.

SessionFactoryObjectFactory Early Cache Population Causes Threading Issue
1 participant