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 a snapshot of the develop branch, built from commit 0f79ae966a.
PrevUpHomeNext

Class segmented_stack_allocator

Boost.Coroutine supports usage of a segmented-stack, e. g. the size of the stack grows on demand. The coroutine is created with a minimal stack size and will be increased as required. Class segmented_stack_allocator models the stack-allocator concept. In contrast to protected_stack_allocator and standard_stack_allocator it creates a stack which grows on demand.

[Note] Note

Segmented stacks are currently only supported by gcc from version 4.7 and clang from version 3.4 onwards. In order to use a segmented-stack Boost.Coroutine must be built with toolset=gcc segmented-stacks=on at b2/bjam command-line. Applications must be compiled with compiler-flags -fsplit-stack -DBOOST_USE_SEGMENTED_STACKS.

#include <boost/coroutine/segmented_stack_allocator.hpp>

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

    void allocate( stack_context &, std::size_t size);

    void deallocate( stack_context &);
}

typedef basic_segmented_stack_allocator< stack_traits > segmented_stack_allocator;
void allocate( stack_context & sctx, std::size_t size)

Preconditions:

traits_type::minimum_size() <= size and ! 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::minimum_size() <= sctx.size and ! traits_type::is_unbounded() && ( traits_type::maximum_size() >= sctx.size).

Effects:

Deallocates the stack space.


PrevUpHomeNext