std.concurrency : sending immutable classes

Dicebot public at dicebot.lv
Mon Nov 11 10:54:02 PST 2013


This prints nothing:

```
import std.concurrency;
import std.stdio;

class A
{
     string toString() immutable
     {
         return "aaa";
     }
}

void thread()
{
     for (;;)
     {
         receive(
             (immutable A x) {
                 writeln(x);
             },
             (Variant x) {
                 writeln(x.type);
                 writeln(x);
             }
         );
     }
}

void main()
{
     auto tid1 = spawn(&thread);
     auto val = new immutable A();
//    tid1.send(42);
     tid1.send(val);
     for (;;) {}
}

}
```

Any ideas? :)


More information about the Digitalmars-d-learn mailing list