title: How to Compress Slot Calls When Using Queued Connection in Qt?
body: <p>After reading some articles <a href="https://qt-project.org/doc/qt-5/threads-qobject.html">like this</a> about Qt Signal-Slot communications I still have a question concerning the queued connection.</p>
  
  <p>If I have some threads sending signals all the time to each other and lets say one <code>thread_slow</code>is running a slow method in it's event loop and another <code>thread_fast</code> is running a fast one that sends multiple signals while the other thread is still running it's slow method.....when the slow method from <code>thread_slow</code> returns to the event loop, will it process all the signals that were sent before by <code>thread_fast</code>or just the last one (all the signals are the same type)? </p>
  
  <p>If it will process all the signals, is it there a way to make the <code>thread_slow</code> <strong>only process the last one</strong>? (Considering "the last one" in a multithread application might be vague, let's consider the last signal before the thread asked for the last signal, for the sake of simplicity, so new ones being sent while the thread looks for the last might be lost).</p>
  
  <p>(I am asking this because I have multiple threads receiving data from multiple threads, and I dont want them to process old data, just the last one that was sent)</p>
  
  <p>I have run some tests, and it appears that Qt will process all the signals. I made one thread do:</p>
  
  <pre><code>while(true)
  {
      QThread::msleep(500);
      emit testQueue(test);
      test++;
  }
  </code></pre>
  
  <p>and a slot in another will do:</p>
  
  <pre><code>void test::testQueue(int test)
  {
      test.store(private_test.load() + test);
      emit testText(QString("Test Queue: ") + QString::number(private_test.load()));
  }
  </code></pre>
  
  <p>and the thread will run:</p>
  
  <pre><code>while(true)
  {
      QThread::msleep(3000);
      QCoreApplication::processEvents();
      private_test.store(private_test.load() + 1000);
  }
  </code></pre>
  
  <p>I am sending a signal from one thread to the other every 500 milliseconds, and the other thread sleeps for 3000 milliseconds (3 seconds) and then wakes up and increment an internal variable by 100. every time the slot is executed it emits a text with the value received + the internal variable. The result I am having is that every time  <code>QCoreApplication::processEvents();</code> is called, all signals are executed....(I edited this part because I found a bug in my previous code) </p>