Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6804531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:28:38+00:00 2026-05-26T19:28:38+00:00

What would be a good way to solve the following problem in Qt: I

  • 0

What would be a good way to solve the following problem in Qt:

I have a sensor class, which continuously produces data. On this data, several operations have to be performed after another, which may take quite long. For this I have some additional classes. Basically, every time a new data item is recorded, the first class should get the data, process it, pass it to the next and so on.

sensor –> class 1 –> … –> last class

I want to put the individual classes of the pipeline into their own threads, so that class 1 may already work on sample n+1 when class 2 is processing sample n…

Also, as the individual steps may differ greatly in their performance (e.g. the sensor is way faster than the rest) and I’m not interested in outdated data, I want class 1 (and everything after it) to always get the newest data from their predecessor, discarding old data. So, no big buffer between the steps of the pipeline.

First I thought about using Qt::QueuedConnections for signals/slots, but I guess that this would introduce a queue full of outdated samples waiting to be processed by the slower parts of the pipeline?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:28:39+00:00Added an answer on May 26, 2026 at 7:28 pm

    What you are dealing with is a Producer Consumer Pattern. You can find a general overview of that here. http://en.wikipedia.org/wiki/Producer-consumer_problem

    You want to use a QMutex to limit access to the data to one thread at a time. Use the QMutexLocker to lock it.

    For a VERY simplified example:

    QList<quint32> data;
    QMutex mutex;
    
    //  Consumer Thread calls this
    int GetData()
    {
       quint32 result(-1); // if =1 is a valid value, you may have to return a bool and 
                           // get the value through a reference to an int 
                           // in the parameter list.
    
       QMutexLocker lock(&mutex);
    
       if (data.size())
       {
          result = data.front();  // or back
          data.clear();
       }
    
       return result;
    }
    
    // Producer Thread calls this
    void SetData(quint32 value)
    {
        QMutexLocker lock(&mutex);
    
        data.push_back(value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wondering what the best / good way of doing this would be in jQuery.
What would be a good way to determine if a string contains an IPv4
What would be a good way to writein C# a .NET3.5 Thread Safe DataSource
What is a good way to represent finite automaton in Haskell? How would the
I have some useful wpf buttons to test some functionality. It would be good
Two good examples would be google and facebook . I have lately pondered the
I would like to know if the following code would be a good pattern
This question is more a semantic-algorithmic-data-structure question than a F# syntactically question. I have
I've got a slightly tricky problem to solve; imagine this: One of my applications
I have a question regarding good design in C++. I have a class A

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.