digitalmars.D.bugs - [Issue 4957] New: std.concurrency does not allow to pass Tid in struct fields
- d-bugmail puremagic.com (40/40) Sep 29 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4957
- d-bugmail puremagic.com (67/67) May 12 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4957
- d-bugmail puremagic.com (11/11) May 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4957
- d-bugmail puremagic.com (10/10) Jul 14 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4957
http://d.puremagic.com/issues/show_bug.cgi?id=4957 Summary: std.concurrency does not allow to pass Tid in struct fields Product: D Version: D2 Platform: x86 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: osa8aso gmail.com send() allows to Tid only as a top-level parameter. Using Tid in a struct does not work. This compiles: ---- import std.concurrency; void main() { send( thisTid, thisTid ); receive( Tid ); } ---- This fails to compile: ---- import std.concurrency; struct Message { Tid tid; } void main() { send( thisTid, Message( thisTid ) ); receive( ( Message ) {} ); } --- std/concurrency.d(363): Error: static assert "Aliases to mutable thread-local data not allowed." c.d(4): instantiated from here: send!(Message) So Tid is not mutable when passed to send() directly, but as a part of struct Message, it suddenly becomes mutable? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 29 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4957 ratchet freak <ratchet.freak gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ratchet.freak gmail.com PDT --- I've found how it comes: std.concurrency defines the following testing template for sending parameters along //line 49 template hasLocalAliasing(T...) { static if( !T.length ) enum hasLocalAliasing = false; else enum hasLocalAliasing = (std.traits.hasLocalAliasing!(T[0]) && !is(T[0] == Tid)) || std.concurrency.hasLocalAliasing!(T[1 .. $]); } which handles Tid as a special case which doesn't happen when it's not top-level Tid itself is of the form: //lines 272 struct Tid { void send(T...)( T vals ) { static assert( !hasLocalAliasing!(T), "Aliases to mutable thread-local data not allowed." ); _send( this, vals ); } private: this( MessageBox m ) { mbox = m; } MessageBox mbox; } MessageBox here does not pass the test of !std.traits.hasLocalAliasing (it's a class object) quick fix: make mbox in Tid shared and cast accesses to it to thread local this allows Tid to pass the !std.traits.hasLocalAliasing test *as one would expect from it* struct Tid { void send(T...)( T vals ) { static assert( !hasLocalAliasing!(T), "Aliases to mutable thread-local data not allowed." ); _send( this, vals ); } private: this( MessageBox m ) { mbox = cast(shared)m; } shared MessageBox mbox; } //lines 419 private void _send(T...)( MsgType type, Tid tid, T vals ) { (cast(MessageBox)tid.mbox).put( Message( type, vals ) ); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 12 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4957 Sean Kelly <sean invisibleduck.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |sean invisibleduck.org --- Curses! Seems I'll have to apply 'shared' to private members of Tid. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 16 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4957 Johan Hernandez <thepumpkin1979 gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thepumpkin1979 gmail.com 03:06:04 PDT --- I ran into this issue too. We need a fix :( -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 14 2012