Home | Libraries | People | FAQ | More |
#include <boost/coroutine/coroutine.hpp> template< typename Signature, typename Allocator = ctx::stack_allocator > class coroutine { public: class self_t { public: T yield( R); void yield_break(); }; coroutine(); template< typename Fn > coroutine( Fn fn, std::size_t size = ctx::default_stacksize(), flag_unwind_t do_unwind = stack_unwind, bool preserve_fpu = true, Allocator alloc = Allocator() ); template< typename Fn > coroutine( Fn && fn, std::size_t size = ctx::default_stacksize(), flag_unwind_t do_unwind = stack_unwind, bool preserve_fpu = true, Allocator alloc = Allocator() ); coroutine( coroutine && other); coroutine & operator=( coroutine && other); operator unspecified-bool-type() const; bool operator!() const; void swap( coroutine & other); bool is_complete() const; R operator()(A0 a0, ..., A9 a9); }; void swap( coroutine & l, coroutine & r);
coroutine()
Creates a coroutine representing a not-a-coroutine.
Nothing.
template< typename Fn > coroutine( Fn fn, std::size_t size, flag_unwind_t
do_unwind,
bool preserve_fpu, Allocator alloc)
size
> ctx::minimum_stacksize(),
size
< ctx::maximum_stacksize()
when ! ctx::is_stack_unbound().
Creates a coroutine which will execute fn
.
If do_unwind
is stack_unwind
the destructor of *this
unwinds the stack before destructing it. If preserve_fpu
is true
the floating-point
registers are preserved between context switches.
invalid_argument if a precondition is not satisfied.
coroutine( coroutine &&
other)
Moves the internal data of other
to *this
.
other
becomes not-a-coroutine.
Nothing.
coroutine &
operator=(
coroutine &&
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, the function returns
false. Otherwise true.
Nothing.
bool operator!() const
If *this
refers not to not-a-coroutine, the function returns
true. Otherwise false.
Nothing.
void swap( coroutine & other)
Swaps the internal data from *this
with the values of other
.
Nothing.
bool is_complete() const
*this
is not a not-a-coroutine.
Returns true
if coroutine-function
of *this
has returned.
Nothing.
R operator()(A0 a0, A9
a9)
*this
is not a not-a-coroutine, !
is_complete()
.
coroutine-function is entered and the arguments are passed to the coroutine. The return value is the argument passed to coroutine<>::self_t::yield().
coroutine_terminated if coroutine<>::self_t::yield_break() was called or other exceptions thrown inside coroutine-function.
T self_t::yield( R)
Gives execution control back to calling context by returning a value of type R. The return type of this function is a boost::tuple<> containing the arguments passed to coroutine<>::operator()().
Nothing.
void self_t::yield_break()
Gives execution control back to calling context and sets the coroutine to be complete. coroutine<>::operator()() in the other coroutine throws exception coroutine_terminated.
*this
is complete, which is is_complete()
returns true
.
swap()
void swap( coroutine & l, coroutine & r);
As if 'l.swap( r)'.