Results 1 to 11 of 11

Thread: Event Queue Question

  1. #1
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Wink Event Queue Question

    Is the event queue lossless? By which I mean if I queue up 30 signals, would they wait until the end of time to be processed?

    I am trying to write a program that will wait in a msleep loop for the front signal until a certain condition has been met, but I am worried about leaving the other 29 signals queued.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Event Queue Question

    If you don't let the queue process its events, they'll wait there. Just be aware that your application won't respond/redraw during that time.

  3. The following user says thank you to wysota for this useful post:

    TheGrimace (5th October 2007)

  4. #3
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Event Queue Question

    Well, in my case the GUI is in a separate thread from the thread that will have a waiting event loop. Does the event loop wait until a slot has finished before handling another signal? I think my logic may be flawed.

    I was thinking along these lines.

    ExampleOne objects send a string to MiddleObject which then funnels it on request to ExampleTwo objects.

    So like this:

    ExampleOne -> (string) -> MiddleObject -> (string) -> ExampleTwo

    Both ExampleOne objects and ExampleTwo objects speak to MiddleObject through signals/slots. Right now I am a little worried about a deadlock situation where a slot holds onto the thread and doesn't allow another slot to process.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Event Queue Question

    The event loop processes events sequentially. So provided that emiter and receivers are in the same thread, slots won't be run concurrently.

  6. The following user says thank you to wysota for this useful post:

    TheGrimace (5th October 2007)

  7. #5
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Event Queue Question

    As a potential solution, I was thinking the following: whenever a signal is processed, if the condition is not ready, sleep briefly and emit a signal with the same variables. My concern is that the signal would be processed as a direct connection. If I forced a queued connection would the other signals get a chance to process? Thank you for the help.

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Event Queue Question

    But what exactly is your goal?

  9. #7
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: Event Queue Question

    I am creating a thread pool to handle file processing. I get the file names from multiple threads of ExampleOne. These file names are held in a queue in MiddleObject until a signal is received from ExampleTwo (of which there might be many objects) This ExampleTwo object will then process the file and when its done ask for another.

    My concern is the ExampleTwo signals blocking the ExampleOne signals which populate the queue.

  10. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Event Queue Question

    But what do you need signals for? Isn't it better to have a wait condition so that all threads wait there until there is anything to do? You could have then a single controller object where you could store jobs and start/stop threads.

  11. #9
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Event Queue Question

    I don't think I understand. How do you transfer information across threads if not by signals/slots?

  12. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Event Queue Question

    Through a common variable.

  13. The following user says thank you to wysota for this useful post:

    TheGrimace (5th October 2007)

  14. #11
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Event Queue Question

    Ok, Thank You

Similar Threads

  1. Replies: 6
    Last Post: 21st September 2007, 13:51
  2. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05
  3. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.