Since there is no non-atomic data that is protected by 'initialized'
anymore, the read from, and the store to, 'initialized' may now have
relaxed memory ordering.
Change-Id: I58004e782d9fd93122efb31fa5b30ee160646d99
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
void QDBusMetaTypeId::init()
{
- static volatile bool initialized = false;
+ static QBasicAtomicInt initialized = Q_BASIC_ATOMIC_INITIALIZER(false);
// reentrancy is not a problem since everything else is locked on their own
// set the guard variable at the end
- if (!initialized) {
+ if (!initialized.load()) {
// register our types with QtCore (calling qMetaTypeId<T>() does this implicitly)
(void)message();
(void)argument();
qDBusRegisterMetaType<QList<QDBusUnixFileDescriptor> >();
#endif
- initialized = true;
+ initialized.store(true);
}
}