Parallel Extension
RTM version of .NET 4 and Visual Studio 2010 is available, and now we can do some test with it. Parallel Extensions is one of the most valuable part of .NET 4.0. It’s a set of good tools for easily consuming multicore hardware power. And it also contains some “upgraded” sync primitives – Slim-version. For example, it include updated variant of widely known ManualResetEvent. For people, who don’t know about it: you can sync concurrency execution of some pieces of code with this sync primitive. Instance...
Today I tell you about BlockingCollection<T>. It’s more complex and more interesting data storage. BlockingCollection<T> is a thread-safe data structure, which is called “blocking”, because it based on following principles: if the collection is empty, and some code try to take an element, the thread, that executes this code, is blocked while any at least one element is not added; if the collection already contains maximum elements, the thread, attempting to add new element, will be blocked...
.NET 4 contains rich set of tools, that allow to create parallelized code more easy. But when we start processing chunk of data in parallel threads, we need to synchronize these threads, and we need some storage for the results of work. Now exist a big number of methods, solving sync issues, and we can realize in code any of them. But MS Parallel Extensions team already do it, and .NET 4 beta versions include set of thread-safe data structures. They implement some popular types of collections, and...