Results 1 to 4 of 4

Thread: What's the size of Qt event queue?

  1. #1
    Join Date
    Apr 2007
    Posts
    62
    Thanks
    43
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default What's the size of Qt event queue?

    How big is Qt's event queue? Is its size customizable? What will happen to the signaler when it gets "full"?

    Example:

    I have 2 threads: thread A and thread B.

    A has a signal "Sig()" which is fired at every 1 second.

    B has a slot called "Slot()" which takes 2 seconds to process.

    I tie the 2 threads together by connecting A "Sig()" to B "Slot()"

    Obviously, things will start to queue up. I've verified this that events do get queued up even if Slot() is not keeping up.

    The question is:

    What's the behavior of the Qt event loop as time approaches infinity. =p

  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: What's the size of Qt event queue?

    Quote Originally Posted by ShaChris23 View Post
    How big is Qt's event queue? Is its size customizable?
    Its size is not limited (apart from running out of memory).

    Example:

    I have 2 threads: thread A and thread B.

    A has a signal "Sig()" which is fired at every 1 second.

    B has a slot called "Slot()" which takes 2 seconds to process.

    I tie the 2 threads together by connecting A "Sig()" to B "Slot()"

    Obviously, things will start to queue up. I've verified this that events do get queued up even if Slot() is not keeping up.
    This doesn't make much sense unless at some point you are going to stop generating requests.

    What's the behavior of the Qt event loop as time approaches infinity. =p
    Oh, that's easy to answer - there is no such thing as infinity in computer science
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2007
    Posts
    62
    Thanks
    43
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: What's the size of Qt event queue?

    Quote Originally Posted by wysota View Post
    Its size is not limited (apart from running out of memory).
    So what happens then when it runs out of memory? How would Qt notify the application programmer? Is there a way for the user to limit the queue size?

    Quote Originally Posted by wysota View Post
    This doesn't make much sense unless at some point you are going to stop generating requests.
    Yes, that was my intention for writing the example--it was so that I could have Thread1 stop generating requests eventually while Thread2 doing something else.

    Speaking of which, is my understanding correct that by using 2 threads, I have 2 independent event threads running? Thus, potentially on multi-core machines, the 2 event loops will be running on different processors?

    Quote Originally Posted by wysota View Post
    Oh, that's easy to answer - there is no such thing as infinity in computer science
    Well, reason why I said as time goes to infinity is precisely because I want to find out what happens when memory is filled up.

  4. #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: What's the size of Qt event queue?

    Quote Originally Posted by ShaChris23 View Post
    So what happens then when it runs out of memory?
    The operating system kills your application to prevent the whole machine becoming unstable.
    Is there a way for the user to limit the queue size?
    If you limited the queue size, how would the application notify you about that happening if it couldn't post an event to the queue? If your application runs out of memory because of the queue size it means it is unstable because you generate events faster than you can process them, so killing the app is fine (you would probably get an exception and/or a runtime warning).

    Yes, that was my intention for writing the example--it was so that I could have Thread1 stop generating requests eventually while Thread2 doing something else.
    You can still do that. Or you can give the producer thread a lower priority than the consumer thread.

    Speaking of which, is my understanding correct that by using 2 threads, I have 2 independent event threads running?
    If you run event loops in both of them then yes. Although they are not really independent (but they can still run in parallel).

    Thus, potentially on multi-core machines, the 2 event loops will be running on different processors?
    Potentially yes. Of course with regard to the fact that you have more than two threads in your whole system so context switching and cpu affinity will kick in.

    Well, reason why I said as time goes to infinity is precisely because I want to find out what happens when memory is filled up.
    Kaboom In C++ there is no way of telling whether an allocation will succeed or not. "new" operator never returns null (contrary to malloc). You can only catch an exception if your new operator implementation throws one.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to peek at the Event queue?
    By TheRonin in forum Qt Programming
    Replies: 3
    Last Post: 7th May 2009, 15:21
  2. Replies: 4
    Last Post: 19th February 2009, 12:10
  3. Qt event queue overloading?
    By gct in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2008, 19:39
  4. QLabel size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2007, 18:57
  5. Event Queue Question
    By TheGrimace in forum Qt Programming
    Replies: 10
    Last Post: 5th October 2007, 17:55

Tags for this Thread

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.