Bug 13262 – Cannot send certain shared data to another thread

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-08-05T18:40:01Z
Last change time
2017-10-16T09:57:22Z
Assigned to
Steven Schveighoffer
Creator
Andrei Alexandrescu
See also
https://issues.dlang.org/show_bug.cgi?id=6585

Comments

Comment #0 by andrei — 2014-08-05T18:40:01Z
Consider: import std.concurrency; void fun(Tid tid, shared int[] a) { tid.send(a); } This doesn't compile due to an obscure memcpy type mismatch in std.variant. It should be legal to send pretty much any shared data across threads.
Comment #1 by andrei — 2014-08-06T17:32:25Z
The plot thickens - some types are oddly rejected. In the example below, adding an int to a struct "fixes" it! import std.concurrency; struct S1 { int c; string a; } struct S2 { string a; shared int[] b; } struct S3 { string a; shared int[] b; int c; } void fun(T)() { T object; thisTid.send(object); } void main(string[] args) { fun!int(); fun!(shared int); fun!S1; fun!(shared S1); fun!S2; fun!(shared S2); fun!S3; fun!(shared S3); }
Comment #2 by andrei — 2014-08-06T17:34:19Z
Comment #3 by schveiguy — 2017-08-16T14:59:17Z
*** Issue 14893 has been marked as a duplicate of this issue. ***
Comment #4 by schveiguy — 2017-08-16T15:22:16Z
Comment #5 by github-bugzilla — 2017-08-21T15:06:31Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/373babe48e186d2e9a54042bd35317c928b14bc3 fix issue 13262 - Ensure shared data can be sent and received via send/receive. Also now allows all types of shared items to be stored in a Variant. https://github.com/dlang/phobos/commit/e2a16ccd4d78ce7288d9abfb253bf64bc6638198 Merge pull request #5694 from schveiguy/fix13262 fix issue 13262 - Cannot send certain shared data to another thread
Comment #6 by schveiguy — 2017-08-22T18:04:38Z
*** Issue 6585 has been marked as a duplicate of this issue. ***
Comment #7 by github-bugzilla — 2017-10-16T09:57:22Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/373babe48e186d2e9a54042bd35317c928b14bc3 fix issue 13262 - Ensure shared data can be sent and received via https://github.com/dlang/phobos/commit/e2a16ccd4d78ce7288d9abfb253bf64bc6638198 Merge pull request #5694 from schveiguy/fix13262