| Home | Libraries | People | FAQ | More

### Class pooled_fixedsize_stack

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)`

Preconditions:

  `traits_type::is_unbounded() || ( traits_type::maximum_size() >= stack_size)` and `0 < next_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 much memory might be allocated for stacks — a value of zero means no upper 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.