![]() |
Home | Libraries | People | FAQ | More |
A fiber uses internally a execution_context
which manages a set of registers and a stack. The memory used by the stack
is allocated/deallocated via a stack_allocator which is
required to model a stack-allocator
concept.
A stack_allocator can be passed to fiber::fiber() or to fibers::async().
A stack_allocator must satisfy the stack-allocator
concept requirements shown in the following table, in which
a is an object of a stack_allocator
type, sctx is a stack_context, and size is a std::size_t:
|
expression |
return type |
notes |
|---|---|---|
|
|
creates a stack allocator |
|
|
|
creates a stack |
|
|
|
|
deallocates the stack created by |
![]() |
Important |
|---|---|
The implementation of |
![]() |
Important |
|---|---|
Calling |
![]() |
Note |
|---|---|
The memory for the stack is not required to be aligned; alignment takes place inside execution_context. |
See also Boost.Context stack allocation.
protected_fixedsize_stack
Boost.Fiber provides the class protected_fixedsize_stack which
models the stack-allocator
concept. It appends a guard page at the end of each stack
to protect against exceeding the stack. If the guard page is accessed (read
or write operation) a segmentation fault/access violation is generated by the
operating system.
![]() |
Important |
|---|---|
Using |
![]() |
Note |
|---|---|
The appended |
fixedsize_stack
Boost.Fiber provides the class 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 simply
managed by std::malloc()
and std::free().
segmented_stack
Boost.Fiber supports usage of a segmented_stack,
i.e. the stack grows on demand. The fiber is created with a minimal stack size
which will be increased as required. Class segmented_stack models
the stack-allocator concept.
In contrast to protected_fixedsize_stack and
fixedsize_stack it creates a stack which grows on demand.
![]() |
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 |
![]() |
Note |
|---|---|
If the library is compiled for segmented stacks, |