Just Intonation
Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
|
Helper class for ThreadBase. More...
#include <threadworker.h>
Signals | |
void | startTimer () |
Helper signal for starting the temporarily existing timer. More... | |
void | stopTimer () |
Helper signal for stopping the temporarily existing timer. More... | |
Public Member Functions | |
ThreadWorker (ThreadBase *threadbase) | |
Constructor. More... | |
void | setPriority (const QThread::Priority p) |
Specify the priority of the thread. More... | |
void | setTimerInterval (const int msec, const int firstMsec) |
Set timer interval in milliseconds. More... | |
void | setThreadName (const QString name) |
Set thread name. More... | |
QString | getThreadName () const |
Helper function for debugging: Get the current thread id and time. More... | |
bool | start () |
Start thread and move base class to the new thread. More... | |
bool | stop () |
Send a request to the thread for termination. More... | |
void | setVerbosity (int verbosity) |
Set the verbosity level of the class-specific messages. More... | |
int | getVerbosity () |
Get the actual verbosity level. More... | |
Private Member Functions | |
virtual void | run () override final |
Private thread worker function, starting execution loop. More... | |
void | setCurrentThreadName (QString threadname) |
Helper function for debugging: set the current thread name. More... | |
Private Attributes | |
ThreadBase * | pThreadBase |
Pointer back to the instance of the ThreadBase. More... | |
QString | mThreadName |
Assigned thread name. More... | |
QThread::Priority | mPriority |
Assigned priority of the thread. More... | |
int | mInterval |
int | mFirstInterval |
Assigned periodic waiting time in milliseconds. More... | |
Helper class for ThreadBase.
ThreadWorker is a helper class for ThreadBase. It is needed because the new thread needs to be started in an instance different from the calling instance so that the slots of the calling instance can be moved later to the thread of the new instance. This trick ensures that all slots of the calling instance (ThreadBase) are running in the newly created thread. (This is the main purpose of the whole construction)
Definition at line 44 of file threadworker.h.
ThreadWorker::ThreadWorker | ( | ThreadBase * | threadbase | ) |
Constructor.
In the constructor the parameters are reset to default values, namely, an empty thread name, normal execution priority, and a timer interval of one second.
threadbase | : Pointer back to the ThreadBase instance |
Definition at line 42 of file threadworker.cpp.
QString ThreadWorker::getThreadName | ( | ) | const |
Helper function for debugging: Get the current thread id and time.
Definition at line 244 of file threadworker.cpp.
|
inherited |
|
finaloverrideprivatevirtual |
Private thread worker function, starting execution loop.
After creation the new thread executes this function. First the timer is created. If the thread is in the suspended mode it simply waits. Otherwise the timer and the execution loop are started.
Definition at line 176 of file threadworker.cpp.
|
private |
Helper function for debugging: set the current thread name.
threadname | : QString holding the name of the thread |
Definition at line 220 of file threadworker.cpp.
void ThreadWorker::setPriority | ( | const QThread::Priority | priority | ) |
Specify the priority of the thread.
Can be used at any time, no matter whether the thread is running.
priority | : Qt priority level |
Definition at line 63 of file threadworker.cpp.
void ThreadWorker::setThreadName | ( | const QString | name | ) |
Set thread name.
name | : Name to be assigned to the thread |
Definition at line 101 of file threadworker.cpp.
void ThreadWorker::setTimerInterval | ( | const int | msec, |
const int | firstMsec | ||
) |
Set timer interval in milliseconds.
Set the timer interval at which the PeriodicallyCalledWorkerFunctiion() will be called. Has to be called before the thread starts.
msec | : Periodic waiting time in milliseconds |
firstMsec | : First waiting time in milliseconds |
Definition at line 82 of file threadworker.cpp.
|
inherited |
bool ThreadWorker::start | ( | ) |
Start thread and move base class to the new thread.
After starting the thread the instance of the base class of type ThreadBase is moved to the thread of ThreadWorker. This ensures that all slots of the base class and its derived classes are executed in the new thread.
Definition at line 121 of file threadworker.cpp.
|
signal |
Helper signal for starting the temporarily existing timer.
Since we want the timer to be executed in the new thread its instance is created temporarily from the new thread. Therefore, the slots of the timer are not always existing. This signal is simply forwarded to the timer slot.
bool ThreadWorker::stop | ( | ) |
Send a request to the thread for termination.
This function requests the thread to terminate. The user has to make sure that the implementation stops as soon as isInterruptionRequested() becomes true. The calling thread waits up to two seconds for the thread to terminate. If the thread terminates before the function returns true, otherwise it returns false.
Definition at line 158 of file threadworker.cpp.
|
signal |
Helper signal for stopping the temporarily existing timer.
Since we want the timer to be executed in the new thread its instance is created temporarily from the new thread. Therefore, the slots of the timer are not always existing. This signal is simply forwarded to the timer slot.
|
private |
Assigned periodic waiting time in milliseconds.
Definition at line 80 of file threadworker.h.
|
private |
Definition at line 80 of file threadworker.h.
|
private |
Assigned priority of the thread.
Definition at line 79 of file threadworker.h.
|
private |
Assigned thread name.
Definition at line 78 of file threadworker.h.
|
private |
Pointer back to the instance of the ThreadBase.
Definition at line 77 of file threadworker.h.