File indexing completed on 2024-04-28 15:20:31

0001 /*
0002     This file is part of the KDE Frameworks.
0003     SPDX-FileCopyrightText: 2010 Sebastian Trueg <trueg@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KDBUSCONNECTIONPOOL_H
0009 #define KDBUSCONNECTIONPOOL_H
0010 
0011 #include <kdbusaddons_export.h>
0012 
0013 #if KDBUSADDONS_ENABLE_DEPRECATED_SINCE(5, 68)
0014 #include <QDBusConnection>
0015 
0016 /**
0017  * @namespace KDBusConnectionPool
0018  * Provides utility functions working around the problem
0019  * of QDBusConnection not being thread-safe.
0020  * @deprecated since 5.68 QDBusConnection has been fixed.
0021  */
0022 namespace KDBusConnectionPool
0023 {
0024 /**
0025  * The KDBusConnectionPool works around the problem
0026  * of QDBusConnection not being thread-safe. As soon as that
0027  * has been fixed (either directly in libdbus or with a work-
0028  * around in Qt) this method can be dropped in favor of
0029  * QDBusConnection::sessionBus().
0030  *
0031  * Note that this will create a thread-local QDBusConnection
0032  * object, which means whichever thread this is called
0033  * from must have both an event loop and be as long-lived as
0034  * the object using it. If either condition is not met, the
0035  * returned QDBusConnection will not send or receive D-Bus
0036  * events (calls, return values, etc).
0037  *
0038  * Using this within libraries can create complexities for
0039  * application developers working with threads as its use
0040  * in the library may not be apparent to the application
0041  * developer, and so functionality may appear to be broken
0042  * simply due to the nature of the thread from which this
0043  * ends up being called from. Library developers using
0044  * this facility are strongly encouraged to note this
0045  * caveat in the library's documentation.
0046  *
0047  * @deprecated since 5.68 Use QDBusConnection::sessionBus() instead.
0048  * QDBusConnection is nowadays safe to use in multiple threads as well.
0049  */
0050 KDBUSADDONS_EXPORT
0051 KDBUSADDONS_DEPRECATED_VERSION(5, 68, "Use QDBusConnection::sessionBus()")
0052 QDBusConnection threadConnection();
0053 }
0054 #endif
0055 
0056 #endif