std.concurrency : sending immutable classes
Dicebot
public at dicebot.lv
Mon Nov 11 15:28:27 PST 2013
Updated case after some experiments:
```
import std.concurrency;
import std.stdio;
class A
{
override string toString() const // this was an issue, it
must be exact override
{
return "aaa";
}
}
void thread()
{
for (;;)
{
receive(
/* (immutable(A) x) {
writeln("what");
}, */
(Variant x) {
writeln(x.type);
writeln(x);
}
);
}
}
void main()
{
auto tid1 = spawn(&thread);
auto val = new immutable A();
tid1.send(val);
for (;;) {}
}
```
This prints expected:
```
immutable(test.A)
aaa
```
However, uncommenting `immutable(A)` receiver makes it silent
again.
More information about the Digitalmars-d-learn
mailing list