...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/coroutine/asymmetric_coroutine.hpp> template< typename R > class asymmetric_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()
Creates a coroutine representing not-a-coroutine.
Nothing.
template< typename Fn
> pull_type( Fn && fn, attributes
const&
attr)
size
>= minimum_stacksize(),
size
<= maximum_stacksize()
when ! is_stack_unbounded().
Creates a coroutine which will execute fn
,
and enters it. Argument attr
determines stack clean-up.
Exceptions thrown inside coroutine-function.
template< typename Fn, typename StackAllocator >
pull_type(
Fn &&
fn,
attributes const& attr, StackAllocator
const&
stack_alloc)
size
>= minimum_stacksize(),
size
<= maximum_stacksize()
when ! is_stack_unbounded().
Creates a coroutine which will execute fn
.
Argument attr
determines
stack clean-up. For allocating/deallocating the stack stack_alloc
is used.
Exceptions thrown inside coroutine-function.
~pull_type()
Destroys the context and deallocates the stack.
pull_type(
pull_type &&
other)
Moves the internal data of other
to *this
.
other
becomes not-a-coroutine.
Nothing.
pull_type &
operator=(
pull_type &&
other)
Destroys the internal data of *this
and moves the internal data of
other
to *this
.
other
becomes not-a-coroutine.
Nothing.
operator unspecified-bool-type() const
If *this
refers to not-a-coroutine or the coroutine-function
has returned (completed), the function returns false
.
Otherwise true
.
Nothing.
bool operator!() const
If *this
refers to not-a-coroutine or the coroutine-function
has returned (completed), the function returns true
.
Otherwise false
.
Nothing.
pull_type<>
& operator()()
*this
is not a not-a-coroutine.
Execution control is transferred to coroutine-function (no parameter is passed to the coroutine-function).
Exceptions thrown inside coroutine-function.
R get()
R asymmetric_coroutine<R,StackAllocator>::pull_type::get(); R& asymmetric_coroutine<R&,StackAllocator>::pull_type::get(); void asymmetric_coroutine<void,StackAllocator>::pull_type::get()=delete;
*this
is not a not-a-coroutine.
Returns data transferred from coroutine-function via asymmetric_coroutine<>::push_type::operator().
invalid_result
If R
is a move-only
type, you may only call get()
once before the next asymmetric_coroutine<>::pull_type::operator()
call.
void swap( pull_type
& other)
Swaps the internal data from *this
with the values of other
.
Nothing.
swap()
template< typename R > void swap( pull_type< R > & l, pull_type< R > & r);
As if 'l.swap( r)'.
begin(
pull_type<
R >
&)
template< typename R > range_iterator< pull_type< R > >::type begin( pull_type< R > &);
Returns a range-iterator (input-iterator).
end(
pull_type<
R >
&)
template< typename R > range_iterator< pull_type< R > >::type end( pull_type< R > &);
Returns an end range-iterator (input-iterator).
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 asymmetric_coroutine<>::pull_type::operator
bool would return false
.