www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8853] New: Unable to use std.concurrency.receive with Tuple!(immutable(int[]))

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8853

           Summary: Unable to use std.concurrency.receive with
                    Tuple!(immutable(int[]))
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: lomereiter gmail.com



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 19 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8853


Stephan <stephan.schiffels mac.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stephan.schiffels mac.com



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 21 2013