Parallel Extensions
Parallel Extensions was the development name for a
Parallel LINQ
PLINQ, or Parallel LINQ, parallelizing the execution of queries on objects (LINQ to Objects) and XML data (LINQ to XML). PLINQ is intended for exposing data parallelism by use of queries.[2] Any computation on objects that has been implemented as queries can be parallelized by PLINQ. However, the objects need to implement the IParallelEnumerable
interface, which is defined by PLINQ itself. Internally it uses TPL for execution.[4][5]
Task Parallel Library
The Task Parallel Library (TPL) is the task parallelism component of the Parallel Extensions to .NET.[6] It exposes parallel constructs like parallel For
and ForEach
loops, using regular method calls and delegates, thus the constructs can be used from any CLI languages. The job of spawning and terminating threads, as well as scaling the number of threads according to the number of available processors, is done by the library itself,[3] using a work stealing scheduler.[7]
TPL also includes other constructs like Task and
Future is a task that returns a result. The result is computed in a background thread encapsulated by the Future object, and the result is buffered until it is retrieved.[3] If an attempt is made to retrieve the result before it has been computed then the requesting thread will block until the result is available.[6]
The other construct of TPL is Parallel class. TPL provides a basic form of structured parallelism via three static methods in the Parallel class:
- Parallel.Invoke
- Executes an array of Action delegates in parallel, and then waits for them to complete
- Parallel.For
- Parallel equivalent of a C# for loop
- Parallel.ForEach
- Parallel equivalent of a C# foreach loop
Architecture
The main concept in the Parallel Extensions to .NET is a Task
, which is a small unit of code, usually represented as a
Parallel.For
, Parallel.ForEach
and Parallel.Invoke
methods divide a loop into Tasks.
PFX includes a Task Manager
object which schedules the Tasks for execution. A Task Manager contains a global
See also
- Concurrency and Coordination Runtime
- Joins
- Cilk Plus– comparable technology for C and C++
- Mac OS X 10.6 developed by Apple.
- JSR 166).
- Threading Building Blocks (TBB) – comparable technology for C++ available for many systems created originally by Intel (also open source)
- Thread pool pattern
- Task parallelism
- ReactiveX (Reactive Extensions)
References
- ^ "What's New in the .NET Framework 4". Retrieved 21 September 2011.
- ^ a b "Programming in the Age of Concurrency: Concurrent Programming with PFX". Retrieved 16 October 2007.
- ^ a b c "MSDN Magazine: Task Parallel Library". Archived from the original on 14 October 2007. Retrieved 16 October 2007.
- ^ a b "June 2008 CTP – Parallel Extensions to the .NET FX". Retrieved 6 August 2008.
- ^ "More powerful aggregations in PLINQ". Retrieved 6 August 2008.
- ^ ISBN 978-0321434821.
- .