QtConcurrent::map uses 100% of CPU
-
how long running is his task?
-
It is up to the size of the "taskActivesByThread" and the time to get the response of the devices, it could be one minute or even more. The application works fine, but I just want to know if any other alternative methods would produce 100% of CPU while the polling is active...
-
Possibly something is in an active wait state, meaning it is constantly querying to see if the results are ready.
-
Well, yesss..they are waiting for the results to be ready, but just because a thread is in an active state will produce a huge increment in the cpu?
-
If the thread is in an active wait state (for example waiting for a spin lock), yes. If the thread is in an inactive wait state (for example waiting for a conditional variable), no.
What does snmp-get do and is it thread safe?
-
It is thread safe...the snmp get is really a "QProcess" calling the libraries of the net-snmp, so i need the wait until the "QProcess" finish to captutre the data...
-
How is it waiting for the QProcess to finish and how is it capturing the data?
-
It's something like this...
@
QProcess snmpGet;
snmpGet.start(program,params);if (snmpGet.waitForStarted())
{
if (!snmpGet.waitForFinished())
{
return INVALID_VALUE;
}
QString output(snmpGet.readAll());
//Then i have to parsing the data to obtain the data...}else{
return INVALID_VALUE
}@
-
Nothing seems wrong with what you've described so far. If you interrupt it in a debugger when the CPU is at 100%, where does it break?
-
Profile it and see where the profiler says the cpu is spending all of its time.