Thread priority to string

This commit is contained in:
Klaus Basan
2018-08-21 15:12:06 +02:00
parent b4946bc46d
commit d3c3fe2566
2 changed files with 28 additions and 2 deletions

View File

@@ -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

View File

@@ -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