diff --git a/src/libs/utils/asynctask.h b/src/libs/utils/asynctask.h index e035977401b..1a6ae7d1b6a 100644 --- a/src/libs/utils/asynctask.h +++ b/src/libs/utils/asynctask.h @@ -44,13 +44,11 @@ public: void setAsyncCallData(const Function &function, const Args &...args) { m_startHandler = [=] { - return Internal::runAsync_internal(m_threadPool, m_stackSize, m_priority, - function, args...); + return Utils::runAsync(m_threadPool, m_priority, function, args...); }; } void setFutureSynchronizer(FutureSynchronizer *synchorizer) { m_synchronizer = synchorizer; } void setThreadPool(QThreadPool *pool) { m_threadPool = pool; } - void setStackSizeInBytes(const StackSizeInBytes &size) { m_stackSize = size; } void setPriority(QThread::Priority priority) { m_priority = priority; } void start() @@ -75,7 +73,6 @@ private: FutureSynchronizer *m_synchronizer = nullptr; QThreadPool *m_threadPool = nullptr; QThread::Priority m_priority = QThread::InheritPriority; - StackSizeInBytes m_stackSize = {}; QFutureWatcher m_watcher; }; diff --git a/src/libs/utils/runextensions.h b/src/libs/utils/runextensions.h index 7c7e6a8e87d..f81eb56699c 100644 --- a/src/libs/utils/runextensions.h +++ b/src/libs/utils/runextensions.h @@ -16,7 +16,6 @@ #include #include -#include // hasCallOperator & Co must be outside of any namespace // because of internal compiler error with MSVC2015 Update 2 @@ -38,8 +37,6 @@ struct hasCallOperator namespace Utils { -using StackSizeInBytes = std::optional; - namespace Internal { /* @@ -375,12 +372,10 @@ template::type> QFuture runAsync_internal(QThreadPool *pool, - StackSizeInBytes stackSize, QThread::Priority priority, Function &&function, Args &&... args) { - Q_ASSERT(!(pool && stackSize)); // stack size cannot be changed once a thread is started auto job = new Internal::AsyncJob (std::forward(function), std::forward(args)...); job->setThreadPriority(priority); @@ -390,8 +385,6 @@ QFuture runAsync_internal(QThreadPool *pool, pool->start(job); } else { auto thread = new Internal::RunnableThread(job); - if (stackSize) - thread->setStackSize(stackSize.value()); thread->moveToThread(qApp->thread()); // make sure thread gets deleteLater on main thread QObject::connect(thread, &QThread::finished, thread, &QObject::deleteLater); thread->start(priority); @@ -430,7 +423,6 @@ QFuture runAsync(QThreadPool *pool, QThread::Priority priority, Function &&function, Args&&... args) { return Internal::runAsync_internal(pool, - StackSizeInBytes(), priority, std::forward(function), std::forward(args)...); @@ -450,47 +442,6 @@ runAsync(QThread::Priority priority, Function &&function, Args&&... args) std::forward(function), std::forward(args)...); } -/*! - Runs \a function with \a args in a new thread with given thread \a stackSize and - thread priority QThread::InheritPriority . - \sa runAsync(QThreadPool*,QThread::Priority,Function&&,Args&&...) - \sa QThread::Priority - \sa QThread::setStackSize -*/ -template::type> -QFuture runAsync(StackSizeInBytes stackSize, Function &&function, Args &&... args) -{ - return Internal::runAsync_internal(static_cast(nullptr), - stackSize, - QThread::InheritPriority, - std::forward(function), - std::forward(args)...); -} - -/*! - Runs \a function with \a args in a new thread with given thread \a stackSize and - given thread \a priority. - \sa runAsync(QThreadPool*,QThread::Priority,Function&&,Args&&...) - \sa QThread::Priority - \sa QThread::setStackSize -*/ -template::type> -QFuture runAsync(StackSizeInBytes stackSize, - QThread::Priority priority, - Function &&function, - Args &&... args) -{ - return Internal::runAsync_internal(static_cast(nullptr), - stackSize, - priority, - std::forward(function), - std::forward(args)...); -} - /*! Runs \a function with \a args in a new thread with thread priority QThread::InheritPriority. \sa runAsync(QThreadPool*,QThread::Priority,Function&&,Args&&...) diff --git a/tests/auto/runextensions/tst_runextensions.cpp b/tests/auto/runextensions/tst_runextensions.cpp index 2ddea333302..50a3f8a40d6 100644 --- a/tests/auto/runextensions/tst_runextensions.cpp +++ b/tests/auto/runextensions/tst_runextensions.cpp @@ -20,8 +20,6 @@ private slots: void moveOnlyType(); #endif void threadPriority(); - void threadSize(); - void threadSizeAndPriority(); void runAsyncNoFutureInterface(); void crefFunction(); void onResultReady(); @@ -379,19 +377,6 @@ void tst_RunExtensions::threadPriority() QList({0, 2, 1})); } -void tst_RunExtensions::threadSize() -{ - QCOMPARE(Utils::runAsync(Utils::StackSizeInBytes(1024 * 1024), report3).results(), - QList({0, 2, 1})); -} - -void tst_RunExtensions::threadSizeAndPriority() -{ - QCOMPARE(Utils::runAsync(Utils::StackSizeInBytes(1024 * 1024), QThread::LowestPriority, report3) - .results(), - QList({0, 2, 1})); -} - void tst_RunExtensions::runAsyncNoFutureInterface() { // free function pointer