C++ – Would Task-based programming in C++ require new language standard features

cc++11concurrencymulti-coremultithreading

So I saw this video on Youtube with all these C++ masters on GoingNative 2012 : Interactive panel where everybody could ask the questions.

This is the video I was talking about: GoingNative 2012 – Day 1 – Interactive Panel: The importance of being native

And at time 0:24:00 someone put a very interesting question:

We've been doing concurrent programming for some time using pthreads,
using windows threads, and so on and I'm so happy that C++ and C
caught up with concurrent programming, but it seems to me like it's
already behind by five years or ten years because right now we have we
have all these powerful multicores and the programming of these
multicores really should not be based on threads, it should be
task-based […] and Microsoft has the PPL library and so on and
this is totally not reflecting in the C++ standard. […] The only
thing I'm afraid of is that the standard could be locked into threads
and sort of make it very difficult to move to Task-Based
Programming

Now I'm quite new to these concepts and I'm a little confused. What is actually Task-Based Programming. Does this term refer to the same thing that Lock-Free Programming refers to? Are these two equivalent terms or are there any links between them?

Best Answer

Microsoft has the "Task Parallel Library," or TPL.

It's a higher-level abstraction over threads, and it's library-based, so I see no reason why something similar could not be built in C++, since the TPL is already thread-based, and it doesn't depend on special features in the language standard for its implementation (although the keywords async and await were added to the C# compiler to make such programming easier).

A Task in the Microsoft ecostructure is more or less equivalent to a Future or a Promise. Basically, it's a non-blocking (asynchronous) function; you call it, it returns control back to you while it executes on a new thread, and then you retrieve the return value at some later time when it becomes available.

The TPL has other facilities like Parallel.For, which allows you to process a loop concurrently, using multiple threads. All of these things could be implemented in C++ as library functions. In fact, such a library has already been written.

As far as I know, the PPL (Parallel Patterns Library for Microsoft C++) doesn't depend on any special language features.