Boost C++ Libraries Home Libraries People FAQ More

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;

    template<typename ...Arg>
    continuation resume(Arg ...arg);

    template<typename Fn,typename ...Arg>
    continuation resume_with(Fn && fn,Arg ...arg);

    bool data_available() noexcept;

    template<typename ...Arg>
    <unspecified> get_data();

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

template<typename ...Arg>
continuation resume(Arg ...arg);

template<typename Fn,typename ...Arg>
continuation resume_with(Fn && fn,Arg ...arg);

Effects:

Captures current continuation and resumes *this. The function with argument type exec_ontop_arg, is used to execute function fn in continuation *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:

The returned arguments from fn are passed as arguments to the context-function of resumed continuation.

Note:

Function fn needs to return a tuple of arguments (see description).

Note:

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

Member function data_available()

bool data_available() noexcept;

Effects:

Tests if c has data.

Returns:

true if data have been transferred, otherwise false.

Throws:

Nothing.

Member function get_available()

template<typename ...Arg>
<unspecified> get_data();

Returns:

Data that have been transferred via callcc() or operator() are returned as std::tuple<Arg...> or Arg if single parameter.

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,typename ...Arg>
continuation callcc(Fn && fn,Arg ...arg);

template<typename StackAlloc,typename Fn,typename ...Arg>
continuation callcc(std::allocator_arg_t,StackAlloc salloc,Fn && fn,Arg ...arg);

template<typename StackAlloc,typename Fn,typename ...Arg>
continuation callcc(std::allocator_arg_t,preallocated palloc,StackAlloc salloc,Fn && fn,Arg ...arg);

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. The arguments, ... arg, are passed to the current continuation to be transferred by the call to callcc() in the same thread.

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(). If the returned continuation has terminated no data are transferred.


PrevUpHomeNext