www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to call receiveTimout? (std.concurrency)

reply Heywood Floyd <soul8o8 gmail.com> writes:
Hello and Good morning!



I'm trying to use receiveTimeout:

// 
	import 	std.stdio,
			std.concurrency;
	int main(string[] args){
		receiveTimeout(  1000L, (int i){writefln("Received: %d",i);}    ) ;
		return 0;
	}
// 

(I removed all the surrounding code above that spawned threads etc.)

Compiler gives me:
	/Library/Compilers/dmd2/osx/bin/../../src/phobos/std/concurrency.d(335):
Error: mismatched
tuple lengths, 2 and 1


I can't see what's wrong? Help!


A look in concurrency.d shows:
// - - 8< - -

	bool receiveTimeout(T...)( long ms, T ops )
	{
	    static enum long TICKS_PER_MILLI = 10_000;
	    return mbox.get( ms * TICKS_PER_MILLI, ops );
	}

// - - 8< - -

       final void get(T...)( T ops )
       {
           static assert( T.length );

           static if( isImplicitlyConvertible!(T[0], long) )
           {
               alias TypeTuple!(T[1 .. $]) Ops;
               assert( ops[0] >= 0 );
               long period = ops[0];
               ops = ops[1 .. $];  // <=== line 335
           }

// - - 8< - -




(DMD v2.047, OSX 10.6.4)

BR
/soul

PS. Sorry if this is a dupe. Mailman doesn't seem to like my emails? Sending
this via the web-
interface..
Jun 29 2010
next sibling parent "Simen kjaeraas" <simen.kjaras gmail.com> writes:
Heywood Floyd <soul8o8 gmail.com> wrote:

 ops = ops[1 .. $];  // <=== line 335

Well, this looks like a bug to me. Should be Ops = ops[1 .. $]; -- Simen
Jun 29 2010
prev sibling next sibling parent "Simen kjaeraas" <simen.kjaras gmail.com> writes:
Simen kjaeraas <simen.kjaras gmail.com> wrote:

 Heywood Floyd <soul8o8 gmail.com> wrote:

 ops = ops[1 .. $];  // <=== line 335

Well, this looks like a bug to me. Should be Ops = ops[1 .. $];

Oh, and you could probably make this change yourself. -- Simen
Jun 29 2010
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 29 Jun 2010 09:53:25 -0400, Simen kjaeraas  
<simen.kjaras gmail.com> wrote:

 Heywood Floyd <soul8o8 gmail.com> wrote:

 ops = ops[1 .. $];  // <=== line 335

Well, this looks like a bug to me. Should be Ops = ops[1 .. $];

Ops is a type, isn't it? Don't you need a variable there? I agree it's a bug in the original, but I don't think that's the fix. -Steve
Jun 29 2010
prev sibling next sibling parent Heywood Floyd <soul8o8 gmail.com> writes:
Ok, thanks!

How does the chain of command/responsibility work here?
Should I file this to bugzilla?

(I'm not able to fix it myself as I haven't built dmd locally. I'm just =
not quite there yet... : )
/heywood



On Jun 29, 2010, at 16:31 , Steven Schveighoffer wrote:

 On Tue, 29 Jun 2010 09:53:25 -0400, Simen kjaeraas =

=20
 Heywood Floyd <soul8o8 gmail.com> wrote:
=20
 ops =3D ops[1 .. $];  // <=3D=3D=3D line 335

Well, this looks like a bug to me. Should be =20 Ops =3D ops[1 .. $]; =20

Ops is a type, isn't it? Don't you need a variable there? =20 I agree it's a bug in the original, but I don't think that's the fix. =20 -Steve

Jun 29 2010
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 29 Jun 2010 13:05:50 -0400, Heywood Floyd <soul8o8 gmail.com>  
wrote:

 Ok, thanks!

 How does the chain of command/responsibility work here?
 Should I file this to bugzilla?

 (I'm not able to fix it myself as I haven't built dmd locally. I'm just  
 not quite there yet... : )
 /heywood

Simen actually already filed it. See here: http://d.puremagic.com/issues/show_bug.cgi?id=4406. In the future, just go to http://d.puremagic.com/issues and you can file the bug directly. It's good to ask on d.learn if you aren't sure. And this bug isn't in dmd, it's in phobos :) They are compiled separately (in case you are interested in trying your hand at phobos patches). All the releases come with the complete source code, just cd to the src directory and type make -f blah.mak where blah is your platform (posix, windows, etc.). -Steve
Jun 29 2010
prev sibling parent Heywood Floyd <soul8o8 gmail.com> writes:
Thanks!
I will!
/heywood







PS. I like D.

On Jun 29, 2010, at 19:37 , Steven Schveighoffer wrote:

 On Tue, 29 Jun 2010 13:05:50 -0400, Heywood Floyd <soul8o8 gmail.com> =

=20
=20
=20
 Ok, thanks!
=20
 How does the chain of command/responsibility work here?
 Should I file this to bugzilla?
=20
 (I'm not able to fix it myself as I haven't built dmd locally. I'm =


 /heywood

Simen actually already filed it. See here: =

just go to http://d.puremagic.com/issues and you can file the bug = directly. It's good to ask on d.learn if you aren't sure.
=20
 And this bug isn't in dmd, it's in phobos :)  They are compiled =

patches). All the releases come with the complete source code, just cd = to the src directory and type make -f blah.mak where blah is your = platform (posix, windows, etc.).
=20
 -Steve

Jun 29 2010