Results 1 to 3 of 3

Thread: Limit queue size of Qt::QueuedConnection

  1. #1
    Join Date
    May 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Limit queue size of Qt::QueuedConnection

    Hey,

    I have a very simple question which seems to be complicated to solve. Google didn't help me, so here is my problem:

    I have a camera thread which is constantly emitting a signal with the current picture at 29Hz.
    Also, I have a worker within a worker thread which should receive the picture and process it somehow.

    My current implementation of the worker can process frames at ~5-10Hz. Since I don't care about every single frame I want the worker to process always the most recent frame.
    I also want the threads to be completely independent, so I can't use Qt:irectConnection (which is thread-wise stupid anyways) and I don't want the worker to poll a picture once it is done processing.

    Is there any way to limit the queue size to contain only one element which is the most recent one?

    Thank you in advance!

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Limit queue size of Qt::QueuedConnection

    In slot connected to signal from camera only append new picture to some list. After that start method processing pictures with QTimer::singleShot. Signals from QTimer are serviced after all another signals. In this method do the work of the last picture and clear the list. Remember to synchronize by semaphores.

  3. #3
    Join Date
    May 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Limit queue size of Qt::QueuedConnection

    Thank you, I will try that!

Similar Threads

  1. Event queue size
    By naroin in forum Qt Programming
    Replies: 7
    Last Post: 29th November 2010, 14:26
  2. Purging the queue in a Qt::QueuedConnection
    By Eos Pengwern in forum Qt Programming
    Replies: 2
    Last Post: 3rd November 2010, 18:32
  3. What's the size of Qt event queue?
    By ShaChris23 in forum Qt Programming
    Replies: 3
    Last Post: 6th November 2009, 18:54
  4. How to limit the size of QLineEdit?
    By MIH1406 in forum Qt Programming
    Replies: 6
    Last Post: 30th September 2009, 13:10
  5. QVBoxLayout width size limit
    By QPlace in forum Qt Programming
    Replies: 7
    Last Post: 18th June 2009, 17:41

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.