D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5538 - Immutable classes can't be passed as messages in std.concurrency
Summary: Immutable classes can't be passed as messages in std.concurrency
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-07 11:37 UTC by Tomasz Sowiński
Modified: 2016-08-05 13:17 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Tomasz Sowiński 2011-02-07 11:37:04 UTC
Test case:

class C {}
thisTid.send(new immutable(C)());
receive((immutable C) { writeln("got it!"); });

This throws: core.exception.AssertError@/usr/include/d/dmd/phobos/std/variant.d(285): immutable(C)

And when I replace immutable(C) with Rebindable, I get "Aliases to mutable thread-local data not allowed.".
Comment 1 David Simcha 2011-04-12 17:41:07 UTC
https://github.com/D-Programming-Language/phobos/commit/325a8fe64a15c57dcde3f8326ad35cfd638f86c7

Fixed the Rebindable part.  Hopefully the Variant part will be fixed with Rob Jacques's upcoming Variant update.
Comment 2 Shammah Chancellor 2013-11-25 04:17:37 UTC
Ping.   This is a really important issue for multithreaded D.  Seems like after 2 years this should be able to be patched.
Comment 3 Kapps 2014-05-29 01:15:17 UTC
Looks like this works on DMD head.

Updated sample (added name for parameter to allow compiling and wrapped in main):

import std.variant, std.concurrency;

class C {}

void main() {
        thisTid.send(new immutable(C)());
        receive((immutable C c) { writeln("got it!"); });
}

DMD 2.065.0:
rdmd test.d
core.exception.AssertError@/opt/dmd/phobos/std/variant.d(288): immutable(C)

DMD Git Head:
rdmd test.d
got it!