Apple event dispatcher: "clarify" copy semantics of ProcessEventsState

QEDCF::processEvents makes copies of ProcessEventsState, which contains
atomics. The memory ordering semantics when those atomics are used
are not clear at all -- given the lack of comments in the code around
them, and the lack of named operations (e.g. loadAcquire).
In principle, it looks like relaxed ordering could even suffice.

However, I'm not confident in making such a change. For now, avoid a
direct copy (assignment) of the atomics themselves (those operations
are meaningless), and use very conservative semantics when copying
ProcessEventsState.

Change-Id: I8584ff3fe9fef52385bd438235ee823bdbab8a42
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Giuseppe D'Angelo 2023-09-13 22:17:22 +02:00
parent 25c9f59546
commit 1399b3ccce

View File

@ -204,6 +204,25 @@ protected:
, processedPostedEvents(false), processedTimers(false) , processedPostedEvents(false), processedTimers(false)
, deferredWakeUp(false), deferredUpdateTimers(false) {} , deferredWakeUp(false), deferredUpdateTimers(false) {}
ProcessEventsState(const ProcessEventsState &other)
: flags(other.flags)
, wasInterrupted(other.wasInterrupted.loadAcquire())
, processedPostedEvents(other.processedPostedEvents.loadAcquire())
, processedTimers(other.processedTimers.loadAcquire())
, deferredWakeUp(other.deferredWakeUp.loadAcquire())
, deferredUpdateTimers(other.deferredUpdateTimers) {}
ProcessEventsState &operator=(const ProcessEventsState &other)
{
flags = other.flags;
wasInterrupted.storeRelease(other.wasInterrupted.loadAcquire());
processedPostedEvents.storeRelease(other.processedPostedEvents.loadAcquire());
processedTimers.storeRelease(other.processedTimers.loadAcquire());
deferredWakeUp.storeRelease(other.deferredWakeUp.loadAcquire());
deferredUpdateTimers = other.deferredUpdateTimers;
return *this;
}
QAtomicInt flags; QAtomicInt flags;
QAtomicInteger<char> wasInterrupted; QAtomicInteger<char> wasInterrupted;
QAtomicInteger<char> processedPostedEvents; QAtomicInteger<char> processedPostedEvents;