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. QEvent, QEventLoop, batch process events?
QtWS25 Last Chance

QEvent, QEventLoop, batch process events?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qeventqeventloop
8 Posts 3 Posters 1.1k Views
  • 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.
  • D Offline
    D Offline
    Dariusz
    wrote on 7 Nov 2019, 05:56 last edited by
    #1

    Hey!

    So I'm working on a worker process for my app. I decided to use QEvents as I can configure their priority and "control" what gets executed in what order - more or less thanks to priority.

    One thing I would like to do is to push an update function after certain jobs have finished.

    say I have low priority jobs, once all of them get processed I would like to push "update" function, whereas if I send priority jobs I would like to push "update" after each event gets processed...

    Pushing update for high priority jobs seems easy, I just add the "update" call to the priority event, but when it comes to "low priority", I'm not sure how to batch group them and update?

    How can I approach it?

    TIA

    J 1 Reply Last reply 7 Nov 2019, 08:09
    0
    • D Dariusz
      7 Nov 2019, 05:56

      Hey!

      So I'm working on a worker process for my app. I decided to use QEvents as I can configure their priority and "control" what gets executed in what order - more or less thanks to priority.

      One thing I would like to do is to push an update function after certain jobs have finished.

      say I have low priority jobs, once all of them get processed I would like to push "update" function, whereas if I send priority jobs I would like to push "update" after each event gets processed...

      Pushing update for high priority jobs seems easy, I just add the "update" call to the priority event, but when it comes to "low priority", I'm not sure how to batch group them and update?

      How can I approach it?

      TIA

      J Offline
      J Offline
      JonB
      wrote on 7 Nov 2019, 08:09 last edited by
      #2

      @Dariusz
      I'm not sure either! Not sure how you mean you can "configure their priority and "control" what gets executed in what order". Priority must be something you are adding.

      but when it comes to "low priority", I'm not sure how to batch group them and update?

      The obvious would be to put your events on some sort of queue, or different queues according to priority. Process higher priority queues before lower priority ones. When, say, the higher priority queue is empty you can then decide to process all events in lower priority queue. When that queue becomes empty that's how you know you have processed them all.

      ?

      D 1 Reply Last reply 7 Nov 2019, 17:31
      1
      • J JonB
        7 Nov 2019, 08:09

        @Dariusz
        I'm not sure either! Not sure how you mean you can "configure their priority and "control" what gets executed in what order". Priority must be something you are adding.

        but when it comes to "low priority", I'm not sure how to batch group them and update?

        The obvious would be to put your events on some sort of queue, or different queues according to priority. Process higher priority queues before lower priority ones. When, say, the higher priority queue is empty you can then decide to process all events in lower priority queue. When that queue becomes empty that's how you know you have processed them all.

        ?

        D Offline
        D Offline
        Dariusz
        wrote on 7 Nov 2019, 17:31 last edited by
        #3

        @JonB Sound about right but I don't control the queue. Its done by Qt, QEventLoop queue, but in my case QThread/QObject queue that I run. So far I was thinking that I could do some wacky local object based filtering to decide when to do what but not sure....

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 7 Nov 2019, 19:44 last edited by
          #4

          Hi,

          Out of curiosity, shouldn't you rather use a state machine to model that ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          D 1 Reply Last reply 8 Nov 2019, 18:57
          0
          • S SGaist
            7 Nov 2019, 19:44

            Hi,

            Out of curiosity, shouldn't you rather use a state machine to model that ?

            D Offline
            D Offline
            Dariusz
            wrote on 8 Nov 2019, 18:57 last edited by
            #5

            @SGaist Except openGL I don't really know of them. Will google it a bit.

            On a side note, is there a way to find out size of current thread/object queue ? I read some stack overflow ideas where I can export
            extern uint qGlobalPostedEventsCount();
            To get it, but I'm not sure if it returns global thread event count or local thread as explanation was a bit confusing...

            So far I was able to specify/control batching in my local obejct which is awesome. But I just need to know the size of queue to determine number of updates during the processing time... Any hints? Could really use object::getPostEventQueueSize() as well as something like. object::clearPostEventQueue() to cancel all signals.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 8 Nov 2019, 21:20 last edited by
              #6

              A search in the documentation should be enough ;-)
              See here.

              As for the QEventLoop, no there's not. It's internal implementation details that may change at any time.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              D 1 Reply Last reply 8 Nov 2019, 22:40
              0
              • S SGaist
                8 Nov 2019, 21:20

                A search in the documentation should be enough ;-)
                See here.

                As for the QEventLoop, no there's not. It's internal implementation details that may change at any time.

                D Offline
                D Offline
                Dariusz
                wrote on 8 Nov 2019, 22:40 last edited by
                #7

                @SGaist Woah Qt has a state machine! Amazing :O

                As to getting queue size, how come that is not exposed? Would it not be helpfull for user to know how many actions/functions are waiting to be processed?

                TIA

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 9 Nov 2019, 20:25 last edited by
                  #8

                  Even two if you take the QtScxml module.

                  Well, I am not behind the design of the system so I can just offer some thoughts. I would say that if you need that level of control of the event loop, you might not be using the right tool for your use case.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  8/8

                  9 Nov 2019, 20:25

                  • Login

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