...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
#include <boost/context/continuation.hpp> class continuation { public: continuation() noexcept = default; ~continuation(); continuation(continuation && other) noexcept; continuation & operator=(continuation && other) noexcept; continuation(continuation const& other) noexcept = delete; continuation & operator=(continuation const& other) noexcept = delete; continuation resume(); template<typename Fn> continuation resume_with(Fn && fn); explicit operator bool() const noexcept; bool operator!() const noexcept; bool operator==(continuation const& other) const noexcept; bool operator!=(continuation const& other) const noexcept; bool operator<(continuation const& other) const noexcept; bool operator>(continuation const& other) const noexcept; bool operator<=(continuation const& other) const noexcept; bool operator>=(continuation const& other) const noexcept; template<typename charT,class traitsT> friend std::basic_ostream<charT,traitsT> & operator<<(std::basic_ostream<charT,traitsT> & os,continuation const& other) { void swap(continuation & other) noexcept; };
continuation() noexcept;
Creates a invalid continuation.
Nothing.
~continuation();
Destructs the associated stack if *this
is a valid continuation, e.g.
continuation::operator bool() returns true
.
Nothing.
continuation(continuation && other) noexcept;
Moves underlying capture continuation to *this
.
Nothing.
continuation & operator=(continuation && other) noexcept;
Moves the state of other
to *this
using move semantics.
Nothing.
operator()
()
continuation resume(); template<typename Fn> continuation resume_with(Fn && fn);
Captures current continuation and resumes *this
. The function resume_with
,
is used to execute function fn
in the execution context of *this
(e.g. the stack frame of fn
is allocated on stack of *this
).
The continuation representing the continuation that has been suspended.
Function fn
needs to
return continuation
.
The returned continuation indicates if the suspended continuation has
terminated (return from context-function) via bool
operator()
.
operator bool
()
explicit operator bool() const noexcept;
true
if *this
points to a captured continuation.
Nothing.
operator!
()
bool operator!() const noexcept;
true
if *this
does not point to a captured continuation.
Nothing.
operator==
()
bool operator==(continuation const& other) const noexcept;
true
if *this
and other
represent
the same continuation, false
otherwise.
Nothing.
operator!=
()
bool operator!=(continuation const& other) const noexcept;
! (other == * this)
Nothing.
operator<
()
bool operator<(continuation const& other) const noexcept;
true
if *this != other
is true and the implementation-defined total order of continuation
values places *this
before other
, false
otherwise.
Nothing.
operator>
()
bool operator>(continuation const& other) const noexcept;
other <
* this
Nothing.
operator<=
()
bool operator<=(continuation const& other) const noexcept;
! (other <
* this)
Nothing.
operator>=
()
bool operator>=(continuation const& other) const noexcept;
! (*
this <
other)
Nothing.
operator<<()
template<typename charT,class traitsT> std::basic_ostream<charT,traitsT> & operator<<(std::basic_ostream<charT,traitsT> & os,continuation const& other);
Writes the representation of other
to stream os
.
os
#include <boost/context/continuation.hpp> template<typename Fn> continuation callcc(Fn && fn); template<typename StackAlloc,typename Fn> continuation callcc(std::allocator_arg_t,StackAlloc salloc,Fn && fn); template<typename StackAlloc,typename Fn> continuation callcc(std::allocator_arg_t,preallocated palloc,StackAlloc salloc,Fn && fn);
Captures current continuation and creates a new continuation prepared
to execute fn
. fixedsize_stack
is used as default
stack allocator (stack size == fixedsize_stack::traits::default_size()).
The function with argument type preallocated
,
is used to create a user defined data (for
instance additional control structures) on top of the stack.
The continuation representing the contexcontinuation that has been suspended.
The returned continuation indicates if the suspended continuation has
terminated (return from context-function) via bool
operator()
.