Uploaded image for project: 'Qt Design Studio'
  1. Qt Design Studio
  2. QDS-6134

Start all puppet in parallel

    XMLWordPrintable

Details

    Description

      ConnectionManager::setUp

       BaseConnectionManager::setUp(nodeInstanceServerProxy, qrcMappingString, target, view);
      
          m_localServer = std::make_unique<QLocalServer>();
          QString socketToken(QUuid::createUuid().toString());
          m_localServer->listen(socketToken);
          m_localServer->setMaxPendingConnections(3);
      
          PuppetCreator puppetCreator(target, view->model());
          puppetCreator.setQrcMappingString(qrcMappingString);
      
          puppetCreator.createQml2PuppetExecutableIfMissing();
      
          for (Connection &connection : m_connections) {
              connection.qmlPuppetProcess = puppetCreator.createPuppetProcess(
                  connection.mode,
                  socketToken,
                  [&] { printProcessOutput(connection.qmlPuppetProcess.get(), connection.name); },
                  [&](int exitCode, QProcess::ExitStatus exitStatus) {
                      processFinished(exitCode, exitStatus, connection.name);
                  });
      
              const int second = 1000;
              int waitConstant = 8 * second;
      
              if (!connection.qmlPuppetProcess->waitForStarted(waitConstant)) {
                  closeSocketsAndKillProcesses();
                  showCannotConnectToPuppetWarningAndSwitchToEditMode();
                  return;
              }
      
              waitConstant /= 2;
      
              bool connectedToPuppet = true;
              if (!m_localServer->hasPendingConnections())
                  connectedToPuppet = m_localServer->waitForNewConnection(waitConstant);
      
              if (connectedToPuppet) {
                  connection.socket.reset(m_localServer->nextPendingConnection());
                  QObject::connect(connection.socket.get(), &QIODevice::readyRead, this, [&] {
                      readDataStream(connection);
                  });
              } else {
                  closeSocketsAndKillProcesses();
                  showCannotConnectToPuppetWarningAndSwitchToEditMode();
                  return;
              }
          }
      
          m_localServer->close();
      }
      
      void ConnectionManager::shutDown()
      {
          BaseConnectionManager::shutDown();
      
          closeSocketsAndKillProcesses();
      
          m_localServer.reset();
      
          for (Connection &connection : m_connections)
              connection.clear();
      }
      
      void ConnectionManager::writeCommand(const QVariant &command)
      {
          for (Connection &connection : m_connections)
              writeCommandToIODevice(command, connection.socket.get(), m_writeCommandCounter);
      
          m_writeCommandCounter++;
      }
      
      void ConnectionManager::processFinished(int exitCode, QProcess::ExitStatus exitStatus, const QString &connectionName)
      {
          qWarning() << "Process" << connectionName <<(exitStatus == QProcess::CrashExit ? "crashed:" : "finished:")
                     << "with exitCode:" << exitCode;
      
          writeCommand(QVariant::fromValue(EndPuppetCommand()));
      
          closeSocketsAndKillProcesses();
      
          if (exitStatus == QProcess::CrashExit)
              callCrashCallback();
      

      We use a single QLocalServer here, which requires us to start each puppet after each other.
      This makes starting the puppets considerably slower.

      Either we move QLocalServer to Connections or we keep a simple map that associates each Connection with a different QLocalServer.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              knud Knud Dollereder
              thohartm Thomas Hartmann
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes