RunExtenstions: Remove StackSizeInBytes

It's currently not used.

Change-Id: I223a2e8add92a107b85518bcaf44bbd8a5e3fb9a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Jarek Kobus
2023-02-02 01:36:51 +01:00
parent fbcf0fb3bf
commit 84ba73be8c
3 changed files with 1 additions and 68 deletions

View File

@@ -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<ResultType> m_watcher;
};

View File

@@ -16,7 +16,6 @@
#include <QThreadPool>
#include <functional>
#include <optional>
// 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<uint>;
namespace Internal {
/*
@@ -375,12 +372,10 @@ template<typename Function,
typename... Args,
typename ResultType = typename Internal::resultType<Function>::type>
QFuture<ResultType> 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<ResultType,Function,Args...>
(std::forward<Function>(function), std::forward<Args>(args)...);
job->setThreadPriority(priority);
@@ -390,8 +385,6 @@ QFuture<ResultType> 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<ResultType>
runAsync(QThreadPool *pool, QThread::Priority priority, Function &&function, Args&&... args)
{
return Internal::runAsync_internal(pool,
StackSizeInBytes(),
priority,
std::forward<Function>(function),
std::forward<Args>(args)...);
@@ -450,47 +442,6 @@ runAsync(QThread::Priority priority, Function &&function, Args&&... args)
std::forward<Function>(function), std::forward<Args>(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<typename Function,
typename... Args,
typename ResultType = typename Internal::resultType<Function>::type>
QFuture<ResultType> runAsync(StackSizeInBytes stackSize, Function &&function, Args &&... args)
{
return Internal::runAsync_internal(static_cast<QThreadPool *>(nullptr),
stackSize,
QThread::InheritPriority,
std::forward<Function>(function),
std::forward<Args>(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<typename Function,
typename... Args,
typename ResultType = typename Internal::resultType<Function>::type>
QFuture<ResultType> runAsync(StackSizeInBytes stackSize,
QThread::Priority priority,
Function &&function,
Args &&... args)
{
return Internal::runAsync_internal(static_cast<QThreadPool *>(nullptr),
stackSize,
priority,
std::forward<Function>(function),
std::forward<Args>(args)...);
}
/*!
Runs \a function with \a args in a new thread with thread priority QThread::InheritPriority.
\sa runAsync(QThreadPool*,QThread::Priority,Function&&,Args&&...)

View File

@@ -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<int>({0, 2, 1}));
}
void tst_RunExtensions::threadSize()
{
QCOMPARE(Utils::runAsync(Utils::StackSizeInBytes(1024 * 1024), report3).results(),
QList<int>({0, 2, 1}));
}
void tst_RunExtensions::threadSizeAndPriority()
{
QCOMPARE(Utils::runAsync(Utils::StackSizeInBytes(1024 * 1024), QThread::LowestPriority, report3)
.results(),
QList<int>({0, 2, 1}));
}
void tst_RunExtensions::runAsyncNoFutureInterface()
{
// free function pointer