On 12/18/2010 10:46 PM, Jonathan M Davis wrote:
On Saturday 18 December 2010 13:22:52 Joost 't Hart wrote:
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.
Welcome!
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?
You're using the wrong function (see http://is.gd/iYySf ). The correct function
is core.Thread.sleep(). It works on both Windows and Linux. It's a static
function which should work just fine regardless of whether you're using Thread
directly or using spawn().
Thanks Jonathan!
After another minute of eyebrowing I got it working:
import core.thread;
....
void mySleep( long tim_in_millisecs )
{
// No, not a simple ::sleep, and please do care about those numbers!
Thread.sleep( tim_in_millisecs * 10_000 );
}
Quoting the documentation:
/Suspends the calling thread for at least the supplied period./
What does "at least" mean here? Is there also an "at most"? I do not
want my friend to end up in cyberspace. :-)
I guess part (2) of my original posting still stands as a candidate bug?
Cheers,
Joost.
- Jonathan M Davis