sending shared pointer to struct. message type mismatch

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 21 10:29:42 PDT 2016


On 4/21/16 1:10 PM, jacob wrote:
> import std.stdio;
> import std.concurrency;
>
> shared struct S(T, uint M)
> {
>      T[M] x;
> }
>
> shared struct M
> {
>      int x;
> }
>
>
> private void runner(T)()
> {
>      shared(T*) s = receiveOnly!(shared(T*))();
>      writeln(s.x.length);
>      writeln(s.x[0]);
>      send(thisTid, true);
> }
>
> int main(string[] argv)
> {
>      alias S!(M, 2) TS;
>      alias shared(TS*) PS;
>
>      Tid runnerTid = spawn(&runner!(TS));
>
>      auto s = new shared(TS);
>      s.x[0] = M(42);
>      send(runnerTid, s);
>
>      bool ok = receiveOnly!bool();
>
>      return 0;
> }

I get strange behavior. Not an error/exception, but basically hung 
process. I tried modifying different things, and passing other types of 
messages. Seems almost like the call to send is ignored for sending the 
s message.

Tried various things, but receiveOnly appears broken for me. I've sent 
messages that should cause an exception and it just hangs.

-Steve


More information about the Digitalmars-d-learn mailing list