diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:41:18 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:43:11 +0900 |
commit | f763a99a501650eff2c60288aa6f10ef916d769e (patch) | |
tree | 02af7e13f9a38c888ebf340fe764cbe7dae99da9 /boost/coroutine2/detail/pull_control_block_ecv1.ipp | |
parent | 5cde13f21d36c7224b0e13d11c4b49379ae5210d (diff) | |
download | boost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.gz boost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.bz2 boost-f763a99a501650eff2c60288aa6f10ef916d769e.zip |
Imported Upstream version 1.62.0upstream/1.62.0
Change-Id: I9d4c1ddb7b7d8f0069217ecc582700f9fda6dd4c
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/coroutine2/detail/pull_control_block_ecv1.ipp')
-rw-r--r-- | boost/coroutine2/detail/pull_control_block_ecv1.ipp | 126 |
1 files changed, 72 insertions, 54 deletions
diff --git a/boost/coroutine2/detail/pull_control_block_ecv1.ipp b/boost/coroutine2/detail/pull_control_block_ecv1.ipp index f271e795df..eb2ae2778f 100644 --- a/boost/coroutine2/detail/pull_control_block_ecv1.ipp +++ b/boost/coroutine2/detail/pull_control_block_ecv1.ipp @@ -36,6 +36,7 @@ void pull_coroutine< T >::control_block::destroy( control_block * cb) noexcept { boost::context::execution_context ctx = cb->ctx; // destroy control structure + cb->state |= state_t::destroy; cb->~control_block(); } @@ -52,15 +53,17 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc, typename push_coroutine< T >::control_block synthesized_cb{ this, ctx }; push_coroutine< T > synthesized{ & synthesized_cb }; other = & synthesized_cb; - try { - auto fn = std::move( fn_); - // call coroutine-fn with synthesized push_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); + if ( state_t::none == ( state & state_t::destroy) ) { + try { + auto fn = std::move( fn_); + // call coroutine-fn with synthesized push_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } } // set termination flags state |= state_t::complete; @@ -78,15 +81,17 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc, typename push_coroutine< T >::control_block synthesized_cb{ this, ctx }; push_coroutine< T > synthesized{ & synthesized_cb }; other = & synthesized_cb; - try { - auto fn = std::move( fn_); - // call coroutine-fn with synthesized push_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); + if ( state_t::none == ( state & state_t::destroy) ) { + try { + auto fn = std::move( fn_); + // call coroutine-fn with synthesized push_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } } // set termination flags state |= state_t::complete; @@ -120,6 +125,7 @@ pull_coroutine< T >::control_block::~control_block() { if ( state_t::none == ( state & state_t::complete) && state_t::none != ( state & state_t::unwind) ) { // unwind coroutine stack + other->ctx = boost::context::execution_context::current(); ctx( context::exec_ontop_arg, unwind_coroutine); } // destroy data if it set @@ -181,6 +187,7 @@ void pull_coroutine< T & >::control_block::destroy( control_block * cb) noexcept { boost::context::execution_context ctx = cb->ctx; // destroy control structure + cb->state |= state_t::destroy; cb->~control_block(); } @@ -197,15 +204,17 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo typename push_coroutine< T & >::control_block synthesized_cb{ this, ctx }; push_coroutine< T & > synthesized{ & synthesized_cb }; other = & synthesized_cb; - try { - auto fn = std::move( fn_); - // call coroutine-fn with synthesized push_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); + if ( state_t::none == ( state & state_t::destroy) ) { + try { + auto fn = std::move( fn_); + // call coroutine-fn with synthesized push_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } } // set termination flags state |= state_t::complete; @@ -223,15 +232,17 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo typename push_coroutine< T & >::control_block synthesized_cb{ this, ctx }; push_coroutine< T & > synthesized{ & synthesized_cb }; other = & synthesized_cb; - try { - auto fn = std::move( fn_); - // call coroutine-fn with synthesized push_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); + if ( state_t::none == ( state & state_t::destroy) ) { + try { + auto fn = std::move( fn_); + // call coroutine-fn with synthesized push_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } } // set termination flags state |= state_t::complete; @@ -263,6 +274,7 @@ pull_coroutine< T & >::control_block::~control_block() { if ( state_t::none == ( state & state_t::complete) && state_t::none != ( state & state_t::unwind) ) { // unwind coroutine stack + other->ctx = boost::context::execution_context::current(); ctx( context::exec_ontop_arg, unwind_coroutine); } } @@ -305,6 +317,7 @@ void pull_coroutine< void >::control_block::destroy( control_block * cb) noexcept { boost::context::execution_context ctx = cb->ctx; // destroy control structure + cb->state |= state_t::destroy; cb->~control_block(); } @@ -320,15 +333,17 @@ pull_coroutine< void >::control_block::control_block( context::preallocated pall typename push_coroutine< void >::control_block synthesized_cb{ this, ctx }; push_coroutine< void > synthesized{ & synthesized_cb }; other = & synthesized_cb; - try { - auto fn = std::move( fn_); - // call coroutine-fn with synthesized push_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); + if ( state_t::none == ( state & state_t::destroy) ) { + try { + auto fn = std::move( fn_); + // call coroutine-fn with synthesized push_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } } // set termination flags state |= state_t::complete; @@ -346,15 +361,17 @@ pull_coroutine< void >::control_block::control_block( context::preallocated pall typename push_coroutine< void >::control_block synthesized_cb{ this, ctx }; push_coroutine< void > synthesized{ & synthesized_cb }; other = & synthesized_cb; - try { - auto fn = std::move( fn_); - // call coroutine-fn with synthesized push_coroutine as argument - fn( synthesized); - } catch ( forced_unwind const&) { - // do nothing for unwinding exception - } catch (...) { - // store other exceptions in exception-pointer - except = std::current_exception(); + if ( state_t::none == ( state & state_t::destroy) ) { + try { + auto fn = std::move( fn_); + // call coroutine-fn with synthesized push_coroutine as argument + fn( synthesized); + } catch ( forced_unwind const&) { + // do nothing for unwinding exception + } catch (...) { + // store other exceptions in exception-pointer + except = std::current_exception(); + } } // set termination flags state |= state_t::complete; @@ -384,6 +401,7 @@ pull_coroutine< void >::control_block::~control_block() { if ( state_t::none == ( state & state_t::complete) && state_t::none != ( state & state_t::unwind) ) { // unwind coroutine stack + other->ctx = boost::context::execution_context::current(); ctx( context::exec_ontop_arg, unwind_coroutine); } } |