summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusintegrator.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-06-26 07:38:31 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-04-03 16:18:43 +0200
commit360f3de3909a14388f27d82bdad50bf370586cfe (patch)
tree9b663c15b5abc9c81da132051478a6658d278b7f /src/dbus/qdbusintegrator.cpp
parente4186b2b28ebe0fefc3f2eaecb7e8345d79ee63f (diff)
QtDBus: optimize handling of isDebugging
This is part of a series of patches deprecating implicit conversions of QAtomic<T> variables to T. Use relaxed atomic loads and stores on the 'isDebugging' variable. The old code used the implict conversions to and from int and therefore loadAcquire/storeRelease. Here, the int is the only value, it's not guarding the construction of any other data, so relaxed loads and stores suffice. A further optimization would be to make the initial value of isDebugging 0, to send it into the BSS instead of the TEXT/DATA segment, but seeing as this is just compiled in for the auto-tests, this patch leaves that particular change for another round (or never). Pick-to: 6.3 Change-Id: Ide92f6c1a12137fcbc3ec15e146f6dcbdb6b481b Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r--src/dbus/qdbusintegrator.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 5c30bc04c0..7970a36a1f 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -85,7 +85,7 @@ QT_IMPL_METATYPE_EXTERN(QDBusSlotCache)
static dbus_int32_t server_slot = -1;
static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1);
-#define qDBusDebug if (::isDebugging == 0); else qDebug
+#define qDBusDebug if (::isDebugging.loadRelaxed() == 0); else qDebug
static inline QDebug operator<<(QDebug dbg, const QThread *th)
{
@@ -1039,12 +1039,12 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
isAuthenticated(false)
{
static const bool threads = q_dbus_threads_init_default();
- if (::isDebugging == -1)
- ::isDebugging = qEnvironmentVariableIntValue("QDBUS_DEBUG");
Q_UNUSED(threads);
+ if (::isDebugging.loadRelaxed() == -1)
+ ::isDebugging.storeRelaxed(qEnvironmentVariableIntValue("QDBUS_DEBUG"));
#ifdef QDBUS_THREAD_DEBUG
- if (::isDebugging > 1)
+ if (::isDebugging.loadRelaxed() > 1)
qdbusThreadDebug = qdbusDefaultThreadDebug;
#endif