How to call receiveTimout? (std.concurrency)
    soul8o8 
    soul8o8 at gmail.com
       
    Tue Jun 29 06:36:16 PDT 2010
    
    
  
Hello!
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?
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
    
    
More information about the Digitalmars-d-learn
mailing list