This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/51617] [C++0x] async(f) isn't.
- From: "dave at boostpro dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 19 Dec 2011 10:58:46 +0000
- Subject: [Bug libstdc++/51617] [C++0x] async(f) isn't.
- Auto-submitted: auto-generated
- References: <bug-51617-4@http.gcc.gnu.org/bugzilla/>
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.