Thread priority boosting.....
-
Can you change a thread’s priority by the thread itself?
For example, two threads, A and B, have same priority, when A is
active, I want A to boost its priority and then reset to its default
priority when done with its task. Likewise, B will do the same thread boosting.
if so, can someone provide code sample? -
Is "this":http://doc.trolltech.com/4.1/qthread.html#setPriority what you're looking for?
-
I believe you'll either want to use "that":http://doc.trolltech.com/4.1/qthread.html#setPriority indeed, or use "QThread::start()":http://doc.trolltech.com/4.1/qthread.html#start with the priority you want, depending on how you want to control things.
-
My question is:
Can a thread boost ( increase ) its own thread priority while it
is in control. Hope this clears things up.Would this psuedo code fragment work:
@
threadA(){nOldThreadPriority = this.priority();
if( bGetNextHigherPriorityAllowed( nOldThreadPriority ) )
this.setPriority( nNextHigherPriority( nOldThreadPriority ) );.........
//Reset thread priority
this.setPriority( nOldThreadPriority );
......
....}
@Again:
I just download Qt today. Still need to learn a lot more about Qt threading capabilities.
Thread priority boosting is one of common thread features I like to have for multi-threading.http://doc.trolltech.com/4.1/qthread.html#setPriority
EDIT: please sue @-tags for code highlighting, Gerolf
-
Lucas:
I ONLY want the thread to boost ITS own priority.
See my example above.Why is QDebug class not show here:
http://doc.trolltech.com/4.1/classes.html -
http://doc.trolltech.com/4.1/classes.html
wow 4.1 :) thats old.
Try assistant or http://doc.qt.nokia.com/ that is if you are not using 4.1 :) -
[quote author="hpng" date="1308245111"]Lucas:
I ONLY want the thread to boost ITS own priority.
See my example above.Why is QDebug class not show here:
http://doc.trolltech.com/4.1/classes.html[/quote]
This is excatly what the example above does.
You asked if this would work.
Compile it and if you see two different numbers then yes, it works ;-)You will find the doc for qDebug() "here":http://doc.qt.nokia.com/latest/qtglobal.html. Be sure to include the QtDebug header otherwise you won't have access to the stream operator.
-
[quote author="Andre" date="1308260525"]The reason that qDebug() is not listed between the classes, is because it isn't a class. [/quote]
Yeah but QDebug is one.
"QDebug class":http://doc.qt.nokia.com/4.7/qdebug.html