PDA

View Full Version : get status of QRunnable



Qtonimo
27th July 2012, 11:35
Hi I have a question ; )...

I want to use QThreadPool to run several QRunnble Tasks concurrent.

f.e. There is a machine with 8 cpu's.
I want to start 8 Runnbles. But after 5 seconds my mainthread want to know the status of each runnable.

t1: 10% finished
t2: 70% finished
and so on....

What is the easiest approach to query a member of a QRunnable, while executing?


thanks in advance

wysota
27th July 2012, 12:42
How exactly would the runnable know if it is at 10% or 90% of its work?

Qtonimo
27th July 2012, 12:53
Thank you for your reply...

Because there is a loop in the run method and I know the count.

wysota
27th July 2012, 14:00
Then emit a signal and catch it somewhere or store the status in some member variable (possibly of type QAtomicInt) of the runnable object and read it from there.

Qtonimo
27th July 2012, 14:52
But storing the status in a member of normal type int is not possible? Is this right?

So I have to use QAtomicInt....

wysota
27th July 2012, 18:37
But storing the status in a member of normal type int is not possible? Is this right?
You can store it however you like.

Qtonimo
30th July 2012, 08:13
Ok, this works very well. So a getter method is possible between different threads.

But why you recommended QAtomicInt?