QWinEventNotifier: reinterpret 'int signaledCount' as a 'bool signaled'
In fact, this variable can take only two values: 0 and 1. By interpreting its value as boolean, we can use relaxed store operations instead of atomic increments. This is safe, because it's guarded by 'activateEventNotifiersPosted' variable, which already provides a release/acquire semantic. Change-Id: If9adb7d022f1500ee7e8b61f336d8732f9b88d4c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
8716413afc
commit
c6d1e7ad38
@ -877,8 +877,8 @@ void QEventDispatcherWin32::activateEventNotifiers()
|
||||
for (int i = 0; i < d->winEventNotifierList.count(); ++i) {
|
||||
QWinEventNotifier *notifier = d->winEventNotifierList.at(i);
|
||||
QWinEventNotifierPrivate *nd = QWinEventNotifierPrivate::get(notifier);
|
||||
if (nd->signaledCount.loadRelaxed() != 0) {
|
||||
--nd->signaledCount;
|
||||
if (nd->signaled.loadRelaxed()) {
|
||||
nd->signaled.storeRelaxed(false);
|
||||
nd->unregisterWaitObject();
|
||||
d->activateEventNotifier(notifier);
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ void QWinEventNotifier::setEnabled(bool enable)
|
||||
}
|
||||
|
||||
if (enable) {
|
||||
d->signaledCount = 0;
|
||||
d->signaled.storeRelaxed(false);
|
||||
eventDispatcher->registerEventNotifier(this);
|
||||
} else {
|
||||
eventDispatcher->unregisterEventNotifier(this);
|
||||
@ -245,7 +245,7 @@ static void CALLBACK wfsoCallback(void *context, BOOLEAN /*ignore*/)
|
||||
|
||||
QEventDispatcherWin32Private *edp = QEventDispatcherWin32Private::get(
|
||||
static_cast<QEventDispatcherWin32 *>(eventDispatcher));
|
||||
++nd->signaledCount;
|
||||
nd->signaled.storeRelaxed(true);
|
||||
edp->postActivateEventNotifiers();
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
|
||||
HANDLE handleToEvent;
|
||||
HANDLE waitHandle = NULL;
|
||||
QAtomicInt signaledCount;
|
||||
QAtomicInt signaled;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user