sleepy receiveTimeout?
Joost 't Hart
Joost.t.Hart at planet.nl
Sat Dec 18 13:22:52 PST 2010
Hi,
(also posted on news.gmane.org, but does not seem to appear there)
New to this group and to D, but getting "into" it fast.
Came across a problem.
2.050 / Linux
1) On windows we can get any (std.concurrency, which is what I use in my
project) thread to sleep using Sleep() from core.sys.windows.windows. I
cannot find the alternative under Linux...
Is there one?
2) So I wrote one myself using receiveTimeout( time, (something unused){} );
Now begins the fun. For values of time >= 500 this workaround is fine.
For values < 500 it does not work.
Where does this magic number sit?
Cheers,
Joost.
$ cat time.d
import std.concurrency;
import std.conv;
void run( long tim )
{
foreach( dum; 0 .. 100 )
{
receiveTimeout( tim, (int x){} );
}
}
void main( string[] args )
{
run( to!long( args[1] ) );
}
$ time ./time 500
real 0m49.673s
user 0m0.000s
sys 0m0.000s
$ time ./time 499
real 0m0.972s
user 0m0.000s
sys 0m0.000s
$
More information about the Digitalmars-d-learn
mailing list