www.digitalmars.com         C & C++   DMDScript  

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

Hello!


I'm trying to use receiveTimeout:

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

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

Compiler gives me:=20
	=
/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?


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

	bool receiveTimeout(T...)( long ms, T ops )
	{
	    static enum long TICKS_PER_MILLI =3D 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] >=3D 0 );
                long period =3D ops[0];
                ops =3D ops[1 .. $];  // <=3D=3D=3D line 335
            }

// - - 8< - -




(DMD v2.047, OSX 10.6.4)

BR
/soul
Jun 29 2010