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 a snapshot of the develop branch, built from commit 0f79ae966a.
PrevUpHomeNext

Class coroutine<>::pull_type

#include <boost/coroutine2/coroutine.hpp>

template< typename R >
class coroutine<>::pull_type
{
public:
    template< typename Fn >
    pull_type( Fn && fn);

    template< typename StackAllocator, typename Fn >
    pull_type( StackAllocator stack_alloc, Fn && fn);

    pull_type( pull_type const& other)=delete;

    pull_type & operator=( pull_type const& other)=delete;

    ~pull_type();

    pull_type( pull_type && other) noexcept;

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

    pull_coroutine & operator()();

    explicit operator bool() const noexcept;

    bool operator!() const noexcept;

    R get() noexcept;
};

template< typename R >
range_iterator< pull_type< R > >::type begin( pull_type< R > &);

template< typename R >
range_iterator< pull_type< R > >::type end( pull_type< R > &);
template< typename Fn > pull_type( Fn && fn)

Effects:

Creates a coroutine which will execute fn, and enters it.

Throws:

Exceptions thrown inside coroutine-function.

template< typename StackAllocator, typename Fn > pull_type( StackAllocator const& stack_alloc, Fn && fn)

Effects:

Creates a coroutine which will execute fn. For allocating/deallocating the stack stack_alloc is used.

Throws:

Exceptions thrown inside coroutine-function.

~pull_type()

Effects:

Destroys the context and deallocates the stack.

pull_type( pull_type && other)

Effects:

Moves the internal data of other to *this. other becomes not-a-coroutine.

Throws:

Nothing.

pull_type & operator=( pull_type && other)

Effects:

Destroys the internal data of *this and moves the internal data of other to *this. other becomes not-a-coroutine.

Throws:

Nothing.

explicit operator bool() const noexcept

Returns:

If *this refers to not-a-coroutine or the coroutine-function has returned (completed), the function returns false. Otherwise true.

Throws:

Nothing.

bool operator!() const noexcept

Returns:

If *this refers to not-a-coroutine or the coroutine-function has returned (completed), the function returns true. Otherwise false.

Throws:

Nothing.

pull_type<> & operator()()

Preconditions:

*this is not a not-a-coroutine.

Effects:

Execution control is transferred to coroutine-function (no parameter is passed to the coroutine-function).

Throws:

Exceptions thrown inside coroutine-function.

R get() noexcept
R    coroutine<R,StackAllocator>::pull_type::get();
R&   coroutine<R&,StackAllocator>::pull_type::get();
void coroutine<void,StackAllocator>::pull_type::get()=delete;

Preconditions:

*this is not a not-a-coroutine.

Returns:

Returns data transferred from coroutine-function via coroutine<>::push_type::operator().

Throws:

invalid_result

Note:

If R is a move-only type, you may only call get() once before the next coroutine<>::pull_type::operator() call.

Non-member function begin( pull_type< R > &)
template< typename R >
range_iterator< pull_type< R > >::type begin( pull_type< R > &);

Returns:

Returns a range-iterator (input-iterator).

Non-member function end( pull_type< R > &)
template< typename R >
range_iterator< pull_type< R > >::type end( pull_type< R > &);

Returns:

Returns an end range-iterator (input-iterator).

Note:

When first obtained from begin( pull_type< R > &), or after some number of increment operations, an iterator will compare equal to the iterator returned by end( pull_type< R > &) when the corresponding coroutine<>::pull_type::operator bool would return false.


PrevUpHomeNext