Boost logo

Boost Users :

Subject: Re: [Boost-users] sliding window containing n seconds of data
From: Bjorn Reese (breese_at_[hidden])
Date: 2015-04-22 06:41:57


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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net