Software Development
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>>();
newQueue.Enqueue(memoryDataForPointer);
return newQueue;
}, (x, queue) =>
{
queue.Enqueue(memoryDataForPointer);
return queue;
});
Into this code:
var q = _freeSegments.GetOrAdd(memoryDataForPointer.SizeInBytes,
size => new ConcurrentQueue<AllocatedMemoryData>());
q.Enqueue(memoryDataForPointer);
Can you tell me why?
| Reference: | Code review challenge – The concurrent dictionary refactoring from our NCG partner Oren Eini at the Ayende @ Rahien blog. |
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



