From 00ba645fe132ae00373f6e74d5686dfb3bdc42cb Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 22 Jan 2024 19:35:39 +0100 Subject: [PATCH] ProcessBlockingInterface: Change signature of waitForSignal() Change the arg to QDeadlineTimer type. Change-Id: I7087648fd4f248b0b5024dc0d51d65171037934d Reviewed-by: Qt CI Bot Reviewed-by: Reviewed-by: Orgad Shaneh --- src/libs/utils/launchersocket.cpp | 11 +++++------ src/libs/utils/launchersocket.h | 4 ++-- src/libs/utils/process.cpp | 24 ++++++++++++------------ src/libs/utils/processinterface.h | 3 ++- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/libs/utils/launchersocket.cpp b/src/libs/utils/launchersocket.cpp index 067730f9c86..23b7d39fcd1 100644 --- a/src/libs/utils/launchersocket.cpp +++ b/src/libs/utils/launchersocket.cpp @@ -300,11 +300,11 @@ void CallerHandle::setProcessSetupData(ProcessSetupData *setup) m_setup = setup; } -bool CallerHandle::waitForSignal(SignalType signalType, int msecs) +bool CallerHandle::waitForSignal(SignalType signalType, QDeadlineTimer timeout) { QTC_ASSERT(isCalledFromCallersThread(), return false); QTC_ASSERT(m_launcherHandle, return false); - return m_launcherHandle->waitForSignal(signalType, msecs); + return m_launcherHandle->waitForSignal(signalType, timeout); } // Called from caller's or launcher's thread. @@ -322,14 +322,13 @@ bool CallerHandle::isCalledFromLaunchersThread() const } // Called from caller's thread exclusively. -bool LauncherHandle::waitForSignal(CallerHandle::SignalType newSignal, int msecs) +bool LauncherHandle::waitForSignal(CallerHandle::SignalType newSignal, QDeadlineTimer timeout) { QTC_ASSERT(!isCalledFromLaunchersThread(), return false); - QDeadlineTimer deadline(msecs); while (true) { - if (deadline.hasExpired()) + if (timeout.hasExpired()) break; - if (!doWaitForSignal(deadline)) + if (!doWaitForSignal(timeout)) break; // Matching (or Done) signal was flushed if (m_callerHandle->flushFor(newSignal)) diff --git a/src/libs/utils/launchersocket.h b/src/libs/utils/launchersocket.h index 54c212c479b..9f906d1dcc4 100644 --- a/src/libs/utils/launchersocket.h +++ b/src/libs/utils/launchersocket.h @@ -51,7 +51,7 @@ public: LauncherHandle *launcherHandle() const { return m_launcherHandle; } void setLauncherHandle(LauncherHandle *handle) { QMutexLocker locker(&m_mutex); m_launcherHandle = handle; } - bool waitForSignal(CallerHandle::SignalType signalType, int msecs); + bool waitForSignal(CallerHandle::SignalType signalType, QDeadlineTimer timeout); // Returns the list of flushed signals. void flush(); @@ -132,7 +132,7 @@ public: // Called from caller's thread, moved to launcher's thread afterwards. LauncherHandle(quintptr token) : m_token(token) {} // Called from caller's thread exclusively. - bool waitForSignal(CallerHandle::SignalType newSignal, int msecs); + bool waitForSignal(CallerHandle::SignalType newSignal, QDeadlineTimer timeout); CallerHandle *callerHandle() const { return m_callerHandle; } void setCallerHandle(CallerHandle *handle) { QMutexLocker locker(&m_mutex); m_callerHandle = handle; } diff --git a/src/libs/utils/process.cpp b/src/libs/utils/process.cpp index 5604b09f305..4eacb28986f 100644 --- a/src/libs/utils/process.cpp +++ b/src/libs/utils/process.cpp @@ -565,7 +565,7 @@ public: ProcessLauncherBlockingImpl(CallerHandle *caller) : m_caller(caller) {} private: - bool waitForSignal(ProcessSignalType signalType, int msecs) final + bool waitForSignal(ProcessSignalType signalType, QDeadlineTimer timeout) final { // TODO: Remove CallerHandle::SignalType const CallerHandle::SignalType type = [signalType] { @@ -580,7 +580,7 @@ private: QTC_CHECK(false); return CallerHandle::SignalType::NoSignal; }(); - return m_caller->waitForSignal(type, msecs); + return m_caller->waitForSignal(type, timeout); } CallerHandle *m_caller = nullptr; @@ -718,7 +718,7 @@ public: ProcessInterfaceHandler(GeneralProcessBlockingImpl *caller, ProcessInterface *process); // Called from caller's thread exclusively. - bool waitForSignal(ProcessSignalType newSignal, int msecs); + bool waitForSignal(ProcessSignalType newSignal, QDeadlineTimer timeout); void moveToCallerThread(); private: @@ -753,7 +753,7 @@ public: private: // Called from caller's thread exclusively - bool waitForSignal(ProcessSignalType newSignal, int msecs) final; + bool waitForSignal(ProcessSignalType newSignal, QDeadlineTimer timeout) final; QList takeAllSignals(); QList takeSignalsFor(ProcessSignalType signalType); @@ -873,13 +873,12 @@ ProcessInterfaceHandler::ProcessInterfaceHandler(GeneralProcessBlockingImpl *cal } // Called from caller's thread exclusively. -bool ProcessInterfaceHandler::waitForSignal(ProcessSignalType newSignal, int msecs) +bool ProcessInterfaceHandler::waitForSignal(ProcessSignalType newSignal, QDeadlineTimer timeout) { - QDeadlineTimer deadline(msecs); while (true) { - if (deadline.hasExpired()) + if (timeout.hasExpired()) break; - if (!doWaitForSignal(deadline)) + if (!doWaitForSignal(timeout)) break; // Matching (or Done) signal was flushed if (m_caller->flushFor(newSignal)) @@ -957,7 +956,7 @@ GeneralProcessBlockingImpl::GeneralProcessBlockingImpl(ProcessPrivate *parent) // +- ProcessInterface } -bool GeneralProcessBlockingImpl::waitForSignal(ProcessSignalType newSignal, int msecs) +bool GeneralProcessBlockingImpl::waitForSignal(ProcessSignalType newSignal, QDeadlineTimer timeout) { m_processHandler->setParent(nullptr); @@ -968,7 +967,7 @@ bool GeneralProcessBlockingImpl::waitForSignal(ProcessSignalType newSignal, int // the caller here is blocked, so all signals should be buffered and we are going // to flush them from inside waitForSignal(). m_processHandler->moveToThread(&thread); - const bool result = m_processHandler->waitForSignal(newSignal, msecs); + const bool result = m_processHandler->waitForSignal(newSignal, timeout); m_processHandler->moveToCallerThread(); m_processHandler->setParent(this); thread.quit(); @@ -1068,11 +1067,12 @@ bool ProcessPrivate::waitForSignal(ProcessSignalType newSignal, QDeadlineTimer t const bool needsSplit = m_killTimer.isActive() && timeout > currentKillTimeout; const QDeadlineTimer mainTimeout = needsSplit ? currentKillTimeout : timeout; - bool result = m_blockingInterface->waitForSignal(newSignal, mainTimeout.remainingTime()); + bool result = m_blockingInterface->waitForSignal(newSignal, + duration_cast(mainTimeout.remainingTimeAsDuration())); if (!result && needsSplit) { m_killTimer.stop(); sendControlSignal(ControlSignal::Kill); - result = m_blockingInterface->waitForSignal(newSignal, timeout.remainingTime()); + result = m_blockingInterface->waitForSignal(newSignal, timeout); } return result; } diff --git a/src/libs/utils/processinterface.h b/src/libs/utils/processinterface.h index 124a0571a00..41f68e811d8 100644 --- a/src/libs/utils/processinterface.h +++ b/src/libs/utils/processinterface.h @@ -9,6 +9,7 @@ #include "commandline.h" #include "processenums.h" +#include #include #include @@ -125,7 +126,7 @@ private: // - Started is being called only in Starting state. // - ReadyRead is being called in Starting or Running state. // - Done is being called in Starting or Running state. - virtual bool waitForSignal(ProcessSignalType signalType, int msecs) = 0; + virtual bool waitForSignal(ProcessSignalType signalType, QDeadlineTimer timeout) = 0; friend class Internal::ProcessPrivate; };