reddit discussion about Go turns to D again
Andrej Mitrovic
andrej.mitrovich at gmail.com
Mon May 16 11:26:39 PDT 2011
Could templates in std.algorithm be expanded to have an optional
thread-count compile-time argument? Maybe they'd be used like so:
import std.stdio;
import std.array;
import std.range;
import std.functional;
enum Threads
{
x1 = 1,
x2 = 2,
x3 = 3,
x4 = 4, // etc..
}
void main()
{
int[] data = [1, 2, 3];
count!("a < 0", Threads.x4)(data);
}
size_t count(alias pred = "true", alias th = Threads.x1, Range)(Range
r) if (isInputRange!(Range))
{
static if (th == Threads.x1)
{
// call normal count
}
else
{
// call parallel count
}
return -1;
}
More information about the Digitalmars-d
mailing list