Bug 8853 – Unable to use std.concurrency.receive with Tuple!(immutable(int[]))
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2012-10-19T11:01:09Z
Last change time
2019-11-14T13:31:46Z
Assigned to
No Owner
Creator
Artem Tarasov
Comments
Comment #0 by lomereiter — 2012-10-19T11:01:09Z
The following code compiles, but the program hangs (because the message is not received by foo()). Without wrapping array into struct everything works. If immutable(int[]) is changed to immutable(int)[] -- also works.
import std.concurrency;
struct A {
immutable(int[]) a;
}
void foo(Tid tid) {
receive(
(A a) {
send(tid, true);
});
}
void main() {
Tid tid = spawn(&foo, thisTid);
immutable(int[]) a = [1];
send(tid, A(a));
receiveOnly!bool();
}
Comment #1 by stephan.schiffels — 2013-01-21T10:01:24Z
I would like to add my own program to this issue, which also hangs, most likely due to the same reason. If you remove ANY of the three members of the struct (and edit the message accordingly), the program passes normally. Only with all three struct members, it hangs:
import std.stdio;
import std.concurrency;
struct message_t {
string str;
int num;
immutable(int)[] vec;
}
void func(Tid caller) {
auto msg = message_t("foo", 42, [1, 2, 3]);
caller.send(msg);
}
void main() {
spawn(&func, thisTid);
auto msg = receiveOnly!(message_t);
writeln("received: ", msg);
}