summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@qt.io>2021-06-21 15:53:13 +0200
committerKarsten Heimrich <karsten.heimrich@qt.io>2021-10-19 10:14:24 +0200
commit1d2d8f30551e54e9e5e760e445f66059f8a1c78e (patch)
treebea1a26b89cabaa9b64ba0a915e557506289eef1 /src
parent4ca7ba269dbafb38ba26e7bef2bb5587d75568f1 (diff)
Revert "Revert "Emit _q_notify only if there's no notification pending""
This reverts commit f6b43c36b3839dae54308a6437bbdd99ae9a44de. Part of chain revert to go back to QWinOverlappedIoNotifier. Task-number: QTBUG-93865 Change-Id: Ibf7328558690faac41375fe4c08d128e928a5a66 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/serialport/qwinoverlappedionotifier.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/serialport/qwinoverlappedionotifier.cpp b/src/serialport/qwinoverlappedionotifier.cpp
index f29bae0a..81cacb2f 100644
--- a/src/serialport/qwinoverlappedionotifier.cpp
+++ b/src/serialport/qwinoverlappedionotifier.cpp
@@ -129,6 +129,7 @@ public:
HANDLE hSemaphore = nullptr;
HANDLE hResultsMutex = nullptr;
QAtomicInt waiting;
+ QAtomicInt pendingNotifications;
QQueue<IOResult> results;
};
@@ -397,14 +398,17 @@ void QWinOverlappedIoNotifierPrivate::notify(DWORD numberOfBytes, DWORD errorCod
results.enqueue(IOResult(numberOfBytes, errorCode, overlapped));
ReleaseMutex(hResultsMutex);
ReleaseSemaphore(hSemaphore, 1, NULL);
- if (!waiting)
+ if (!waiting && pendingNotifications-- == 0)
emit q->_q_notify();
}
void QWinOverlappedIoNotifierPrivate::_q_notified()
{
- if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0)
- dispatchNextIoResult();
+ int n = pendingNotifications.fetchAndStoreAcquire(0);
+ while (--n >= 0) {
+ if (WaitForSingleObject(hSemaphore, 0) == WAIT_OBJECT_0)
+ dispatchNextIoResult();
+ }
}
OVERLAPPED *QWinOverlappedIoNotifierPrivate::dispatchNextIoResult()