mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-01 06:35:41 +08:00
refs #624 Use noexcept instead of Q_DECL_NOEXCEPT.
This commit is contained in:
@@ -45,7 +45,7 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
//! @{
|
//! @{
|
||||||
template <class T>
|
template <class T>
|
||||||
constexpr typename std::add_const<T>::type &as_const(T &v) Q_DECL_NOEXCEPT { return v; }
|
constexpr typename std::add_const<T>::type &as_const(T &v) noexcept { return v; }
|
||||||
template <class T>
|
template <class T>
|
||||||
void as_const(const T &&) = delete;
|
void as_const(const T &&) = delete;
|
||||||
//! @}
|
//! @}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace BlackMisc
|
|||||||
this->m_temp = other.m_temp;
|
this->m_temp = other.m_temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CStatusException::what() const Q_DECL_NOEXCEPT
|
const char *CStatusException::what() const noexcept
|
||||||
{
|
{
|
||||||
QWriteLocker lock(&this->m_lock);
|
QWriteLocker lock(&this->m_lock);
|
||||||
if (m_temp.isNull()) { m_temp = m_payload.getMessage().toLocal8Bit(); }
|
if (m_temp.isNull()) { m_temp = m_payload.getMessage().toLocal8Bit(); }
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace BlackMisc
|
|||||||
CStatusException &operator=(const CStatusException &) = delete;
|
CStatusException &operator=(const CStatusException &) = delete;
|
||||||
|
|
||||||
//! Return null-terminated message string.
|
//! Return null-terminated message string.
|
||||||
virtual const char *what() const Q_DECL_NOEXCEPT override;
|
virtual const char *what() const noexcept override;
|
||||||
|
|
||||||
//! Return the contained status message.
|
//! Return the contained status message.
|
||||||
const CStatusMessage &status() const { return m_payload; }
|
const CStatusMessage &status() const { return m_payload; }
|
||||||
|
|||||||
@@ -45,20 +45,20 @@ namespace BlackMisc
|
|||||||
QMetaObject::invokeMethod(this, "deleteLater");
|
QMetaObject::invokeMethod(this, "deleteLater");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorkerBase::waitForFinished() Q_DECL_NOEXCEPT
|
void CWorkerBase::waitForFinished() noexcept
|
||||||
{
|
{
|
||||||
std::promise<void> promise;
|
std::promise<void> promise;
|
||||||
then([ & ] { promise.set_value(); });
|
then([ & ] { promise.set_value(); });
|
||||||
promise.get_future().wait();
|
promise.get_future().wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorkerBase::abandon() Q_DECL_NOEXCEPT
|
void CWorkerBase::abandon() noexcept
|
||||||
{
|
{
|
||||||
thread()->requestInterruption();
|
thread()->requestInterruption();
|
||||||
quit();
|
quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWorkerBase::abandonAndWait() Q_DECL_NOEXCEPT
|
void CWorkerBase::abandonAndWait() noexcept
|
||||||
{
|
{
|
||||||
thread()->requestInterruption();
|
thread()->requestInterruption();
|
||||||
quitAndWait();
|
quitAndWait();
|
||||||
@@ -90,13 +90,13 @@ namespace BlackMisc
|
|||||||
thread->start(priority);
|
thread->start(priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContinuousWorker::quit() Q_DECL_NOEXCEPT
|
void CContinuousWorker::quit() noexcept
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(!CThreadUtils::isApplicationThreadObjectThread(this), Q_FUNC_INFO, "Try to stop main thread");
|
Q_ASSERT_X(!CThreadUtils::isApplicationThreadObjectThread(this), Q_FUNC_INFO, "Try to stop main thread");
|
||||||
thread()->quit();
|
thread()->quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContinuousWorker::quitAndWait() Q_DECL_NOEXCEPT
|
void CContinuousWorker::quitAndWait() noexcept
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(!CThreadUtils::isApplicationThreadObjectThread(this), Q_FUNC_INFO, "Try to stop main thread");
|
Q_ASSERT_X(!CThreadUtils::isApplicationThreadObjectThread(this), Q_FUNC_INFO, "Try to stop main thread");
|
||||||
auto *ownThread = thread();
|
auto *ownThread = thread();
|
||||||
|
|||||||
@@ -159,14 +159,14 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Blocks until the task is finished.
|
//! Blocks until the task is finished.
|
||||||
//! \threadsafe Will deadlock if called by the worker thread.
|
//! \threadsafe Will deadlock if called by the worker thread.
|
||||||
void waitForFinished() Q_DECL_NOEXCEPT;
|
void waitForFinished() noexcept;
|
||||||
|
|
||||||
//! Notify the task that its result is no longer needed, so it can finish early.
|
//! Notify the task that its result is no longer needed, so it can finish early.
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
void abandon() Q_DECL_NOEXCEPT;
|
void abandon() noexcept;
|
||||||
|
|
||||||
//! Convenience to call abandon() followed by waitForFinished().
|
//! Convenience to call abandon() followed by waitForFinished().
|
||||||
void abandonAndWait() Q_DECL_NOEXCEPT;
|
void abandonAndWait() noexcept;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Emitted when the task is finished.
|
//! Emitted when the task is finished.
|
||||||
@@ -200,8 +200,8 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void quit() Q_DECL_NOEXCEPT {}
|
virtual void quit() noexcept {}
|
||||||
virtual void quitAndWait() Q_DECL_NOEXCEPT { waitForFinished(); }
|
virtual void quitAndWait() noexcept { waitForFinished(); }
|
||||||
|
|
||||||
bool m_finished = false;
|
bool m_finished = false;
|
||||||
mutable QMutex m_finishedMutex { QMutex::Recursive };
|
mutable QMutex m_finishedMutex { QMutex::Recursive };
|
||||||
@@ -293,11 +293,11 @@ namespace BlackMisc
|
|||||||
//! Stops the thread the next time around its event loop.
|
//! Stops the thread the next time around its event loop.
|
||||||
//! The thread and the worker will then be deleted.
|
//! The thread and the worker will then be deleted.
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
virtual void quit() Q_DECL_NOEXCEPT final override;
|
virtual void quit() noexcept final override;
|
||||||
|
|
||||||
//! Calls quit() and blocks until the thread is finished.
|
//! Calls quit() and blocks until the thread is finished.
|
||||||
//! \threadsafe Will deadlock if called by the worker thread.
|
//! \threadsafe Will deadlock if called by the worker thread.
|
||||||
virtual void quitAndWait() Q_DECL_NOEXCEPT final override;
|
virtual void quitAndWait() noexcept final override;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
//! Called when the thread is started.
|
//! Called when the thread is started.
|
||||||
|
|||||||
Reference in New Issue
Block a user