On Friday 06 September 2013 22:22:20 Andre Somers wrote: > . However, I'd hope the design would > not limit itself to just event-driven jobs, if I understand correctly > what that means. Some of my jobs are just heavy processing that require > multi-threading.
That sounds more like QRunnable than QJob then. But we could have a QThreadJob, for instance like this: it would inherit from both QJob and QRunnable, its doStart() would queue itself as a runnable into a QThreadPool. This creates issues with methods on the same class being called from two different threads though, so maybe better to have QThreadJob and QThreadJobRunnable (which inherits QRunnable and adds signals for progress and completion, optionally cancellation). All this however is experimental, so definitely not for 5.2. > Would this API suport that too, or would that be hacky > again to implement? Another aspect that I build into my own solution and > that I find valuable, is that I have added a mechanism to prevent the > same work being done twice. If different parts of the code ask for the > same calculation to be performed (that can happen in my case), they > actually get a pointer to the same job back. That turns out to be very > convenient. Note however, that that requires a job manager, and it > doesn't look like that is in this design. In my case, I submit a request > to the manager, who then returns a job. You can do that on top of the QJob framework I have in mind. Instead of "new CalculationJob" you'd ask manager->createCalculationJob() and the manager would take care of reuse and deletion. I don't think this is necessary in the core framework. > Note that in my case, I return QSharedPointer<Job>, so it is clear to > everyone that the code that everyone that requests a job and gets one, > can't treat it as if it was theirs exclusively. Yep, that can be done on top. Most use cases I've seen are about separate operations rather than calculations, so they don't need the extra syntactic overhead of QSharedPointer<Job> everywhere. -- David Faure | david.fa...@kdab.com | Managing Director KDAB France KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090 KDAB - Qt Experts - Platform-independent software solutions _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development