Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Thread priority boosting.....
Forum Updated to NodeBB v4.3 + New Features

Thread priority boosting.....

Scheduled Pinned Locked Moved General and Desktop
11 Posts 6 Posters 7.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HuXiKa
    wrote on last edited by
    #2

    Is "this":http://doc.trolltech.com/4.1/qthread.html#setPriority what you're looking for?

    If you can find faults of spelling in the text above, you can keep them.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hpng
      wrote on last edited by
      #3

      I am new to Qt. So I am not sure.
      If it allows a thread to set its own priority, then,
      this is what I am looking for.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #4

        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.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hpng
          wrote on last edited by
          #5

          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

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lgeyer
            wrote on last edited by
            #6

            @
            #include <QtCore/QThread>
            #include <QtDebug>

            int main(...)
            {
            ...
            qDebug() << QThread::currentThread()->priority();
            QThread::currentThread()->setPriority(QThread::HighPriority);
            qDebug() << QThread::currentThread()->priority();
            ...
            }
            @

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hpng
              wrote on last edited by
              #7

              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

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kkrzewniak
                wrote on last edited by
                #8

                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 :)

                Me, Grimlock, not "nice dino". ME BASH BRAINS!

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  lgeyer
                  wrote on last edited by
                  #9

                  [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.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #10

                    -The reason that qDebug() is not listed between the classes, is because it isn't a class.- Never mind, corrected below. Note to self: don't post to the DevNet forum if you are tired and come directly from a Trollband performance.

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kkrzewniak
                      wrote on last edited by
                      #11

                      [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

                      Me, Grimlock, not "nice dino". ME BASH BRAINS!

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved