Boost logo

Boost Users :

Subject: Re: [Boost-users] A need for a complex pool type container
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2009-02-18 21:58:52


On Wed, Feb 18, 2009 at 8:54 PM, Scott McMurray <me22.ca+boost_at_[hidden]>wrote:

> Yes, you will. (I had thought you were popping tasks off the vectors
> to run them.) And be sure to keep the capacity and size of the
> circular_buffer the same, or else the rotate will start copying and
> destructing vectors.
>

Well after I construct my circular buffer, I immediately do:
schedule.resize( 100 );

This should give it a fixed size, right? And as long as I never call any of
the pop or push functions to remove/add elements, nothing should be
allocated or freed by the circular buffer, correct again?

> Of course, even on other containers you always have the option of
>
> c.push_back(vector<T>());
> swap(c.front(), c.back());
> c.pop_front();
>
> which should also avoid any allocing or freeing by the vectors.
>

I'm assuming "c" here is the circular buffer previously named "schedule"?

Won't doing a push_back() and pop_front() cause an allocation and
deallocation, respectively? the rotate() looked good because it did not
actually add or move anything from the circular buffer itself.



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