diff options
Diffstat (limited to 'boost/coroutine2/detail/push_control_block_cc.ipp')
-rw-r--r-- | boost/coroutine2/detail/push_control_block_cc.ipp | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/boost/coroutine2/detail/push_control_block_cc.ipp b/boost/coroutine2/detail/push_control_block_cc.ipp index 9972c7039f..98b24f2642 100644 --- a/boost/coroutine2/detail/push_control_block_cc.ipp +++ b/boost/coroutine2/detail/push_control_block_cc.ipp @@ -38,7 +38,6 @@ push_coroutine< T >::control_block::destroy( control_block * cb) noexcept { cb->~control_block(); // destroy coroutine's stack cb->state |= state_t::destroy; - c.resume(); } template< typename T > @@ -58,12 +57,6 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc, pull_coroutine< T > synthesized{ & synthesized_cb }; other = & synthesized_cb; other->c = other->c.resume(); - // set transferred value - if ( other->c.data_available() ) { - synthesized_cb.set( other->c.template get_data< T >() ); - } else { - synthesized_cb.reset(); - } if ( state_t::none == ( state & state_t::destroy) ) { try { auto fn = std::move( fn_); @@ -91,12 +84,6 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc, pull_coroutine< T > synthesized{ & synthesized_cb }; other = & synthesized_cb; other->c = other->c.resume(); - // set transferred value - if ( other->c.data_available() ) { - synthesized_cb.set( other->c.template get_data< T >() ); - } else { - synthesized_cb.reset(); - } if ( state_t::none == ( state & state_t::destroy) ) { try { auto fn = std::move( fn_); @@ -137,8 +124,10 @@ push_coroutine< T >::control_block::deallocate() noexcept { template< typename T > void push_coroutine< T >::control_block::resume( T const& data) { - // pass an pointer to other context - c = c.resume( data); + // pass data to other context + other->set( data); + // resume other context + c = c.resume(); if ( except) { std::rethrow_exception( except); } @@ -147,8 +136,10 @@ push_coroutine< T >::control_block::resume( T const& data) { template< typename T > void push_coroutine< T >::control_block::resume( T && data) { - // pass an pointer to other context - c = c.resume( std::move( data) ); + // pass data to other context + other->set( std::move( data) ); + // resume other context + c = c.resume(); if ( except) { std::rethrow_exception( except); } @@ -171,7 +162,6 @@ push_coroutine< T & >::control_block::destroy( control_block * cb) noexcept { cb->~control_block(); // destroy coroutine's stack cb->state |= state_t::destroy; - c.resume(); } template< typename T > @@ -191,12 +181,6 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo pull_coroutine< T & > synthesized{ & synthesized_cb }; other = & synthesized_cb; other->c = other->c.resume(); - // set transferred value - if ( other->c.data_available() ) { - synthesized_cb.set( other->c.template get_data< T & >() ); - } else { - synthesized_cb.reset(); - } if ( state_t::none == ( state & state_t::destroy) ) { try { auto fn = std::move( fn_); @@ -224,12 +208,6 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo pull_coroutine< T & > synthesized{ & synthesized_cb }; other = & synthesized_cb; other->c = other->c.resume(); - // set transferred value - if ( other->c.data_available() ) { - synthesized_cb.set( other->c.template get_data< T & >() ); - } else { - synthesized_cb.reset(); - } if ( state_t::none == ( state & state_t::destroy) ) { try { auto fn = std::move( fn_); @@ -269,9 +247,11 @@ push_coroutine< T & >::control_block::deallocate() noexcept { template< typename T > void -push_coroutine< T & >::control_block::resume( T & t) { - // pass an pointer to other context - c = c.resume( std::ref( t) ); +push_coroutine< T & >::control_block::resume( T & data) { + // pass data to other context + other->set( data); + // resume other context + c = c.resume(); if ( except) { std::rethrow_exception( except); } @@ -294,7 +274,6 @@ push_coroutine< void >::control_block::destroy( control_block * cb) noexcept { cb->~control_block(); // destroy coroutine's stack cb->state |= state_t::destroy; - c.resume(); } template< typename StackAllocator, typename Fn > |