Skip to content

Commit 12c5573

Browse files
committed
Merge pull request #584 from rainers/sleep_non_zero
Thread.sleep for windows: for non-zero timeout, sleep at least 1ms
2 parents 113efb5 + 9f02de4 commit 12c5573

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/core/thread.d

+4
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,10 @@ class Thread
960960
{
961961
auto maxSleepMillis = dur!("msecs")( uint.max - 1 );
962962

963+
// avoid a non-zero time to be round down to 0
964+
if( val > dur!"msecs"( 0 ) && val < dur!"msecs"( 1 ) )
965+
val = dur!"msecs"( 1 );
966+
963967
// NOTE: In instances where all other threads in the process have a
964968
// lower priority than the current thread, the current thread
965969
// will not yield with a sleep time of zero. However, unlike

0 commit comments

Comments
 (0)