mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
Improved thread info (for debugging)
This commit is contained in:
@@ -61,4 +61,18 @@ namespace BlackMisc
|
||||
static const QString unknown("unknown");
|
||||
return unknown;
|
||||
}
|
||||
|
||||
const QString CThreadUtils::threadToString(const void *t)
|
||||
{
|
||||
static const QString s("0x%1");
|
||||
return s.arg(reinterpret_cast<long long>(t), 0, 16);
|
||||
}
|
||||
|
||||
const QString CThreadUtils::currentThreadInfo()
|
||||
{
|
||||
static const QString info("thread: %1 name: '%2' priority: '%3'");
|
||||
const QThread *t = QThread::currentThread();
|
||||
if (!t) { return QString("no thread"); }
|
||||
return info.arg(threadToString(t), t->objectName(), priorityToString(t->priority()));
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -40,6 +40,12 @@ namespace BlackMisc
|
||||
|
||||
//! Priority to string
|
||||
static const QString &priorityToString(QThread::Priority priority);
|
||||
|
||||
//! Thread to int string info
|
||||
static const QString threadToString(const void *t);
|
||||
|
||||
//! Info about current thread
|
||||
static const QString currentThreadInfo();
|
||||
};
|
||||
} // ns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user