You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello: if the dequeue work very slowly, the queue will become bigger and bigger, is there some limit or max level for the queue? can we delete the element
The text was updated successfully, but these errors were encountered:
It sounds like you want a circular ring-buffer that supports elements being overwritten on overflow.
It is not possible to overwrite elements with my queue, however you can limit the number of elements using either the BlockingReaderWriterCircularBuffer or ReaderWriterQueue with try_enqueue (with an appropriate size passed to the constructor).
@cameron314 an overwriting circular buffer would be very useful for audio (DSP->GUI thread) visualizations, which is a fairly common scenario for me. I did think about this a fair bit and dug through the circular buffer code, but decided that while it would be cool to pop if there were no slots left during an enqueue, there's no thread safe way to do this from the producer thread. Does your answer here confirm that?
In that particular case, and when limited to scalars, I wonder if a simple array of std::atomic using the power of two mask trick for modulo would suffice 🤔
Right, not really feasible with the current design. Yes, this could be done for std::atomic integers, though the reader/writer indexes would need to be coordinated somehow.
Hello: if the dequeue work very slowly, the queue will become bigger and bigger, is there some limit or max level for the queue? can we delete the element
The text was updated successfully, but these errors were encountered: