c++ - C++11 async - is management of optimal number of threads automatic? -
if have task spawns, say, 10,000 async threads using c++11 async<> / futures. async automatically manage number of concurrent threads?
specifically, if have 8 core machine, program spawn 10,000 thread or smart enough queue them batches of 8 (or whatever ideal machine)?
this quality of implementation issue, not mandated standard.
however if subset of threads block, remaining threads must advance. cannot 'run 8, wait them finish, start next 8'. monitor threads blocking and/or synchronized communication, , lacking not lauch new threads. if block or read/write in thread safe manner, keeping other threads suspended (or not started) indefinitely not (i think) legal, , bad idea.
Comments
Post a Comment