[Interest] Fwd: how to run 21 threads concurrently

Sujan Dasmahapatra sujan.dasmahapatra at gmail.com
Fri Oct 5 19:20:40 CEST 2012


This code snippet is nomore hanging. i did some mistake. but it's still the
same. not writing some data to the file. problem persists. whats still
going wrong please help.

[code]


QSemaphore mSemaphore1;

int nZ=1;

for (int z=0;z<nZ;z++)

{

Q_ASSERT( &mSemaphore1 );

Th = QtConcurrent::run(

this,&UNRSTParser::ProcessZLayer,z);

mSemaphore1.release(1);

values += (nX*nY);

}

mSemaphore1.acquire(nZ);


[/code]

On Fri, Oct 5, 2012 at 2:12 PM, Jan Kundrát <jkt at flaska.net> wrote:

> On 10/05/12 00:27, Sascha Cunz wrote:
> > But, after all, the above code is a so called busy-loop. It will eat up
> 1 core
> > almost completely (At least on most OS-configurations).
>
> Are you sure that a call to QFuture::waitForFinished() consumes CPU?
> That would be highly suspicious. Yes, the call will block and wait until
> the QFuture succeeds, but that's different from what a busy loop is.
>
> Using waitForFinished() on each future is easier and more
> straightforward than adding semaphores.
>
> With kind regards,
> Jan
>
> --
> Trojita, a fast e-mail client -- http://trojita.flaska.net/
> _______________________________________________
> 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
Mobile no : +966-530184511





-- 
Regards
Sujan Dasmahapatra
skype: sujan.dasmahapatra
yahoo msn : dasmahapatra.aerodynamics at yahoo.co.in
Mobile no : +966-530184511
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121005/64b8d8dd/attachment.html>


More information about the Interest mailing list