On Monday, 11 November 2013 at 18:54:04 UTC, Dicebot wrote:
Any ideas? :)

This is one way:

import std.concurrency;
import std.stdio;

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

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

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

I must admit the concurrency confuses me and i need to play with it more. :)

Reply via email to