I had code that worked in 2.063 that crashes now (on Linux, on Windows it still works). I suspect I was doing something stupid and got lucky, but I'm posting here to make sure. Code:

import std.concurrency;

private void func() {
    auto done = false;

    while(!done) {
        receive(
            (OwnerTerminated trm) {
                done = true;
            }
        );
    }
}

void main() {
    spawn(&func);
}

Changing func like so stops the crashing (which I agree is better code anyway that I just shamelessly stole from TDPL):

private void func() {
    for(auto running = true; running;) {
        receive(
            (OwnerTerminated trm) {
                running = false
            }
        );
    }
}


So what's going on? I thought it maybe had to do with synchronisation but doing the write in a synchronized block changed nothing. Bug or me being stupid?

Atila



Reply via email to