Home » Software Development » Code review challenge – The concurrent dictionary refactoring

About Oren Eini

Oren Eini

Code review challenge – The concurrent dictionary refactoring

In a recent code review, I had modified the following code:


_freeSegments.AddOrUpdate(memoryDataForPointer.SizeInBytes, x =>
   var newQueue = new ConcurrentQueue<AllocatedMemoryData>>();
   return newQueue;
}, (x, queue) =>
   return queue;

Into this code:

var q = _freeSegments.GetOrAdd(memoryDataForPointer.SizeInBytes, 
                         size => new ConcurrentQueue<AllocatedMemoryData>());

Can you tell me why?

(0 rating, 0 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a sysadmin Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. Introduction to NGINX
2. Apache HTTP Server Cookbook
3. VirtualBox Essentials
4. Nagios Monitoring Cookbook
5. Linux BASH Programming Cookbook
6. Postgresql Database Tutorial
and many more ....
I agree to the Terms and Privacy Policy
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments