QThreadPool: let the started thread have the same name as the pool
If the pool has a name. This should make identifying threads belonging to different pools easier in process-inspection tools. Fixes: QTBUG-92004 Change-Id: Id2983978ad544ff79911fffd167225902efeb855 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This commit is contained in:
parent
33786e7b02
commit
451fb66212
@ -257,9 +257,15 @@ bool QThreadPoolPrivate::tooManyThreadsActive() const
|
|||||||
*/
|
*/
|
||||||
void QThreadPoolPrivate::startThread(QRunnable *runnable)
|
void QThreadPoolPrivate::startThread(QRunnable *runnable)
|
||||||
{
|
{
|
||||||
|
Q_Q(QThreadPool);
|
||||||
Q_ASSERT(runnable != nullptr);
|
Q_ASSERT(runnable != nullptr);
|
||||||
QScopedPointer<QThreadPoolThread> thread(new QThreadPoolThread(this));
|
QScopedPointer<QThreadPoolThread> thread(new QThreadPoolThread(this));
|
||||||
thread->setObjectName(QLatin1String("Thread (pooled)"));
|
QString objectName;
|
||||||
|
if (QString myName = q->objectName(); !myName.isEmpty())
|
||||||
|
objectName = myName;
|
||||||
|
else
|
||||||
|
objectName = QLatin1String("Thread (pooled)");
|
||||||
|
thread->setObjectName(objectName);
|
||||||
Q_ASSERT(!allThreads.contains(thread.data())); // if this assert hits, we have an ABA problem (deleted threads don't get removed here)
|
Q_ASSERT(!allThreads.contains(thread.data())); // if this assert hits, we have an ABA problem (deleted threads don't get removed here)
|
||||||
allThreads.insert(thread.data());
|
allThreads.insert(thread.data());
|
||||||
++activeThreads;
|
++activeThreads;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user