[ThreadWeaver] Several Weaver instances

Mirko Boehm mirko at kde.org
Thu Apr 19 09:00:07 BST 2007


On Wednesday 18 April 2007 15:57, you wrote:
> > Just create a ThreadWeaver::Weaver object. It will behave just like the
> > singleton. One of the examples does it that way.
>
> Great, I already took a look at the SMIV model and noticed the
> ThreadWeaver::Weaver have a public constructor.
> I already have the code working :)
Sure. What where you thinking? :-)

>
> > Dependencies of jobs do function across Weaver objects.
>
> If the same priority is used for the jobs, is it garanteed the the jobs
> will be executed by their queue order?
You should not make assumptions on execution order, in general. In reality, 
jobs will be executed in queueing order, but for example, job collections and 
sequences are free to queue their subjobs as they please. 

> Anyway I got this job that should only be started when all jobs of a
> certain kind are finished. I couldn't find a way to do this, as
> addDependency() works with instances of jobs, not job types.
This sounds to me like you want to put all the other jobs into on collection, 
set up a dependency between the collection and the cleanup job, and queue 
both. 
If this is a generic "do this when everything else is done", priorities are 
the way to go. But there are few solutions where this makes sense. 

Generally, I would avoid trying to manage multiple queues. Instead, one queue 
with many threads and a well-thought-of set of dependencies and resource 
restrictions leads to better performance and a cleaner implementation. It is 
like the processors in your computer - you do not want to care which one does 
what, you just tell the OS how you want done. 

If multiple jobs are related in a bigger picture, it is advisable to inherit 
JobCollection (or JobSequence) and put them all in there, then you have a 
nice unit of execution. 

--Mirko.

-- 
KDE e.V.: http://ev.kde.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070419/e7ab4689/attachment.sig>


More information about the kde-core-devel mailing list