diff --git a/src/blackmisc/threadutils.cpp b/src/blackmisc/threadutils.cpp index 87005b28c..3b65d9919 100644 --- a/src/blackmisc/threadutils.cpp +++ b/src/blackmisc/threadutils.cpp @@ -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 diff --git a/src/blackmisc/threadutils.h b/src/blackmisc/threadutils.h index 8da499228..30aa9bb04 100644 --- a/src/blackmisc/threadutils.h +++ b/src/blackmisc/threadutils.h @@ -13,8 +13,7 @@ #define BLACKMISC_CTHREADUTILS_H #include "blackmisc/blackmiscexport.h" - -class QObject; +#include 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