asynchronous tasks vs. multithreading with std::thread

Mar 31, 2016 at 4:37 PM
Edited Mar 31, 2016 at 4:41 PM
Hello,

this is a conceptual question on the asynchronous task feature (and maybe also a bit of a noob question).

In a basic application, I have a client and perform several requests, e.g. like
http_client client(U("whatever"));

for(int i=0; i<100; ++i)
{
    http_request request;
    //fill the request
    client.request(request).then([](http_response response) { /* do something*/});
}
(The foor-loop is just to indicate that the request is sent often, I don't really use it in my code).

Questions:
  • As far I understand, the asynchronous task library then handles those incoming requests in a parallel way -- meaning that not the main thread handles all tasks in an event-like fashion, but rather the library assigns the tasks to an underlying thread pool in some (--to me intransparent--) way. Did I get that correct?
-
  • If the previous view is correct, then is there any reason to combine the REST SDK with the multithreading capabilities of C++. For example, taking again the above loop, start 10 threads and in each one process 10 loop iterations. Does this makes sense or is it unnecessary?
-
  • Moreover, in general, are there any common patterns where one should combine the ppl-capabilities by the C++11 multithreading feature? Or is it safe to rely that the REST SDK and ppl under the hood get the job done better?
Thanks in advance,
David