[Interest] Is this snippet correct- concurrent run

Sujan Dasmahapatra sujan.dasmahapatra at gmail.com
Fri Oct 12 17:01:32 CEST 2012


Please check this snippet if this is correct


   1. QFuture<void> Th;
   2. std::vector<QFuture<void> > Threads;
   3. int z=0;
   4. while(z<nZ) {
   5. while(QThreadPool::globalInstance()->activeThreadCount() < QThreadPool
   ::globalInstance()->maxThreadCount()) {
   6. Th = QtConcurrent::run(this,&UNRSTParser::ProcessZLayer,z);
   7. Threads.push_back(Th);
   8. z++;
   9. if(z==nZ)
   10. break;
   11. }
   12. }
   13. //cout << " ZFinished...\n";
   14. for(int th=0; th<Threads.size(); th++)
   15. Threads[th].waitForFinished();
   16. Threads.clear();


On Fri, Oct 12, 2012 at 4:44 PM, Christian Gagneraud <chris at techworks.ie>wrote:

> Hi Sujan,
>
> Copy/pasting code in email body can lead to strange formating depending
> on the reader's email client (Have a look below).
> You better off using online copy/pasting tools like http://pastebin.com
> (free service). This way, anyone can read your code snippet, and with
> good syntax highlight too!
>
> Chris
>
> On 12/10/12 14:02, Sujan Dasmahapatra wrote:
> > Is this code snippet correct?  I am  trying to submit a number of
> > threads if global actibe threadcount is less than global max thread
> count.
> > [code]
> >
> > QFuture<
> >
> > void> Th;
> >
> > std::vector<QFuture<
> >
> > void> > Threads;
> >
> > intz=0;
> >
> > while(z<nZ) {
> >
> > while(QThreadPool::globalInstance()->activeThreadCount() <
> > QThreadPool::globalInstance()->maxThreadCount()) {
> >
> > Th = QtConcurrent::run(
> >
> > this,&UNRSTParser::ProcessZLayer,z);
> >
> > Threads.push_back(Th);
> >
> > z++;
> >
> > values += (nX*nY);
> >
> > if(z==nZ)
> >
> > break;
> >
> > }
> >
> > }
> >
> > //cout << " ZFinished...\n";
> >
> > for(intth=0; th<Threads.size(); th++)
> >
> > Threads[th].waitForFinished();
> >
> > Threads.clear();
> >
> > [/code]
> >
> > --
> > Regards
> > Sujan Dasmahapatra
> > skype: sujan.dasmahapatra
> > yahoo msn : dasmahapatra.aerodynamics at yahoo.co.in
> > <mailto:dasmahapatra.aerodynamics at yahoo.co.in>
> >
> >
> >
> > _______________________________________________
> > Interest mailing list
> > Interest at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/interest
>
>
> --
> Christian Gagneraud,
> Embedded systems engineer.
> Techworks Marine
> 1 Harbour road
> Dun Laoghaire
> Co. Dublin
> Ireland
> Tel: + 353 (0) 1 236 5990
> Web: http://www.techworks.ie/
> --
> Visit us at the International Conference on Ocean Energy
> Dublin 17-19 Oct
> http://www.icoe2012dublin.com/
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>



-- 
Regards
Sujan Dasmahapatra
skype: sujan.dasmahapatra
yahoo msn : dasmahapatra.aerodynamics at yahoo.co.in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121012/3dce4216/attachment.html>


More information about the Interest mailing list