Problems with receive
Bob Cowdery
bob at bobcowdery.plus.com
Sun Aug 29 10:45:06 PDT 2010
Hi
I'm trying out some very simple concurrency tests to make sure I
understand how it operates. However I'm having a few problems. I'm sure
this is just lack of knowledge. I dont know enough to debug these things
on my own yet.
Bob
The test below builds but does not output anything so I assume for some
reason the pattern matching is not working. If I uncomment the line
adding a variant pattern it gives me a compile error.
Error: static assert "function with arguments (VariantN!(maxSize))
occludes successive function"
But there is no successive function, its the last statement.
Also I tried using a function address instead of a literal but that
gives me a compile error:
Error: static assert (false || false) is false
>From the code it looks its saying that myfunc is not a function.
import std.concurrency, std.stdio, std.variant;
int main(char[][] args)
{
auto low = 0, high = 100;
auto tid = spawn(&tfun);
foreach(i;low .. high) {
tid.send(thisTid,i);
}
writeln("Exiting");
return 0;
}
void myfunc(double x) {
writeln("Got : ", x);
}
void tfun() {
receive(
//&myfunc,
(int x) {writeln("Got : ", x);}//,
//(Variant any) {writeln("Got : ", any);}
);
};
More information about the Digitalmars-d-learn
mailing list