Terminology question: Why is Parallel part of TPL?How do we explain to people why the Parallel class considered part of the <em>Task </em> Parallel Library?<br/> http://msdn.microsoft.com/en-us/library/dd460693(VS.100).aspx<br/> <br/> It doesn't appear to have anything to do with tasks.<br/> <br/> In fact, the Parallel class is much closer to PLINQ than the Task class in its model: the Parallel class and PLINQ both offer <em>structured data parallelism</em> . I would consider the two sit side-by-side, with the Task class (and Task's associated classes) underneath.<br/> <br/> Intuitively, the types in <strong>System.Threading.Tasks</strong> would seem to constitute the Task Parallel Library:<br/> <br/> Task<br/> Task&lt;TResult&gt;<br/> TaskFactory<br/> TaskFactory&lt;TResult&gt;<br/> TaskScheduler<br/> TaskCompletionSource<br/> <br/> and nothing else.<br/> <br/> Unless it's the Task <strong>/</strong> Parallel Library :)<br/> <br/> Joe<br/> <hr class=sig> Write LINQ queries interactively - www.linqpad.net© 2009 Microsoft Corporation. All rights reserved.Sat, 04 Jul 2009 00:44:45 Z188771ff-7090-4956-ae87-a47118ba94eahttp://social.msdn.microsoft.com/Forums/en-US/parallelextensions/thread/188771ff-7090-4956-ae87-a47118ba94ea#188771ff-7090-4956-ae87-a47118ba94eahttp://social.msdn.microsoft.com/Forums/en-US/parallelextensions/thread/188771ff-7090-4956-ae87-a47118ba94ea#188771ff-7090-4956-ae87-a47118ba94eaJoe Albaharihttp://social.msdn.microsoft.com/Profile/en-US/?user=Joe%20AlbahariTerminology question: Why is Parallel part of TPL?How do we explain to people why the Parallel class considered part of the <em>Task </em> Parallel Library?<br/> http://msdn.microsoft.com/en-us/library/dd460693(VS.100).aspx<br/> <br/> It doesn't appear to have anything to do with tasks.<br/> <br/> In fact, the Parallel class is much closer to PLINQ than the Task class in its model: the Parallel class and PLINQ both offer <em>structured data parallelism</em> . I would consider the two sit side-by-side, with the Task class (and Task's associated classes) underneath.<br/> <br/> Intuitively, the types in <strong>System.Threading.Tasks</strong> would seem to constitute the Task Parallel Library:<br/> <br/> Task<br/> Task&lt;TResult&gt;<br/> TaskFactory<br/> TaskFactory&lt;TResult&gt;<br/> TaskScheduler<br/> TaskCompletionSource<br/> <br/> and nothing else.<br/> <br/> Unless it's the Task <strong>/</strong> Parallel Library :)<br/> <br/> Joe<br/> <hr class=sig> Write LINQ queries interactively - www.linqpad.netFri, 03 Jul 2009 14:25:05 Z2009-07-03T14:39:33Zhttp://social.msdn.microsoft.com/Forums/en-US/parallelextensions/thread/188771ff-7090-4956-ae87-a47118ba94ea#3b98b7ca-203f-4b1e-8738-e861a410ad6bhttp://social.msdn.microsoft.com/Forums/en-US/parallelextensions/thread/188771ff-7090-4956-ae87-a47118ba94ea#3b98b7ca-203f-4b1e-8738-e861a410ad6bStephen Toub - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Stephen%20Toub%20-%20MSFTTerminology question: Why is Parallel part of TPL?<p>re: &quot;How do we explain to people why the Parallel class is considered part of the Task Parallel Library&quot;<br/><br/>That's largely how it evolved.  At this point, both Parallel and Task (and the types that support both) are core components of the .NET Framework, and from that perspective the &quot;Task Parallel Library&quot; moniker is just a nice way of grouping some new technologies for explanatory purposes, but isn't necessary for any technical reason.<br/><br/>re: &quot;It doesn't appear to have anything to do with tasks&quot;<br/><br/>Parallel does use tasks extensively under the covers, evidenced by the fact that ParallelOptions accepts a TaskScheduler that can be used to target the Parallel.* operations' tasks to run on a particular scheduler (by default they run on TaskScheduler.Default as you'd expect).  In effect, the methods on Parallel are very sophisticated task generators, and they're very closely intertwined from an implementation perspective, much more so than is PLINQ (at least in the current implementation).<br/><br/>Additionally, consider a method like Parallel.Invoke.  If you want to perform multiple operations in parallel, it's likely the first place you start.  If you then determine you need more control than Parallel.Invoke provides, you can replace it with starting on multiple tasks and waiting on all of them.  From there you can do more sophisticated things.  In that sense, Parallel.Invoke sits on the same spectrum as Tasks, in terms of productivity vs control/power.<br/><br/>re: &quot;the Parallel class and PLINQ both offer <em>structured data parallelism</em>&quot;<br/><br/>The line between what is data parallelism and what is task parallelism can get a bit blurry. Parallel.Invoke isn't really about data parallelism.  Certainly Parallel.ForEach would seem to fall squarely into the data parallel camp, but then again, you could use Parallel.ForEach to iterate in parallel through a set of arbitrary delegates, invoking each (which is similar in concept to what Parallel.Invoke will do under the covers in some situations), in which case it's less about data and more about executing arbitrary tasks in parallel.<br/><br/>re: &quot;Unless it's the Task <strong>/</strong> Parallel Library :)&quot;<br/><br/>Sure, that works, too ;)<br/><br/>I personally use the TPL terminology as an easy mechanism to refer to set a of technologies that are being shipped in .NET 4, but I wouldn't get hung up on that.  In the long term, I'd honestly expect that terminology to drop away, leaving behind what's actually important: the technology and what it can be used to accomplish.</p>Fri, 03 Jul 2009 19:57:03 Z2009-07-03T19:57:03Z