3510 void os::naked_short_sleep(jlong ms) { |
3510 void os::naked_short_sleep(jlong ms) { |
3511 assert(ms < 1000, "Un-interruptable sleep, short time use only"); |
3511 assert(ms < 1000, "Un-interruptable sleep, short time use only"); |
3512 Sleep(ms); |
3512 Sleep(ms); |
3513 } |
3513 } |
3514 |
3514 |
|
3515 void os::naked_short_nanosleep(jlong ns) { |
|
3516 assert(ns > -1 && ns < NANOUNITS, "Un-interruptable sleep, short time use only"); |
|
3517 LARGE_INTEGER hundreds_nanos = { 0 }; |
|
3518 HANDLE wait_timer = ::CreateWaitableTimer(NULL /* attributes*/, |
|
3519 true /* manual reset */, |
|
3520 NULL /* name */ ); |
|
3521 if (wait_timer == NULL) { |
|
3522 log_warning(os)("Failed to CreateWaitableTimer: %u", GetLastError()); |
|
3523 return; |
|
3524 } |
|
3525 |
|
3526 // We need a minimum of one hundred nanos. |
|
3527 ns = ns > 100 ? ns : 100; |
|
3528 |
|
3529 // Round ns to the nearst hundred of nanos. |
|
3530 // Negative values indicate relative time. |
|
3531 hundreds_nanos.QuadPart = -((ns + 50) / 100); |
|
3532 |
|
3533 if (::SetWaitableTimer(wait_timer /* handle */, |
|
3534 &hundreds_nanos /* due time */, |
|
3535 0 /* period */, |
|
3536 NULL /* comp func */, |
|
3537 NULL /* comp func args */, |
|
3538 FALSE /* resume */)) { |
|
3539 DWORD res = ::WaitForSingleObject(wait_timer /* handle */, INFINITE /* timeout */); |
|
3540 if (res != WAIT_OBJECT_0) { |
|
3541 if (res == WAIT_FAILED) { |
|
3542 log_warning(os)("Failed to WaitForSingleObject: %u", GetLastError()); |
|
3543 } else { |
|
3544 log_warning(os)("Unexpected return from WaitForSingleObject: %s", |
|
3545 res == WAIT_ABANDONED ? "WAIT_ABANDONED" : "WAIT_TIMEOUT"); |
|
3546 } |
|
3547 } |
|
3548 } |
|
3549 ::CloseHandle(wait_timer /* handle */); |
|
3550 } |
|
3551 |
3515 // Sleep forever; naked call to OS-specific sleep; use with CAUTION |
3552 // Sleep forever; naked call to OS-specific sleep; use with CAUTION |
3516 void os::infinite_sleep() { |
3553 void os::infinite_sleep() { |
3517 while (true) { // sleep forever ... |
3554 while (true) { // sleep forever ... |
3518 Sleep(100000); // ... 100 seconds at a time |
3555 Sleep(100000); // ... 100 seconds at a time |
3519 } |
3556 } |