www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - concurrency send() error

reply "John Colvin" <john.loughran.colvin gmail.com> writes:
I was messing about with std.concurrency and ran in to this: 
http://dpaste.dzfl.pl/5655cbbe

copied out for those who don't want to go to dpaste:

import std.concurrency;
import std.stdio;

void main() {
     double[] a,b;
     a = [1.1];
     b = [2.2];
     int i= 3;

     auto tid = spawn(&foo);
	
     tid.send(a.idup, b.idup);    //works, no problem

     tid.send(a.idup, i);	 //so does this

     tid.send(a.idup, b.idup, i); //core.exception.AssertError  
std/variant.d(277): target must be non-null

}

void foo() {
     bool running  = true;
     while(running) {
      	receive(
	    (immutable(double)[] a, int i) {
		writeln(a, i);
	    },
	    (immutable(double)[] a, immutable(double)[] b, int i) {
		writeln(a, b, i);
	    },
	    (immutable(double)[] a, immutable(double)[] b) {
		writeln(a, b);
	    },
	    (OwnerTerminated e) {
		running = false;
	    }
	);
     }
}

This seems like a bug to me, but I don't know std.concurrency 
well enough to be sure.
Dec 07 2012
parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
12/7/2012 4:40 PM, John Colvin пишет:
 I was messing about with std.concurrency and ran in to this:
 http://dpaste.dzfl.pl/5655cbbe

 copied out for those who don't want to go to dpaste:
[snip]
 This seems like a bug to me, but I don't know std.concurrency well
 enough to be sure.
It looks like a bug and it smells like a bug. I'd say it's a bug :) Please go ahead and file it. -- Dmitry Olshansky
Dec 07 2012