![]() |
Home | Libraries | People | FAQ | More |
Boost.Fiber 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/fiber/pooled_fixedsize_stack.hpp> struct pooled_fixedsize_stack { 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 &); }
pooled_fixedsize_stack(std::size_t
stack_size,
std::size_t next_size, std::size_t max_size)
traits_type::is_unbounded()
|| (
traits_type::maximum_size()
>= stack_size)
and 0
< next_size
.
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 much memory might be allocated for stacks — a value of zero
means no upper limit.
stack_context allocate()
traits_type::is_unbounded()
|| (
traits_type::maximum_size()
>= stack_size)
.
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)
sctx.sp
is valid, traits_type::is_unbounded() || ( traits_type::maximum_size() >= sctx.size)
.
Deallocates the stack space.