// I am learning how to send and receive data. The following is my intention, but it cannot be compiled. // aliases to mutable thread-local data not allowed, what does it mean? thank you.

I am learning how to send and receive. The following is my intention, but it cannot be compiled. Report
import std.concurrency;
import std.stdio;
import std.exception;

void main(){

        int N=5;
        int[] arr1= new int[N];
        for(int i; i<N; i++){ arr1[i]=i;}
        writeln("Main thread, msg= ", arr1);
        auto j=spawn(&fun);
        j.send(thisTid, arr1);   //error!
        enforce(receiveOnly!Tid() == j);

}

void fun(){

        auto msg5= receiveOnly!(Tid, int[])();
        writeln("child thread, msg= ", msg5[1]);
        msg5[0].send(thisTid);
}

Reply via email to