Geeks With Blogs
Simon Cooper Peering into the depths of .NET Inside the Concurrent Collections
Inside the Concurrent Collections: ConcurrentBag
Unlike the other concurrent collections, ConcurrentBag does not really have a non-concurrent analogy. As stated in the MSDN documentation, ConcurrentBag is optimised for the situation where the same thread is both producing and consuming items from the collection. We'll see how this is the case as we take a closer look. Again, I recommend you have ConcurrentBag open in a decompiler for reference. Thread Statics ConcurrentBag makes heavy use of thread statics - static variables marked with ThreadStaticAttribute. ......

Posted On Monday, March 26, 2012 4:42 PM

Inside the Concurrent Collections: ConcurrentDictionary
Using locks to implement a thread-safe collection is rather like using a sledgehammer - unsubtle, easy to understand, and tends to make any other tool redundant. Unlike the previous two collections I looked at, ConcurrentStack and ConcurrentQueue, ConcurrentDictionary uses locks quite heavily. However, it is careful to wield locks only where necessary to ensure that concurrency is maximised. This will, by necessity, be a higher-level look than my other posts in this series, as there is quite a lot ......

Posted On Wednesday, February 22, 2012 6:47 PM

Inside the Concurrent Collections: ConcurrentQueue
ConcurrentQueue is, like ConcurrentStack, a lockless collection, in that it is implemented without using any locks at all. However, the semantics required for a queue impose a quite different approach; unlike ConcurrentStack, which has a single point of concurrent contention, a queue can be changed at both the head and tail. This means that at least two variables are involved, most likely more. The simple approach of atomically modifying a single variable won't work here. What does System.Collections.Generic.... ......

Posted On Tuesday, January 24, 2012 10:14 PM

Inside the Concurrent Collections: ConcurrentStack
The first concurrent collection we'll look at is ConcurrentStack. This is conceptually the same as System.Collections.Generic.... but is geared towards occasional concurrent modifications. Now, in these posts I won't be looking to explain what every method does; just like my other explorations of various collection types, I'll be concentrating on the core implementation and concepts used by the collections, and glossing over the more sordid implementation details and scaffolding required to support ......

Posted On Thursday, January 12, 2012 1:56 PM

Inside the Concurrent Collections
The concurrent collections, located in the System.Collections.Concurrent namespace, were introduced in .NET 4 as thread-safe collections that could be used without locking, and there are plenty of posts and articles out on the interwebs giving an overview of the collections and how to use them. Instead, I'll be focusing these posts on how the concurrent collections are implemented; how they achieve thread-safety and the principles behind their implementation. Not only because I find that sort of ......

Posted On Thursday, January 5, 2012 2:43 PM

Copyright © simonc | Powered by: | Join free