KDECore
Go to the documentation of this file.
23 #include <QThreadStorage>
24 #include <QCoreApplication>
28 QAtomicInt s_connectionCounter;
30 class KDBusConnectionPoolPrivate
33 KDBusConnectionPoolPrivate()
34 : m_connection( QDBusConnection::connectToBus(
35 QDBusConnection::SessionBus,
36 QString::fromLatin1(
"KDBusConnection%1").arg(newNumber()) ) )
40 ~KDBusConnectionPoolPrivate()
42 QDBusConnection::disconnectFromBus( m_connection.name() );
45 QDBusConnection connection()
const
51 static int newNumber()
53 return s_connectionCounter.fetchAndAddAcquire(1);
56 QDBusConnection m_connection;
64 if (QCoreApplication::instance()->thread() == QThread::currentThread()) {
65 return QDBusConnection::sessionBus();
67 if (!s_perThreadConnection.hasLocalData()) {
68 s_perThreadConnection.setLocalData(
new KDBusConnectionPoolPrivate);
71 return s_perThreadConnection.localData()->connection();
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Sep 23 2014 09:53:07 by
doxygen 1.8.3.1 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.