Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
threadworker.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016-2017 Karolin Stange, Christoph Wick, and Haye Hinrichsen
3  *
4  * This file is part of JustIntonation.
5  *
6  * JustIntonation is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * JustIntonation is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with JustIntonation. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 //=============================================================================
21 // Thread worker class
22 //=============================================================================
23 
24 #ifndef THREADWORKER_H
25 #define THREADWORKER_H
26 
27 #include <QThread>
28 
29 #include "log.h"
30 
31 class ThreadBase;
32 
43 
44 class ThreadWorker : public QThread, public Log
45 {
46  Q_OBJECT
47 public:
48  ThreadWorker (ThreadBase *threadbase);
49 
50  void setPriority (const QThread::Priority p);
51  void setTimerInterval (const int msec, const int firstMsec);
52  void setThreadName (const QString name);
53  QString getThreadName() const;
54 
55  bool start();
56  bool stop();
57 
58 signals:
64  void startTimer();
70  void stopTimer();
71 
72 private:
73  virtual void run() override final;
74  void setCurrentThreadName(QString threadname);
75 
76 private:
78  QString mThreadName;
79  QThread::Priority mPriority;
81 };
82 
83 #endif // THREADWORKER_H
QThread::Priority mPriority
Assigned priority of the thread.
Definition: threadworker.h:79
QString mThreadName
Assigned thread name.
Definition: threadworker.h:78
Universal base class for threaded modules.
Definition: threadbase.h:60
QString getThreadName() const
Helper function for debugging: Get the current thread id and time.
bool start()
Start thread and move base class to the new thread.
void setTimerInterval(const int msec, const int firstMsec)
Set timer interval in milliseconds.
void setPriority(const QThread::Priority p)
Specify the priority of the thread.
int mFirstInterval
Assigned periodic waiting time in milliseconds.
Definition: threadworker.h:80
virtual void run() override final
Private thread worker function, starting execution loop.
void setThreadName(const QString name)
Set thread name.
ThreadBase * pThreadBase
Pointer back to the instance of the ThreadBase.
Definition: threadworker.h:77
bool stop()
Send a request to the thread for termination.
void stopTimer()
Helper signal for stopping the temporarily existing timer.
Helper class for ThreadBase.
Definition: threadworker.h:44
void setCurrentThreadName(QString threadname)
Helper function for debugging: set the current thread name.
Base class for managing log messages.
Definition: log.h:83
ThreadWorker(ThreadBase *threadbase)
Constructor.
void startTimer()
Helper signal for starting the temporarily existing timer.