[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KJob: chaining and synchronizing jobs
From:       Kevin Krammer <kevin.krammer () gmx ! at>
Date:       2011-05-04 6:32:05
Message-ID: 201105040832.05567.kevin.krammer () gmx ! at
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Sunday, 2011-05-01, Michael Schuerig wrote:
> I have several KJob jobs, some of which may run in parallel, some depend
> on the results of one or more others, and all of them are fallible. The
> context is Akonadi, but I think my question is generic.
> 
> I want to retrieve items from several Akonadi collections and act on
> them. By the nature of the (prefered) interface, the individual steps
> executed asynchronously as KJobs.
> 
> The parts are these:
> 
> I launch several retrieval jobs and want to know when all of them have
> finished. If one of them fails, all others are killed and failure is
> signaled.
> 
> As far as I can tell, there's no pre-build way to group jobs in such a
> way as to be notified when all of them have finished. Therefore,
> apparently I need to do the synchronization myself, possibly by
> connecting to each jobs result signal and keeping track of how many are
> still active.
> 
> For chaining jobs, I need to glue them together so that the result of
> one is passed as an argument to the next. Of course, if an error occurs,
> the chain ought to be broken.
> 
> For all this I can write very specific code -- and do it again the next
> time I want to do something similar. I'd rather not do that. Instead,
> I'd like to connect independent pieces that are ignorant of each other.

For passing one job's result as a parameter to new job you'll need some place 
that knows the API of both, gets the data from the finished job and creates 
the new job.

Maybe using KCompositeJob and reimplementing  slotResult()?

Cheers,
Kevin
-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring

["signature.asc" (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic