mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 02:55:44 +08:00
Performance: avoid long sleep in processEvents loop.
This commit is contained in:
@@ -248,14 +248,10 @@ namespace BlackCore
|
|||||||
|
|
||||||
bool CApplication::waitForStart()
|
bool CApplication::waitForStart()
|
||||||
{
|
{
|
||||||
// process events return immediatley if nothing is to be processed
|
QEventLoop eventLoop;
|
||||||
const QTime dieTime = QTime::currentTime().addMSecs(5000);
|
QTimer::singleShot(5000, &eventLoop, &QEventLoop::quit);
|
||||||
while (QTime::currentTime() < dieTime && !this->m_started && !this->m_startUpCompleted)
|
connect(this, &CApplication::setupAvailable, &eventLoop, &QEventLoop::quit);
|
||||||
{
|
eventLoop.exec();
|
||||||
// Alternative: use QEventLoop, which seemed to make the scenario here more complex
|
|
||||||
QCoreApplication::instance()->processEvents(QEventLoop::AllEvents, 250);
|
|
||||||
QThread::msleep(250); // avoid CPU loop overload by "infinite loop"
|
|
||||||
}
|
|
||||||
if (!this->m_startUpCompleted)
|
if (!this->m_startUpCompleted)
|
||||||
{
|
{
|
||||||
CLogMessage(this).error("Waiting for startup timed out");
|
CLogMessage(this).error("Waiting for startup timed out");
|
||||||
|
|||||||
Reference in New Issue
Block a user