mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Adding priority support to GenericThread
This commit is contained in:
parent
08d1364f81
commit
63dfd570f1
3 changed files with 6 additions and 5 deletions
|
@ -23,7 +23,7 @@ const QString LOGS_DIRECTORY = "Logs";
|
|||
|
||||
class FilePersistThread : public GenericQueueThread < QString > {
|
||||
public:
|
||||
FilePersistThread(FileLogger& logger) : _logger(logger) {
|
||||
FilePersistThread(const FileLogger& logger) : _logger(logger) {
|
||||
setObjectName("LogFileWriter");
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ protected:
|
|||
return true;
|
||||
}
|
||||
private:
|
||||
FileLogger& _logger;
|
||||
const FileLogger& _logger;
|
||||
};
|
||||
|
||||
static FilePersistThread* _persistThreadInstance;
|
||||
|
@ -49,7 +49,7 @@ FileLogger::FileLogger(QObject* parent) :
|
|||
_logData("")
|
||||
{
|
||||
_persistThreadInstance = new FilePersistThread(*this);
|
||||
_persistThreadInstance->initialize(true);
|
||||
_persistThreadInstance->initialize(true, QThread::LowestPriority);
|
||||
|
||||
_fileName = FileUtils::standardPath(LOGS_DIRECTORY);
|
||||
QHostAddress clientAddress = getLocalAddress();
|
||||
|
|
|
@ -28,13 +28,14 @@ GenericThread::~GenericThread() {
|
|||
}
|
||||
}
|
||||
|
||||
void GenericThread::initialize(bool isThreaded) {
|
||||
void GenericThread::initialize(bool isThreaded, QThread::Priority priority) {
|
||||
_isThreaded = isThreaded;
|
||||
if (_isThreaded) {
|
||||
_thread = new QThread(this);
|
||||
|
||||
// match the thread name to our object name
|
||||
_thread->setObjectName(objectName());
|
||||
_thread->setPriority(priority);
|
||||
|
||||
// when the worker thread is started, call our engine's run..
|
||||
connect(_thread, SIGNAL(started()), this, SLOT(threadRoutine()));
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
/// Call to start the thread.
|
||||
/// \param bool isThreaded true by default. false for non-threaded mode and caller must call threadRoutine() regularly.
|
||||
void initialize(bool isThreaded = true);
|
||||
void initialize(bool isThreaded = true, QThread::Priority priority = QThread::NormalPriority);
|
||||
|
||||
/// Call to stop the thread
|
||||
void terminate();
|
||||
|
|
Loading…
Reference in a new issue