On Jan 8, 2016, at 4:11 AM, Etienne Sandré-Chardonnal 
<etienne.san...@m4x.org<mailto:etienne.san...@m4x.org>> wrote:

Dear all,

In a recent stress test, where I created 5 sub-processes, each one starting 
idealThreadCount() fully working threads (ie they never sleep), I found that a 
QTimer responsible for sending some information messages to the sub-process 
stdout was stuck until the working threads stopped.

The QTimer is created and lives in the main thread, and the main event loop is 
alive and responds to event. But the slot to which timeout() is called is never 
called until the worker threads finish.

Could it be that the QTimer is using a different thread, that gets stuck due to 
the high system load?

The platform is Windows


While possible, I doubt issue is caused by system load.

Slots will not get called unless the main event loop gets to run.  You can 
force this to happen by calling processEvents.  If you find yourself calling 
processEvents you may need to analyze your code for “bad smells”.


    QCoreApplication::processEvents();


If you are emitting signals from threads and need to receive them on a slot in 
your MainWindow for example, you can use a QueuedConnection


    // Use QueuedConnection because readyRead signal is called from a thread 
that uses WINSOCK to listen for Bluetooth receive data

    connect(&m_bufferReceiveWriter, SIGNAL(readyRead()),

            this,   SIGNAL(readyRead()),

            Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection));

I would recommend to analyze where you create your QTimer, where you emit the 
QTimer signals, and where is your slot located.

-Ed



Thanks!
_______________________________________________
Interest mailing list
Interest@qt-project.org<mailto:Interest@qt-project.org>
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.qt-2Dproject.org_mailman_listinfo_interest&d=CwICAg&c=G4BpsyPyB19LB50bn2swXw&r=cAG2c-SQES5P2qb8IW-uwnBOCX_f2qYJIlzenFnoHUc&m=1SUE5pnBqhPlyK46ciVn5FvriHwNe1xMp53ZSF_EzVs&s=ijsGadn_1LnVhAnq--bFQuZ8gSActgybIy2UMd5B__g&e=

This email and any files transmitted with it from The Charles Machine Works, 
Inc. are confidential and intended solely for the use of the individual or 
entity to which they are addressed. If you have received this email in error 
please notify the sender. Our company accepts no liability for the contents of 
this email, or for the consequences of any actions taken on the basis of the 
information provided, unless that information is subsequently confirmed in 
writing. Please note that any views or opinions presented in this email are 
solely those of the author and do not necessarily represent those of the 
company. Finally, the recipient should check this email and any attachments for 
the presence of viruses. The company accepts no liability for any damage caused 
by any virus transmitted by this email.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to