Input/Output Queues for threads: Add possibility to tweak the queue
I'm a vivid user of input/output queues for threads.
In one of my applications I'm collecting some hardware info in a thread and push that info out to the main thread. From the main thread a background function occasionally reads all values from its input queue with that thread but throws away all values except the last one (which is the most current one).
Now I'm looking for ways to get rid of the reading-all-values-until-I-got-the-last-one-scheme.
Two ways I can think of are:
- Add a threadsafe method to clear the input/ouput queue. The thread could then always clear the queue before adding a new value.
- Add a way to set the maximum number of elements of an input/output queue. Setting this to 1 would solve the issue as well.