From: Matthew Towler (towler_at_[hidden])
Date: 2003-04-23 07:39:22
Most RTOS provide something called a 'partition pool', effectively a
fast deterministic heap of elements of a predefined size.
You then just have to write a custom allocator than just forwards to the
pool you have already created - it saves writing any complicated
An easier alternative if you know globally how many objects you will
need (rather than just how many in a given list) is to instead add new
and delete operators to the class you are going to hold, and make these
forwarding functions to the partition pool.
Allocators are usually not too bad to write, just find one in the
standard library source for your compiler and do a bit of cut and paste.
Andreas Huber wrote:
>I would like to use STL containers in a hard real-time environment. Hard
>real-time means that for all operations on the container it is possible to
>specify an upper duration limit. At some point containers have to allocate
>memory, which is notoriously non-deterministic. The usual solution is to
>preallocate for a certain maximum container-size *before* the software needs
>to react deterministically.
>With std::vector this is easy: Simply call vector::reserve(). However, there
>is no such function for all the other standard containers (deque, list, set,
>map) and I absolutely need a std::list-like container. The following
>solutions come to mind:
>- Use a custom allocator
>- Write your own list, which provides a reserve() function
>Neither is very appealing to me and I can't really believe that there is no
>easier solution within the standard library. What am I missing?
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk