forked from libuv/libuv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
win: evaluate timers when system wakes up
When Windows resumes after sleep GetQueuedCompletionStatus timeout is not updated. This commit adds a method for signaling all loops to wake up and update their timers. Fixes: nodejs/node#6763 PR-URL: libuv#962 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Saúl Ibarra Corretgé <[email protected]>
- Loading branch information
Showing
7 changed files
with
206 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "uv.h" | ||
#include "internal.h" | ||
#include "winapi.h" | ||
|
||
static void uv__register_system_resume_callback(); | ||
|
||
void uv__init_detect_system_wakeup() { | ||
/* Try registering system power event callback. This is the cleanest | ||
* method, but it will only work on Win8 and above. | ||
*/ | ||
uv__register_system_resume_callback(); | ||
} | ||
|
||
static ULONG CALLBACK uv__system_resume_callback(PVOID Context, | ||
ULONG Type, | ||
PVOID Setting) { | ||
if (Type == PBT_APMRESUMESUSPEND || Type == PBT_APMRESUMEAUTOMATIC) | ||
uv__wake_all_loops(); | ||
|
||
return 0; | ||
} | ||
|
||
static void uv__register_system_resume_callback() { | ||
_DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS recipient; | ||
_HPOWERNOTIFY registration_handle; | ||
|
||
if (pPowerRegisterSuspendResumeNotification == NULL) | ||
return; | ||
|
||
recipient.Callback = uv__system_resume_callback; | ||
recipient.Context = NULL; | ||
(*pPowerRegisterSuspendResumeNotification)(DEVICE_NOTIFY_CALLBACK, | ||
&recipient, | ||
®istration_handle); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters