http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51617

--- Comment #4 from Dave Abrahams <dave at boostpro dot com> 2011-12-19 
10:58:46 UTC ---
(In reply to comment #2)
> Yes, this was an intentional choice (as I described in message
> c++std-lib-30840) to ensure the system doesn't get killed by a fork bomb, e.g.
> writing a parallel sort algorithm using async which launches a new thread for
> every partition. I tried it, it wasn't pretty :)

Hey, cool; I tried it too.  I mean, when I discovered async wasn't async. :-)

> At some point I will use getloadavg() or equivalent functionality to check the
> system load and decide whether to launch a new thread or not, until then the
> safer choice is to require a user to explicitly request it (then it's the
> user's fault if they fork bomb their machine!)

Yeah, but in the meantime you could also just limit async() threads to
hardware_concurrency() using the technique shown in my attachment.  It wouldn't
necessarily guarantee good performance but it would be enough to prevent async
from fork bombing while still allowing some semi-intelligent amount of
parallelism.

Reply via email to