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 coroutine<>::pull_type

#include <boost/coroutine2/coroutine.hpp>

template< typename R >
class coroutine<>::pull_type
{
public:
    pull_type() noexcept;

    template< typename Fn >
    pull_type( Fn && fn, attributes const& attr = attributes() );

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

    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;

    operator unspecified-bool-type() const noexcept;

    bool operator!() const noexcept;

    void swap( pull_type & other) noexcept;

    pull_type & operator()();

    R get() const;
};

template< typename R >
void swap( pull_type< R > & l, pull_type< R > & r);

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 > &);
pull_type()

Effects:

Creates a coroutine representing not-a-coroutine.

Throws:

Nothing.

template< typename Fn > pull_type( Fn && fn, attributes const& attr)

Preconditions:

size >= minimum_stacksize(), size <= maximum_stacksize() when ! is_stack_unbounded().

Effects:

Creates a coroutine which will execute fn, and enters it. Argument attr determines stack clean-up and preserving floating-point registers.

Throws:

Exceptions thrown inside coroutine-function.

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

Preconditions:

size >= minimum_stacksize(), size <= maximum_stacksize() when ! is_stack_unbounded().

Effects:

Creates a coroutine which will execute fn. Argument attr determines stack clean-up and preserving floating-point registers. 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.

operator unspecified-bool-type() const

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

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

void swap( pull_type & other)

Effects:

Swaps the internal data from *this with the values of other.

Throws:

Nothing.

Non-member function swap()
template< typename R >
void swap( pull_type< R > & l, pull_type< R > & r);

Effects:

As if 'l.swap( r)'.

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