www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - structs, tids, and concurrency.

reply "Nathan M. Swan" <nathanmswan gmail.com> writes:
Nesting a Tid in a struct is interpreted as having local 
aliasing, though a bare Tid is not.

This doesn't work, though commenting out "receiveOnly!S()" and 
"tid.send(S(thisTid))" works:
-----
import std.stdio;
import std.concurrency;

void main() {
     auto thread = spawn(function void(Tid tid)
                         {
                             tid.send(thisTid);
                             tid.send(S(thisTid));
                         }, thisTid);
     receiveOnly!Tid();
     receiveOnly!S();
}

struct S {
     Tid tid;
}
-----

$ rdmd test.d
/usr/share/dmd/src/phobos/std/concurrency.d(319): Error: static 
assert  "Aliases to mutable thread-local data not allowed."
../test.d(9):        instantiated from here: send!(S)
Failed: dmd  -v -o- '../test.d' -I'..' >../test.d.deps
Mar 30 2012
parent Timon Gehr <timon.gehr gmx.ch> writes:
On 03/30/2012 10:18 AM, Nathan M. Swan wrote:
 Nesting a Tid in a struct is interpreted as having local aliasing,
 though a bare Tid is not.

http://d.puremagic.com/issues/show_bug.cgi?id=4957
Mar 30 2012