Skip to content

Commit

Permalink
resume() -> continuation::operator()
Browse files Browse the repository at this point in the history
  • Loading branch information
olk committed Feb 2, 2017
1 parent 638d3f2 commit 6bfa86e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
24 changes: 12 additions & 12 deletions include/boost/coroutine2/detail/pull_control_block_cc.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pull_coroutine< T >::control_block::destroy( control_block * cb) noexcept {
cb->~control_block();
// destroy coroutine's stack
cb->state |= state_t::destroy;
boost::context::resume( std::move( c) );
c();
}

template< typename T >
Expand Down Expand Up @@ -75,7 +75,7 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc,
// set termination flags
state |= state_t::complete;
// jump back
return boost::context::resume( std::move( other->c) );
return other->c();
},
std::forward< Fn >( fn) ) );
#else
Expand All @@ -101,7 +101,7 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc,
// set termination flags
state |= state_t::complete;
// jump back
return boost::context::resume( std::move( other->c) );
return other->c();
});
#endif
if ( boost::context::data_available( c) ) {
Expand Down Expand Up @@ -139,7 +139,7 @@ pull_coroutine< T >::control_block::deallocate() noexcept {
template< typename T >
void
pull_coroutine< T >::control_block::resume() {
c = boost::context::resume( std::move( c) );
c = c();
if ( boost::context::data_available( c) ) {
set( boost::context::get_data< T >( c) );
} else {
Expand Down Expand Up @@ -205,7 +205,7 @@ pull_coroutine< T & >::control_block::destroy( control_block * cb) noexcept {
cb->~control_block();
// destroy coroutine's stack
cb->state |= state_t::destroy;
boost::context::resume( std::move( c) );
c();
}

template< typename T >
Expand Down Expand Up @@ -241,7 +241,7 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo
// set termination flags
state |= state_t::complete;
// jump back
return boost::context::resume( std::move( other->c) );
return other->c();
},
std::forward< Fn >( fn) ) );
#else
Expand All @@ -267,7 +267,7 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo
// set termination flags
state |= state_t::complete;
// jump back
return boost::context::resume( std::move( other->c) );
return other->c();
});
#endif
if ( boost::context::data_available( c) ) {
Expand Down Expand Up @@ -297,7 +297,7 @@ pull_coroutine< T & >::control_block::deallocate() noexcept {
template< typename T >
void
pull_coroutine< T & >::control_block::resume() {
c = boost::context::resume( std::move( c) );
c = c();
if ( boost::context::data_available( c) ) {
set( boost::context::get_data< T & >( c) );
} else {
Expand Down Expand Up @@ -347,7 +347,7 @@ pull_coroutine< void >::control_block::destroy( control_block * cb) noexcept {
cb->~control_block();
// destroy coroutine's stack
cb->state |= state_t::destroy;
boost::context::resume( std::move( c) );
c();
}

template< typename StackAllocator, typename Fn >
Expand Down Expand Up @@ -380,7 +380,7 @@ pull_coroutine< void >::control_block::control_block( context::preallocated pall
// set termination flags
state |= state_t::complete;
// jump back
return boost::context::resume( std::move( other->c) );
return other->c();
},
std::forward< Fn >( fn) ) );
#else
Expand All @@ -406,7 +406,7 @@ pull_coroutine< void >::control_block::control_block( context::preallocated pall
// set termination flags
state |= state_t::complete;
// jump back to ctx
return boost::context::resume( std::move( other->c) );
return other->c();
});
#endif
}
Expand All @@ -431,7 +431,7 @@ pull_coroutine< void >::control_block::deallocate() noexcept {
inline
void
pull_coroutine< void >::control_block::resume() {
c = boost::context::resume( std::move( c) );
c = c();
if ( except) {
std::rethrow_exception( except);
}
Expand Down
38 changes: 19 additions & 19 deletions include/boost/coroutine2/detail/push_control_block_cc.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ push_coroutine< T >::control_block::destroy( control_block * cb) noexcept {
cb->~control_block();
// destroy coroutine's stack
cb->state |= state_t::destroy;
boost::context::resume( std::move( c) );
c();
}

template< typename T >
Expand All @@ -57,7 +57,7 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
typename pull_coroutine< T >::control_block synthesized_cb{ this, c };
pull_coroutine< T > synthesized{ & synthesized_cb };
other = & synthesized_cb;
other->c = boost::context::resume( std::move( other->c) );
other->c = other->c();
// set transferred value
if ( boost::context::data_available( other->c) ) {
synthesized_cb.set( boost::context::get_data< T >( other->c) );
Expand All @@ -79,7 +79,7 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
// set termination flags
state |= state_t::complete;
// jump back
return boost::context::resume( std::move( other->c) );
return other->c();
},
std::forward< Fn >( fn) ) );
#else
Expand All @@ -90,7 +90,7 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
typename pull_coroutine< T >::control_block synthesized_cb{ this, c };
pull_coroutine< T > synthesized{ & synthesized_cb };
other = & synthesized_cb;
other->c = boost::context::resume( std::move( other->c) );
other->c = other->c();
// set transferred value
if ( boost::context::data_available( other->c) ) {
synthesized_cb.set( boost::context::get_data< T >( other->c) );
Expand All @@ -112,7 +112,7 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
// set termination flags
state |= state_t::complete;
// jump back
return boost::context::resume( std::move( other->c) );
return other->c();
});
#endif
}
Expand All @@ -138,7 +138,7 @@ template< typename T >
void
push_coroutine< T >::control_block::resume( T const& data) {
// pass an pointer to other context
c = boost::context::resume( std::move( c), data);
c = c( data);
if ( except) {
std::rethrow_exception( except);
}
Expand All @@ -148,7 +148,7 @@ template< typename T >
void
push_coroutine< T >::control_block::resume( T && data) {
// pass an pointer to other context
c = boost::context::resume( std::move( c), std::move( data) );
c = c( std::move( data) );
if ( except) {
std::rethrow_exception( except);
}
Expand All @@ -171,7 +171,7 @@ push_coroutine< T & >::control_block::destroy( control_block * cb) noexcept {
cb->~control_block();
// destroy coroutine's stack
cb->state |= state_t::destroy;
boost::context::resume( std::move( c) );
c();
}

template< typename T >
Expand All @@ -190,7 +190,7 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
typename pull_coroutine< T & >::control_block synthesized_cb{ this, c };
pull_coroutine< T & > synthesized{ & synthesized_cb };
other = & synthesized_cb;
other->c = boost::context::resume( std::move( other->c) );
other->c = other->c();
// set transferred value
if ( boost::context::data_available( other->c) ) {
synthesized_cb.set( boost::context::get_data< T & >( other->c) );
Expand All @@ -212,7 +212,7 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
// set termination flags
state |= state_t::complete;
// jump back
return boost::context::resume( std::move( other->c) );
return other->c();
},
std::forward< Fn >( fn) ) );
#else
Expand All @@ -223,7 +223,7 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
typename pull_coroutine< T & >::control_block synthesized_cb{ this, c };
pull_coroutine< T & > synthesized{ & synthesized_cb };
other = & synthesized_cb;
other->c = boost::context::resume( std::move( other->c) );
other->c = other->c();
// set transferred value
if ( boost::context::data_available( other->c) ) {
synthesized_cb.set( boost::context::get_data< T & >( other->c) );
Expand All @@ -245,7 +245,7 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
// set termination flags
state |= state_t::complete;
// jump back
return boost::context::resume( std::move( other->c) );
return other->c();
});
#endif
}
Expand All @@ -271,7 +271,7 @@ template< typename T >
void
push_coroutine< T & >::control_block::resume( T & t) {
// pass an pointer to other context
c = boost::context::resume( std::move( c), std::ref( t) );
c = c( std::ref( t) );
if ( except) {
std::rethrow_exception( except);
}
Expand All @@ -294,7 +294,7 @@ push_coroutine< void >::control_block::destroy( control_block * cb) noexcept {
cb->~control_block();
// destroy coroutine's stack
cb->state |= state_t::destroy;
boost::context::resume( std::move( c) );
c();
}

template< typename StackAllocator, typename Fn >
Expand All @@ -311,7 +311,7 @@ push_coroutine< void >::control_block::control_block( context::preallocated pall
typename pull_coroutine< void >::control_block synthesized_cb{ this, c };
pull_coroutine< void > synthesized{ & synthesized_cb };
other = & synthesized_cb;
other->c = boost::context::resume( std::move( other->c) );
other->c = other->c();
if ( state_t::none == ( state & state_t::destroy) ) {
try {
auto fn = std::move( fn_);
Expand All @@ -327,7 +327,7 @@ push_coroutine< void >::control_block::control_block( context::preallocated pall
// set termination flags
state |= state_t::complete;
// jump back
return boost::context::resume( std::move( other->c) );
return other->c();
},
std::forward< Fn >( fn) ) );
#else
Expand All @@ -338,7 +338,7 @@ push_coroutine< void >::control_block::control_block( context::preallocated pall
typename pull_coroutine< void >::control_block synthesized_cb{ this, c};
pull_coroutine< void > synthesized{ & synthesized_cb };
other = & synthesized_cb;
other->c = boost::context::resume( std::move( other->c) );
other->c = other->c();
if ( state_t::none == ( state & state_t::destroy) ) {
try {
auto fn = std::move( fn_);
Expand All @@ -354,7 +354,7 @@ push_coroutine< void >::control_block::control_block( context::preallocated pall
// set termination flags
state |= state_t::complete;
// jump back
return boost::context::resume( std::move( other->c) );
return other->c();
});
#endif
}
Expand All @@ -379,7 +379,7 @@ push_coroutine< void >::control_block::deallocate() noexcept {
inline
void
push_coroutine< void >::control_block::resume() {
c = boost::context::resume( std::move( c) );
c = c();
if ( except) {
std::rethrow_exception( except);
}
Expand Down

0 comments on commit 6bfa86e

Please sign in to comment.