summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-06-02 13:09:28 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-06-05 20:57:32 +0200
commit999c79863c574bdf3e1650a1b0901fdf83a9e0b4 (patch)
tree5b681c135637d00e8ea610db84ce71ce9f263142
parent458d49861f5ab04490014f7839be0dab30c8ac61 (diff)
Remove QThreadPool::cancel()
Deprecated in 5.9 Change-Id: Ib6e2a5da1e7ee2664fb6fa496bdc880fab870901 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
-rw-r--r--src/corelib/thread/qrunnable.h2
-rw-r--r--src/corelib/thread/qthreadpool.cpp18
-rw-r--r--src/corelib/thread/qthreadpool.h4
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp77
4 files changed, 0 insertions, 101 deletions
diff --git a/src/corelib/thread/qrunnable.h b/src/corelib/thread/qrunnable.h
index 47ea00bdb0..9f8ab2a3d0 100644
--- a/src/corelib/thread/qrunnable.h
+++ b/src/corelib/thread/qrunnable.h
@@ -52,9 +52,7 @@ class Q_CORE_EXPORT QRunnable
friend class QThreadPool;
friend class QThreadPoolPrivate;
friend class QThreadPoolThread;
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Q_DISABLE_COPY(QRunnable)
-#endif
public:
virtual void run() = 0;
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index d2dcc32280..9657112abc 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -786,24 +786,6 @@ bool QThreadPool::contains(const QThread *thread) const
return d->allThreads.contains(const_cast<QThreadPoolThread *>(poolThread));
}
-#if QT_DEPRECATED_SINCE(5, 9)
-/*!
- \since 5.5
- \obsolete use tryTake() instead, but note the different deletion rules.
-
- Removes the specified \a runnable from the queue if it is not yet started.
- The runnables for which \l{QRunnable::autoDelete()}{runnable->autoDelete()}
- returns \c true are deleted.
-
- \sa start(), tryTake()
-*/
-void QThreadPool::cancel(QRunnable *runnable)
-{
- if (tryTake(runnable) && runnable->autoDelete() && !runnable->ref) // tryTake already deref'ed
- delete runnable;
-}
-#endif
-
QT_END_NAMESPACE
#include "moc_qthreadpool.cpp"
diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h
index 004f76a240..0d143574cf 100644
--- a/src/corelib/thread/qthreadpool.h
+++ b/src/corelib/thread/qthreadpool.h
@@ -95,10 +95,6 @@ public:
bool contains(const QThread *thread) const;
-#if QT_DEPRECATED_SINCE(5, 9)
- QT_DEPRECATED_X("use tryTake(), but note the different deletion rules")
- void cancel(QRunnable *runnable);
-#endif
Q_REQUIRED_RESULT bool tryTake(QRunnable *runnable);
};
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index 49ce918caf..74563a9c40 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -93,9 +93,6 @@ private slots:
void priorityStart();
void waitForDone();
void clear();
-#if QT_DEPRECATED_SINCE(5, 9)
- void cancel();
-#endif
void tryTake();
void waitForDoneTimeout();
void destroyingWaitsForTasksToFinish();
@@ -976,80 +973,6 @@ void tst_QThreadPool::clear()
QCOMPARE(count.loadRelaxed(), threadPool.maxThreadCount());
}
-#if QT_DEPRECATED_SINCE(5, 9)
-void tst_QThreadPool::cancel()
-{
- QSemaphore sem(0);
- QSemaphore startedThreads(0);
-
- class BlockingRunnable : public QRunnable
- {
- public:
- QSemaphore & sem;
- QSemaphore &startedThreads;
- QAtomicInt &dtorCounter;
- QAtomicInt &runCounter;
- int dummy;
-
- explicit BlockingRunnable(QSemaphore &s, QSemaphore &started, QAtomicInt &c, QAtomicInt &r)
- : sem(s), startedThreads(started), dtorCounter(c), runCounter(r){}
-
- ~BlockingRunnable()
- {
- dtorCounter.fetchAndAddRelaxed(1);
- }
-
- void run()
- {
- startedThreads.release();
- runCounter.fetchAndAddRelaxed(1);
- sem.acquire();
- count.ref();
- }
- };
-
- enum {
- MaxThreadCount = 3,
- OverProvisioning = 2,
- runs = MaxThreadCount * OverProvisioning
- };
-
- QThreadPool threadPool;
- threadPool.setMaxThreadCount(MaxThreadCount);
- BlockingRunnable *runnables[runs];
-
- // ensure that the QThreadPool doesn't deadlock if any of the checks fail
- // and cause an early return:
- const QSemaphoreReleaser semReleaser(sem, runs);
-
- count.storeRelaxed(0);
- QAtomicInt dtorCounter = 0;
- QAtomicInt runCounter = 0;
- for (int i = 0; i < runs; i++) {
- runnables[i] = new BlockingRunnable(sem, startedThreads, dtorCounter, runCounter);
- runnables[i]->setAutoDelete(i != 0 && i != (runs-1)); //one which will run and one which will not
- threadPool.cancel(runnables[i]); //verify NOOP for jobs not in the queue
- threadPool.start(runnables[i]);
- }
- // wait for all worker threads to have started up:
- QVERIFY(startedThreads.tryAcquire(MaxThreadCount, 60*1000 /* 1min */));
-
- for (int i = 0; i < runs; i++) {
- threadPool.cancel(runnables[i]);
- }
- runnables[0]->dummy = 0; //valgrind will catch this if cancel() is crazy enough to delete currently running jobs
- runnables[runs-1]->dummy = 0;
- QCOMPARE(dtorCounter.loadRelaxed(), runs - threadPool.maxThreadCount() - 1);
- sem.release(threadPool.maxThreadCount());
- threadPool.waitForDone();
- QCOMPARE(runCounter.loadRelaxed(), threadPool.maxThreadCount());
- QCOMPARE(count.loadRelaxed(), threadPool.maxThreadCount());
- QCOMPARE(dtorCounter.loadRelaxed(), runs - 2);
- delete runnables[0]; //if the pool deletes them then we'll get double-free crash
- delete runnables[runs-1];
-}
-#endif
-
void tst_QThreadPool::tryTake()
{
QSemaphore sem(0);