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);
}