fiber::resume() and fiber::resume_with() are rvalue-ref qualified only

This commit is contained in:
Oliver Kowalke 2018-02-09 17:29:02 +01:00
parent 5243bfef42
commit fc3cb67527
2 changed files with 31 additions and 31 deletions

View File

@ -67,7 +67,7 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc,
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back // jump back
return other->c.resume(); return std::move( other->c).resume();
}, },
std::forward< Fn >( fn) ) }, std::forward< Fn >( fn) ) },
#else #else
@ -92,7 +92,7 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc,
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back // jump back
return other->c.resume(); return std::move( other->c).resume();
} }, } },
#endif #endif
other{ nullptr }, other{ nullptr },
@ -100,7 +100,7 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc,
except{}, except{},
bvalid{ false }, bvalid{ false },
storage{} { storage{} {
c = c.resume(); c = std::move( c).resume();
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -136,7 +136,7 @@ pull_coroutine< T >::control_block::deallocate() noexcept {
template< typename T > template< typename T >
void void
pull_coroutine< T >::control_block::resume() { pull_coroutine< T >::control_block::resume() {
c = c.resume(); c = std::move( c).resume();
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -215,7 +215,7 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back // jump back
return other->c.resume(); return std::move( other->c).resume();
}, },
std::forward< Fn >( fn) ) }, std::forward< Fn >( fn) ) },
#else #else
@ -240,7 +240,7 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back // jump back
return other->c.resume(); return std::move( other->c).resume();
} }, } },
#endif #endif
other{ nullptr }, other{ nullptr },
@ -248,7 +248,7 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo
except{}, except{},
bvalid{ false }, bvalid{ false },
storage{} { storage{} {
c = c.resume(); c = std::move( c).resume();
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -276,7 +276,7 @@ pull_coroutine< T & >::control_block::deallocate() noexcept {
template< typename T > template< typename T >
void void
pull_coroutine< T & >::control_block::resume() { pull_coroutine< T & >::control_block::resume() {
c = c.resume(); c = std::move( c).resume();
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -339,7 +339,7 @@ pull_coroutine< void >::control_block::control_block( context::preallocated pall
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back // jump back
return other->c.resume(); return std::move( other->c).resume();
}, },
std::forward< Fn >( fn) ) }, std::forward< Fn >( fn) ) },
#else #else
@ -364,13 +364,13 @@ pull_coroutine< void >::control_block::control_block( context::preallocated pall
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back to ctx // jump back to ctx
return other->c.resume(); return std::move( other->c).resume();
} }, } },
#endif #endif
other{ nullptr }, other{ nullptr },
state{ state_t::unwind }, state{ state_t::unwind },
except{} { except{} {
c = c.resume(); c = std::move( c).resume();
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -396,7 +396,7 @@ pull_coroutine< void >::control_block::deallocate() noexcept {
inline inline
void void
pull_coroutine< void >::control_block::resume() { pull_coroutine< void >::control_block::resume() {
c = c.resume(); c = std::move( c).resume();
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }

View File

@ -51,7 +51,7 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
typename pull_coroutine< T >::control_block synthesized_cb{ this, c }; typename pull_coroutine< T >::control_block synthesized_cb{ this, c };
pull_coroutine< T > synthesized{ & synthesized_cb }; pull_coroutine< T > synthesized{ & synthesized_cb };
other = & synthesized_cb; other = & synthesized_cb;
other->c = other->c.resume(); other->c = std::move( other->c).resume();
if ( state_t::none == ( state & state_t::destroy) ) { if ( state_t::none == ( state & state_t::destroy) ) {
try { try {
auto fn = std::move( fn_); auto fn = std::move( fn_);
@ -67,7 +67,7 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back // jump back
return other->c.resume(); return std::move( other->c).resume();
}, },
std::forward< Fn >( fn) ) }, std::forward< Fn >( fn) ) },
#else #else
@ -77,7 +77,7 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
typename pull_coroutine< T >::control_block synthesized_cb{ this, c }; typename pull_coroutine< T >::control_block synthesized_cb{ this, c };
pull_coroutine< T > synthesized{ & synthesized_cb }; pull_coroutine< T > synthesized{ & synthesized_cb };
other = & synthesized_cb; other = & synthesized_cb;
other->c = other->c.resume(); other->c = std::move( other->c).resume();
if ( state_t::none == ( state & state_t::destroy) ) { if ( state_t::none == ( state & state_t::destroy) ) {
try { try {
auto fn = std::move( fn_); auto fn = std::move( fn_);
@ -93,13 +93,13 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back // jump back
return other->c.resume(); return std::move( other->c).resume();
} }, } },
#endif #endif
other{ nullptr }, other{ nullptr },
state{ state_t::unwind }, state{ state_t::unwind },
except{} { except{} {
c = c.resume(); c = std::move( c).resume();
} }
template< typename T > template< typename T >
@ -125,7 +125,7 @@ push_coroutine< T >::control_block::resume( T const& data) {
// pass data to other context // pass data to other context
other->set( data); other->set( data);
// resume other context // resume other context
c = c.resume(); c = std::move( c).resume();
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -137,7 +137,7 @@ push_coroutine< T >::control_block::resume( T && data) {
// pass data to other context // pass data to other context
other->set( std::move( data) ); other->set( std::move( data) );
// resume other context // resume other context
c = c.resume(); c = std::move( c).resume();
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -173,7 +173,7 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
typename pull_coroutine< T & >::control_block synthesized_cb{ this, c }; typename pull_coroutine< T & >::control_block synthesized_cb{ this, c };
pull_coroutine< T & > synthesized{ & synthesized_cb }; pull_coroutine< T & > synthesized{ & synthesized_cb };
other = & synthesized_cb; other = & synthesized_cb;
other->c = other->c.resume(); other->c = std::move( other->c).resume();
if ( state_t::none == ( state & state_t::destroy) ) { if ( state_t::none == ( state & state_t::destroy) ) {
try { try {
auto fn = std::move( fn_); auto fn = std::move( fn_);
@ -189,7 +189,7 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back // jump back
other->c = other->c.resume(); other->c = std::move( other->c).resume();
}, },
std::forward< Fn >( fn) ) }, std::forward< Fn >( fn) ) },
#else #else
@ -199,7 +199,7 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
typename pull_coroutine< T & >::control_block synthesized_cb{ this, c }; typename pull_coroutine< T & >::control_block synthesized_cb{ this, c };
pull_coroutine< T & > synthesized{ & synthesized_cb }; pull_coroutine< T & > synthesized{ & synthesized_cb };
other = & synthesized_cb; other = & synthesized_cb;
other->c = other->c.resume(); other->c = std::move( other->c).resume();
if ( state_t::none == ( state & state_t::destroy) ) { if ( state_t::none == ( state & state_t::destroy) ) {
try { try {
auto fn = std::move( fn_); auto fn = std::move( fn_);
@ -215,14 +215,14 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back // jump back
other->c = other->c.resume(); other->c = std::move( other->c).resume();
return std::move( other->c); return std::move( other->c);
} }, } },
#endif #endif
other{ nullptr }, other{ nullptr },
state{ state_t::unwind }, state{ state_t::unwind },
except{} { except{} {
c = c.resume(); c = std::move( c).resume();
} }
template< typename T > template< typename T >
@ -248,7 +248,7 @@ push_coroutine< T & >::control_block::resume( T & data) {
// pass data to other context // pass data to other context
other->set( data); other->set( data);
// resume other context // resume other context
c = c.resume(); c = std::move( c).resume();
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -282,7 +282,7 @@ push_coroutine< void >::control_block::control_block( context::preallocated pall
typename pull_coroutine< void >::control_block synthesized_cb{ this, c }; typename pull_coroutine< void >::control_block synthesized_cb{ this, c };
pull_coroutine< void > synthesized{ & synthesized_cb }; pull_coroutine< void > synthesized{ & synthesized_cb };
other = & synthesized_cb; other = & synthesized_cb;
other->c = other->c.resume(); other->c = std::move( other->c).resume();
if ( state_t::none == ( state & state_t::destroy) ) { if ( state_t::none == ( state & state_t::destroy) ) {
try { try {
auto fn = std::move( fn_); auto fn = std::move( fn_);
@ -298,7 +298,7 @@ push_coroutine< void >::control_block::control_block( context::preallocated pall
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back // jump back
other->c = other->c.resume(); other->c = std::move( other->c).resume();
return std::move( other->c); return std::move( other->c);
}, },
std::forward< Fn >( fn) ) }, std::forward< Fn >( fn) ) },
@ -309,7 +309,7 @@ push_coroutine< void >::control_block::control_block( context::preallocated pall
typename pull_coroutine< void >::control_block synthesized_cb{ this, c}; typename pull_coroutine< void >::control_block synthesized_cb{ this, c};
pull_coroutine< void > synthesized{ & synthesized_cb }; pull_coroutine< void > synthesized{ & synthesized_cb };
other = & synthesized_cb; other = & synthesized_cb;
other->c = other->c.resume(); other->c = std::move( other->c).resume();
if ( state_t::none == ( state & state_t::destroy) ) { if ( state_t::none == ( state & state_t::destroy) ) {
try { try {
auto fn = std::move( fn_); auto fn = std::move( fn_);
@ -325,14 +325,14 @@ push_coroutine< void >::control_block::control_block( context::preallocated pall
// set termination flags // set termination flags
state |= state_t::complete; state |= state_t::complete;
// jump back // jump back
other->c = other->c.resume(); other->c = std::move( other->c).resume();
return std::move( other->c); return std::move( other->c);
} }, } },
#endif #endif
other{ nullptr }, other{ nullptr },
state{ state_t::unwind }, state{ state_t::unwind },
except{} { except{} {
c = c.resume(); c = std::move( c).resume();
} }
inline inline
@ -355,7 +355,7 @@ push_coroutine< void >::control_block::deallocate() noexcept {
inline inline
void void
push_coroutine< void >::control_block::resume() { push_coroutine< void >::control_block::resume() {
c = c.resume(); c = std::move( c).resume();
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }