mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Thread priority to string
This commit is contained in:
@@ -37,4 +37,28 @@ namespace BlackMisc
|
||||
if (!QCoreApplication::instance()->thread()) { return false; }
|
||||
return (QCoreApplication::instance()->thread() == QThread::currentThread());
|
||||
}
|
||||
|
||||
const QString &CThreadUtils::priorityToString(QThread::Priority priority)
|
||||
{
|
||||
static const QString idle("idle");
|
||||
static const QString lowest("lowest");
|
||||
static const QString low("low");
|
||||
static const QString normal("normal");
|
||||
static const QString high("high");
|
||||
static const QString highest("highest");
|
||||
|
||||
switch (priority)
|
||||
{
|
||||
case QThread::IdlePriority: return idle;
|
||||
case QThread::LowestPriority: return lowest;
|
||||
case QThread::LowPriority: return low;
|
||||
case QThread::NormalPriority: return normal;
|
||||
case QThread::HighPriority: return high;
|
||||
case QThread::HighestPriority: return highest;
|
||||
default: break;
|
||||
}
|
||||
|
||||
static const QString unknown("unknown");
|
||||
return unknown;
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
#define BLACKMISC_CTHREADUTILS_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
class QObject;
|
||||
#include <QThread>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -38,6 +37,9 @@ namespace BlackMisc
|
||||
//! Is the current thread the Application thread?
|
||||
//! \remarks can be used as ASSERT check for threaded objects
|
||||
static bool isCurrentThreadApplicationThread();
|
||||
|
||||
//! Priority to string
|
||||
static const QString &priorityToString(QThread::Priority priority);
|
||||
};
|
||||
} // ns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user