Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class pooled_fixedsize_stack

Boost.Context provides the class pooled_fixedsize_stack which models the stack-allocator concept. In contrast to protected_fixedsize_stack it does not append a guard page at the end of each stack. The memory is managed internally by boost::pool<>.

#include <boost/context/pooled_fixedsize_stack.hpp>

template< typename traitsT >
struct basic_pooled_fixedsize_stack {
    typedef traitT  traits_type;

    basic_pooled_fixedsize_stack(std::size_t stack_size = traits_type::default_size(), std::size_t next_size = 32, std::size_t max_size = 0);

    stack_context allocate();

    void deallocate( stack_context &);
}

typedef basic_pooled_fixedsize_stack< stack_traits > pooled_fixedsize_stack;
basic_pooled_fixedsize_stack(std::size_t stack_size, std::size_t next_size, std::size_t max_size)

Preconditions:

! traits_type::is_unbounded() && ( traits_type::maximum:size() >= stack_size) and 0 < nest_size.

Effects:

Allocates memory of at least stack_size Bytes and stores a pointer to the stack and its actual size in sctx. Depending on the architecture (the stack grows downwards/upwards) the stored address is the highest/lowest address of the stack. Argument next_size determines the number of stacks to request from the system the first time that *this needs to allocate system memory. The third argument max_size controls how many memory might be allocated for stacks - a value of zero means no uper limit.

stack_context allocate()

Preconditions:

! traits_type::is_unbounded() && ( traits_type::maximum:size() >= stack_size).

Effects:

Allocates memory of at least stack_size Bytes and stores a pointer to the stack and its actual size in sctx. Depending on the architecture (the stack grows downwards/upwards) the stored address is the highest/lowest address of the stack.

void deallocate( stack_context & sctx)

Preconditions:

sctx.sp is valid, ! traits_type::is_unbounded() && ( traits_type::maximum:size() >= sctx.size).

Effects:

Deallocates the stack space.


PrevUpHomeNext