On 5/15/2011 10:43 AM, Andrei Alexandrescu wrote:
Whoa. Did you skim the list at http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch31s03.html? A _ton_ of algorithms in std.algorithms are parallelizable, and many in trivial ways too.
(Smacks self on forehead.) Yeah, here's an (untested, quick and dirty) implementation of parallelCount().
size_t parallelCount(alias pred, R)(R range) { // Use the fact that bools are implicitly convertible to ints. return taskPool.reduce!"a + b"( cast(size_t) 0, std.algorithm.map!pred(range) ); }