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 an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class continuation

#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;
};

Constructor

continuation() noexcept;

Effects:

Creates a invalid continuation.

Throws:

Nothing.

Destructor

~continuation();

Effects:

Destructs the associated stack if *this is a valid continuation, e.g. continuation::operator bool() returns true.

Throws:

Nothing.

Move constructor

continuation(continuation && other) noexcept;

Effects:

Moves underlying capture continuation to *this.

Throws:

Nothing.

Move assignment operator

continuation & operator=(continuation && other) noexcept;

Effects:

Moves the state of other to *this using move semantics.

Throws:

Nothing.

Member function operator()()

continuation resume();

template<typename Fn>
continuation resume_with(Fn && fn);

Effects:

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

Returns:

The continuation representing the continuation that has been suspended.

Note:

Function fn needs to return continuation.

Note:

The returned continuation indicates if the suspended continuation has terminated (return from context-function) via bool operator().

Member function operator bool()

explicit operator bool() const noexcept;

Returns:

true if *this points to a captured continuation.

Throws:

Nothing.

Member function operator!()

bool operator!() const noexcept;

Returns:

true if *this does not point to a captured continuation.

Throws:

Nothing.

Member function operator==()

bool operator==(continuation const& other) const noexcept;

Returns:

true if *this and other represent the same continuation, false otherwise.

Throws:

Nothing.

Member function operator!=()

bool operator!=(continuation const& other) const noexcept;

Returns:

! (other == * this)

Throws:

Nothing.

Member function operator<()

bool operator<(continuation const& other) const noexcept;

Returns:

true if *this != other is true and the implementation-defined total order of continuation values places *this before other, false otherwise.

Throws:

Nothing.

Member function operator>()

bool operator>(continuation const& other) const noexcept;

Returns:

other < * this

Throws:

Nothing.

Member function operator<=()

bool operator<=(continuation const& other) const noexcept;

Returns:

! (other < * this)

Throws:

Nothing.

Member function operator>=()

bool operator>=(continuation const& other) const noexcept;

Returns:

! (* this < other)

Throws:

Nothing.

Non-member function operator<<()

template<typename charT,class traitsT>
std::basic_ostream<charT,traitsT> &
operator<<(std::basic_ostream<charT,traitsT> & os,continuation const& other);

Effects:

Writes the representation of other to stream os.

Returns:

os

Call with current continuation
#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);

Effects:

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.

Returns:

The continuation representing the contexcontinuation that has been suspended.

Note:

The returned continuation indicates if the suspended continuation has terminated (return from context-function) via bool operator().


PrevUpHomeNext