using KDBusConnectionPool in libraries
Kevin Ottens
ervin at kde.org
Fri Feb 21 07:30:02 UTC 2014
Hello,
On Thursday 20 February 2014 20:03:20 Aaron J. Seigo wrote:
> I ran into an interesting situation the other day with libkactivities: it
> uses KDBusConnectionPool to create connections in a thread-safe manner.
> KDBusConnectionPool creates a connection in whatever thread it happens to
> be executed from. In libkactivities this creates a problem as a singleton
> that is internal to the library uses KDBusConnectionPool .. so whatever
> thread it happens to be called from first: that’s the thread it gets its
> QDBusConnection object put into.
Well, isn't the problem that this singleton should be thread-safe or thread-
local in the first place?
> Of course, if that thread has no event loop and/or exits, then things stop
> working as expected. In the case of libkactivities, things just stop
> working, period.
>
> Either a better solution needs to be found for KDBusConnectionPool or a
> warning should be placed prominently in the apidox about this “gotcha” and
> perhaps it should be completely avoided in other frameworks where it is
> impossible to know the threading model of the application that will be using
> it.
Yes, adding a big fat warning sounds fair to me.
> Or, I suppose, we could invent a policy that applications should do all
> dbus related activities in a specific thread .. though that can be
> difficult to know as dbus calls are often hidden within libraries.
>
> .. or, does anyone have a pointer to what exactly in QDBusConnection is not
> thread safe?
It wasn't (Qt4 times)... I have no idea if that's still the case today. It
could be that this class isn't needed anymore.
As for what exactly is not thread safe in QDBusConnection I don't remember.
Since it was highlighted by Nepomuk at the time and forced upon us by its API
(almost behind us too) Vishesh or Sebastian should know more (adding them in
CC).
Regards.
--
Kévin Ottens, http://ervin.ipsquad.net
KDAB - proud supporter of KDE, http://www.kdab.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20140221/315b3c46/attachment.sig>
More information about the Kde-frameworks-devel
mailing list