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 lock to scoped burdens to ensure only one instance is created per scope #547

Merged
merged 8 commits into from
Sep 15, 2020

Conversation

generik0
Copy link
Contributor

@generik0 generik0 commented Sep 8, 2020

Add lock to scoped burdens to ensure only one instance is created per scope

#533

@generik0
Copy link
Contributor Author

generik0 commented Sep 8, 2020

@jonorossi can you add netfore3 and 3.1 to the appveyor? Then the tests can run in all frameworks

@generik0
Copy link
Contributor Author

generik0 commented Sep 8, 2020

@AntonioDrusin can you review. it was the scopeCache that needed the lock. Hence we only sync for each scope. less performance hit, and more SOLID as scopeCache is an instance, not a static..

lock (scopeCache)
			{
				var burden = scopeCache[model];
				if (burden == null)
				{
					scopeCache[model] = burden = createInstance((_) => {});
				}
				return burden;	
			}

@AntonioDrusin
Copy link
Contributor

The lock code looks correct. I tested with @mdavis test project and with my own. The resolvers now behave as expected.

@generik0
Copy link
Contributor Author

@jonorossi improved nestling and improved naming of variables for readability

@generik0
Copy link
Contributor Author

@jonorossi did i get all the review comments ok? If so, can we get this into master and a new build for people?

@jonorossi jonorossi merged commit d3c18a0 into castleproject:master Sep 15, 2020
@jonorossi
Copy link
Member

@generik0 yep, all good. Merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants