QThread::Priority for QThreadPool or QRunnable?
-
Hi, I have a class that contains it's own
QThreadPoolobject and I run instances ofQRunnableusing this thread-pool object. In my application, there are two instances of this class and for one type I want to run theQThreadPool-QRunnablecombo withQThread::HighPriorityand for another instance, I want to run it withQThread::LowPriority. Is it possible? -
See https://bugreports.qt.io/browse/QTBUG-3481 - feel free to provide a patch, doesn't look that complicated
-
See https://bugreports.qt.io/browse/QTBUG-3481 - feel free to provide a patch, doesn't look that complicated
@Christian-Ehrlicher Thanks! I am not so knowledgeable in Qt/C++ to provide a patch, but if I come up with a workaround I will definitely post it here :)
-
@Christian-Ehrlicher Thanks! I am not so knowledgeable in Qt/C++ to provide a patch, but if I come up with a workaround I will definitely post it here :)
Hi,
@CJha said in QThread::Priority for QThreadPool or QRunnable?:
@Christian-Ehrlicher Thanks! I am not so knowledgeable in Qt/C++ to provide a patch, but if I come up with a workaround I will definitely post it here :)
You do not need to have 10+ years in C++ to provide a patch. There's now one progress that you can check from the bug report. You'll see that it is not something arcane so if you would like to participate to Qt, do not hesitate to take a look at the open issues, you will likely find something suitable for you to have some fun fixing.
-
Hi,
Having your own class you can have a member variable to indicate the priority you want to set. The, when you want to start the Thread pool you can set the priority according to the member variable value.
-
Hi,
You can use this to set the priority of the current thread.
QThread::currentThread()->setPriority(QThread::HighestPriority); -
Hi,
Calling this in run method will be ok as the current thread is the thread executing the run method.