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.Coroutine2 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/coroutine2/pooled_fixedsize_stack.hpp>

struct pooled_fixedsize_stack {
    pooled_fixedsize_stack(std::size_t size = traits_type::default_size());

    stack_context allocate();

    void deallocate( stack_context &);
}
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() >= size).

Effects:

Allocates memory of at least 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