On 04/22/2015 06:22 AM, Lane wrote:
I like the idea of using a circular_buffer, but still not sure how to time the data on this buffer. I'd like for objects on this buffer to be removed after n seconds, and not based on fixed capacity where they get
Your understanding of circular_buffer is correct, but IIUC you wish to throttle the rate of objects per time, so it makes more sense to limit the number of objects in the queue than the time interval. This is also significantly easier to implement.
over-written. Or did I misunderstand? I think somehow attaching a timer to each and every object on this buffer is the part I'm having trouble with efficiently.
As others have already mentioned, you can simply leave them in the queue and let the consumer discard outdated objects when they are extracted.