mirror of
https://github.com/debauchee/barrier.git
synced 2026-02-09 05:13:36 +08:00
changed waitForEvent() to handle a peculiar feature of
MsgWaitForMultipleObjects(): it will not return immediately if an event already in the queue when it's called was already in the queue during the last call to GetMessage()/PeekMessage(). also now discarding screen saver events if there are any other screen saver events in the queue already. this prevents these events from piling up in the queue, which they'd do because we sleep for 250ms when handling each one.
This commit is contained in:
@@ -628,6 +628,14 @@ CThreadRep::wait(CThreadRep* target, double timeout)
|
||||
bool
|
||||
CThreadRep::waitForEvent(double timeout)
|
||||
{
|
||||
// check if messages are available first. if we don't do this then
|
||||
// MsgWaitForMultipleObjects() will block even if the queue isn't
|
||||
// empty if the messages in the queue were there before the last
|
||||
// call to GetMessage()/PeekMessage().
|
||||
if (HIWORD(GetQueueStatus(QS_ALLINPUT)) != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// is cancellation enabled?
|
||||
const DWORD n = (isCancellable() ? 1 : 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user