Skip to content

Commit 7a2e9f4

Browse files
author
Eric Holk
committed
Sleep for a nonzero amount of time on Windows.
1 parent 5d5a3ca commit 7a2e9f4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/rt/rust_scheduler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ rust_scheduler::start_main_loop() {
197197
DLOG(this, task,
198198
"all tasks are blocked, scheduler id %d yielding ...",
199199
id);
200-
lock.timed_wait(100000);
200+
lock.timed_wait(10);
201201
reap_dead_tasks(id);
202202
DLOG(this, task,
203203
"scheduler %d resuming ...", id);

src/rt/sync/lock_and_signal.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ void lock_and_signal::wait() {
6868
timed_wait(0);
6969
}
7070

71-
bool lock_and_signal::timed_wait(size_t timeout_in_ns) {
71+
bool lock_and_signal::timed_wait(size_t timeout_in_ms) {
7272
_locked = false;
7373
bool rv = true;
7474
#if defined(__WIN32__)
7575
LeaveCriticalSection(&_cs);
76-
DWORD timeout = timeout_in_ns == 0 ? INFINITE : timeout_in_ns / 1000000;
76+
DWORD timeout = timeout_in_ms == 0 ? INFINITE : timeout_in_ms;
7777
rv = WaitForSingleObject(_event, timeout) != WAIT_TIMEOUT;
7878
EnterCriticalSection(&_cs);
7979
_holding_thread = GetCurrentThreadId();
@@ -85,7 +85,7 @@ bool lock_and_signal::timed_wait(size_t timeout_in_ns) {
8585
gettimeofday(&time_val, NULL);
8686
timespec time_spec;
8787
time_spec.tv_sec = time_val.tv_sec + 0;
88-
time_spec.tv_nsec = time_val.tv_usec * 1000 + timeout_in_ns;
88+
time_spec.tv_nsec = time_val.tv_usec * 1000 + timeout_in_ms * 1000000;
8989
if(time_spec.tv_nsec >= 1000000000) {
9090
time_spec.tv_sec++;
9191
time_spec.tv_nsec -= 1000000000;

0 commit comments

Comments
 (0)