[Kde-pim] Akonadi + multithreading
Kevin Krammer
krammer at kde.org
Fri Mar 7 16:55:53 GMT 2014
Hello Patrick!
On Friday, 2014-03-07, 16:40:09, Patrick Ohly wrote:
> Hello!
>
> I recently released SyncEvolution 1.4 and shortly afterwards got a bug
> report about Akonadi failing when used in a SyncML HTTP server
> (https://bugs.freedesktop.org/show_bug.cgi?id=75672).
>
> The symptom is that SyncEvolution reports "Akonadi is not running. It
> can be started with 'akonadictl start'" despite Akonadi being up and
> running. SyncEvolution prints that when
> Akonadi::ServerManager::isRunning() returns false.
>
> Further debugging showed that this occurs only when code using Akonadi
> runs in a background thread. This feature was introduced in
> SyncEvolution 1.4 to allow the main SyncML code to respond with
> intermediate replies while slow, synchronous initialization of local or
> remote storage is still going on.
>
> The feature can be turned off, but the real question remains: should
> Akonadi::ServerManager::isRunning() work regardless which thread calls
> it?
This might be an artifact of ServerManager being a singleton, e.g. the
instance "belonging" to the thread which created it.
Maybe that is the main thread due to some other code or always the main
thread, I don't know. But that is a possible cause.
> If I move the check into the main thread, will the other Akonadi methods
> (in particular Job::exec) work in background threads?
Yes. All thread's have their own default session, i.e. the
Akonadi::Sesssion::defaultSession() instance is a "per-thread singleton".
This is the session used by jobs that do not have a parent job or explciit
parent session. In those cases the newly created job runs with the provided
session and in the thread that created that session.
But since most jobs are usally created without any parent, the default session
is the one usually being used. And each thread has its own.
Cheers,
Kevin
P.S.: great to hear from you again, despite the circumstances. We need to
invite you more often to our sprints :)
--
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20140307/514d8e61/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/
More information about the kde-pim
mailing list