adapt mods for execution_context::operator() (passing argument)

This commit is contained in:
Oliver Kowalke 2015-10-15 17:57:47 +02:00
parent 4197d019f9
commit 68913206d2
2 changed files with 34 additions and 34 deletions

View File

@ -35,7 +35,7 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc,
Fn && fn_, bool preserve_fpu_) : Fn && fn_, bool preserve_fpu_) :
other( nullptr), other( nullptr),
ctx( std::allocator_arg, palloc, salloc, ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void {
// create synthesized push_coroutine< T > // create synthesized push_coroutine< T >
typename push_coroutine< T >::control_block synthesized_cb( this, ctx); typename push_coroutine< T >::control_block synthesized_cb( this, ctx);
push_coroutine< T > synthesized( & synthesized_cb); push_coroutine< T > synthesized( & synthesized_cb);
@ -52,14 +52,14 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc,
// set termination flags // set termination flags
state |= static_cast< int >( state_t::complete); state |= static_cast< int >( state_t::complete);
// jump back to ctx // jump back to ctx
other->ctx( preserve_fpu); other->ctx( nullptr, preserve_fpu);
BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); BOOST_ASSERT_MSG( false, "pull_coroutine is complete");
}), }),
preserve_fpu( preserve_fpu_), preserve_fpu( preserve_fpu_),
state( static_cast< int >( state_t::unwind) ), state( static_cast< int >( state_t::unwind) ),
except() { except() {
// enter coroutine-fn in order to have first value available after ctor returns // enter coroutine-fn in order to have first value available after ctor returns
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
template< typename T > template< typename T >
@ -78,7 +78,7 @@ pull_coroutine< T >::control_block::~control_block() {
0 != ( state & static_cast< int >( state_t::unwind) ) ) { 0 != ( state & static_cast< int >( state_t::unwind) ) ) {
// set early-exit flag // set early-exit flag
state |= static_cast< int >( state_t::early_exit); state |= static_cast< int >( state_t::early_exit);
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
} }
@ -86,7 +86,7 @@ template< typename T >
void void
pull_coroutine< T >::control_block::resume() { pull_coroutine< T >::control_block::resume() {
other->ctx = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -111,7 +111,7 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo
Fn && fn_, bool preserve_fpu_) : Fn && fn_, bool preserve_fpu_) :
other( nullptr), other( nullptr),
ctx( std::allocator_arg, palloc, salloc, ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void {
// create synthesized push_coroutine< T > // create synthesized push_coroutine< T >
typename push_coroutine< T & >::control_block synthesized_cb( this, ctx); typename push_coroutine< T & >::control_block synthesized_cb( this, ctx);
push_coroutine< T & > synthesized( & synthesized_cb); push_coroutine< T & > synthesized( & synthesized_cb);
@ -128,14 +128,14 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo
// set termination flags // set termination flags
state |= static_cast< int >( state_t::complete); state |= static_cast< int >( state_t::complete);
// jump back to ctx // jump back to ctx
other->ctx( preserve_fpu); other->ctx( nullptr, preserve_fpu);
BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); BOOST_ASSERT_MSG( false, "pull_coroutine is complete");
}), }),
preserve_fpu( preserve_fpu_), preserve_fpu( preserve_fpu_),
state( static_cast< int >( state_t::unwind) ), state( static_cast< int >( state_t::unwind) ),
except() { except() {
// enter coroutine-fn in order to have first value available after ctor returns // enter coroutine-fn in order to have first value available after ctor returns
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
template< typename T > template< typename T >
@ -154,7 +154,7 @@ pull_coroutine< T & >::control_block::~control_block() {
0 != ( state & static_cast< int >( state_t::unwind) ) ) { 0 != ( state & static_cast< int >( state_t::unwind) ) ) {
// set early-exit flag // set early-exit flag
state |= static_cast< int >( state_t::early_exit); state |= static_cast< int >( state_t::early_exit);
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
} }
@ -162,7 +162,7 @@ template< typename T >
void void
pull_coroutine< T & >::control_block::resume() { pull_coroutine< T & >::control_block::resume() {
other->ctx = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -186,7 +186,7 @@ pull_coroutine< void >::control_block::control_block( context::preallocated pall
Fn && fn_, bool preserve_fpu_) : Fn && fn_, bool preserve_fpu_) :
other( nullptr), other( nullptr),
ctx( std::allocator_arg, palloc, salloc, ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void {
// create synthesized push_coroutine< T > // create synthesized push_coroutine< T >
typename push_coroutine< void >::control_block synthesized_cb( this, ctx); typename push_coroutine< void >::control_block synthesized_cb( this, ctx);
push_coroutine< void > synthesized( & synthesized_cb); push_coroutine< void > synthesized( & synthesized_cb);
@ -203,14 +203,14 @@ pull_coroutine< void >::control_block::control_block( context::preallocated pall
// set termination flags // set termination flags
state |= static_cast< int >( state_t::complete); state |= static_cast< int >( state_t::complete);
// jump back to ctx // jump back to ctx
other->ctx( preserve_fpu); other->ctx( nullptr, preserve_fpu);
BOOST_ASSERT_MSG( false, "pull_coroutine is complete"); BOOST_ASSERT_MSG( false, "pull_coroutine is complete");
}), }),
preserve_fpu( preserve_fpu_), preserve_fpu( preserve_fpu_),
state( static_cast< int >( state_t::unwind) ), state( static_cast< int >( state_t::unwind) ),
except() { except() {
// enter coroutine-fn in order to have first value available after ctor returns // enter coroutine-fn in order to have first value available after ctor returns
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
inline inline
@ -229,7 +229,7 @@ pull_coroutine< void >::control_block::~control_block() {
0 != ( state & static_cast< int >( state_t::unwind) ) ) { 0 != ( state & static_cast< int >( state_t::unwind) ) ) {
// set early-exit flag // set early-exit flag
state |= static_cast< int >( state_t::early_exit); state |= static_cast< int >( state_t::early_exit);
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
} }
@ -237,7 +237,7 @@ inline
void void
pull_coroutine< void >::control_block::resume() { pull_coroutine< void >::control_block::resume() {
other->ctx = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }

View File

@ -36,13 +36,13 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
Fn && fn_, bool preserve_fpu_) : Fn && fn_, bool preserve_fpu_) :
other( nullptr), other( nullptr),
ctx( std::allocator_arg, palloc, salloc, ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void {
// create synthesized pull_coroutine< T > // create synthesized pull_coroutine< T >
typename pull_coroutine< T >::control_block synthesized_cb( this, ctx); typename pull_coroutine< T >::control_block synthesized_cb( this, ctx);
pull_coroutine< T > synthesized( & synthesized_cb); pull_coroutine< T > synthesized( & synthesized_cb);
other = & synthesized_cb; other = & synthesized_cb;
// jump back to ctor // jump back to ctor
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
try { try {
// call coroutine-fn with synthesized pull_coroutine as argument // call coroutine-fn with synthesized pull_coroutine as argument
fn( synthesized); fn( synthesized);
@ -55,7 +55,7 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
// set termination flags // set termination flags
state |= static_cast< int >( state_t::complete); state |= static_cast< int >( state_t::complete);
// jump back to ctx // jump back to ctx
other->ctx( preserve_fpu); other->ctx( nullptr, preserve_fpu);
BOOST_ASSERT_MSG( false, "push_coroutine is complete"); BOOST_ASSERT_MSG( false, "push_coroutine is complete");
}), }),
preserve_fpu( preserve_fpu_), preserve_fpu( preserve_fpu_),
@ -63,7 +63,7 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
except(), except(),
t( nullptr) { t( nullptr) {
// enter coroutine-fn in order to get other set // enter coroutine-fn in order to get other set
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
template< typename T > template< typename T >
@ -83,7 +83,7 @@ push_coroutine< T >::control_block::~control_block() {
0 != ( state & static_cast< int >( state_t::unwind) ) ) { 0 != ( state & static_cast< int >( state_t::unwind) ) ) {
// set early-exit flag // set early-exit flag
state |= static_cast< int >( state_t::early_exit); state |= static_cast< int >( state_t::early_exit);
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
} }
@ -95,7 +95,7 @@ push_coroutine< T >::control_block::resume( T const& t_) {
T tmp( t_); T tmp( t_);
t = & tmp; t = & tmp;
other->ctx = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
t = nullptr; t = nullptr;
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
@ -114,7 +114,7 @@ push_coroutine< T >::control_block::resume( T && t_) {
T tmp( std::move( t_) ); T tmp( std::move( t_) );
t = & tmp; t = & tmp;
other->ctx = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
t = nullptr; t = nullptr;
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
@ -140,13 +140,13 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
Fn && fn_, bool preserve_fpu_) : Fn && fn_, bool preserve_fpu_) :
other( nullptr), other( nullptr),
ctx( std::allocator_arg, palloc, salloc, ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void {
// create synthesized pull_coroutine< T > // create synthesized pull_coroutine< T >
typename pull_coroutine< T & >::control_block synthesized_cb( this, ctx); typename pull_coroutine< T & >::control_block synthesized_cb( this, ctx);
pull_coroutine< T & > synthesized( & synthesized_cb); pull_coroutine< T & > synthesized( & synthesized_cb);
other = & synthesized_cb; other = & synthesized_cb;
// jump back to ctor // jump back to ctor
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
try { try {
// call coroutine-fn with synthesized pull_coroutine as argument // call coroutine-fn with synthesized pull_coroutine as argument
fn( synthesized); fn( synthesized);
@ -159,7 +159,7 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
// set termination flags // set termination flags
state |= static_cast< int >( state_t::complete); state |= static_cast< int >( state_t::complete);
// jump back to ctx // jump back to ctx
other->ctx( preserve_fpu); other->ctx( nullptr, preserve_fpu);
BOOST_ASSERT_MSG( false, "push_coroutine is complete"); BOOST_ASSERT_MSG( false, "push_coroutine is complete");
}), }),
preserve_fpu( preserve_fpu_), preserve_fpu( preserve_fpu_),
@ -167,7 +167,7 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
except(), except(),
t( nullptr) { t( nullptr) {
// enter coroutine-fn in order to get other set // enter coroutine-fn in order to get other set
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
template< typename T > template< typename T >
@ -187,7 +187,7 @@ push_coroutine< T & >::control_block::~control_block() {
0 != ( state & static_cast< int >( state_t::unwind) ) ) { 0 != ( state & static_cast< int >( state_t::unwind) ) ) {
// set early-exit flag // set early-exit flag
state |= static_cast< int >( state_t::early_exit); state |= static_cast< int >( state_t::early_exit);
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
} }
@ -196,7 +196,7 @@ void
push_coroutine< T & >::control_block::resume( T & t_) { push_coroutine< T & >::control_block::resume( T & t_) {
t = & t_; t = & t_;
other->ctx = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
t = nullptr; t = nullptr;
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
@ -220,13 +220,13 @@ template< typename StackAllocator, typename Fn >
push_coroutine< void >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, Fn && fn_, bool preserve_fpu_) : push_coroutine< void >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, Fn && fn_, bool preserve_fpu_) :
other( nullptr), other( nullptr),
ctx( std::allocator_arg, palloc, salloc, ctx( std::allocator_arg, palloc, salloc,
[=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] (void *) mutable -> void {
// create synthesized pull_coroutine< T > // create synthesized pull_coroutine< T >
typename pull_coroutine< void >::control_block synthesized_cb( this, ctx); typename pull_coroutine< void >::control_block synthesized_cb( this, ctx);
pull_coroutine< void > synthesized( & synthesized_cb); pull_coroutine< void > synthesized( & synthesized_cb);
other = & synthesized_cb; other = & synthesized_cb;
// jump back to ctor // jump back to ctor
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
try { try {
// call coroutine-fn with synthesized pull_coroutine as argument // call coroutine-fn with synthesized pull_coroutine as argument
fn( synthesized); fn( synthesized);
@ -239,14 +239,14 @@ push_coroutine< void >::control_block::control_block( context::preallocated pall
// set termination flags // set termination flags
state |= static_cast< int >( state_t::complete); state |= static_cast< int >( state_t::complete);
// jump back to ctx // jump back to ctx
other->ctx( preserve_fpu); other->ctx( nullptr, preserve_fpu);
BOOST_ASSERT_MSG( false, "push_coroutine is complete"); BOOST_ASSERT_MSG( false, "push_coroutine is complete");
}), }),
preserve_fpu( preserve_fpu_), preserve_fpu( preserve_fpu_),
state( static_cast< int >( state_t::unwind) ), state( static_cast< int >( state_t::unwind) ),
except() { except() {
// enter coroutine-fn in order to get other set // enter coroutine-fn in order to get other set
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
inline inline
@ -265,7 +265,7 @@ push_coroutine< void >::control_block::~control_block() {
0 != ( state & static_cast< int >( state_t::unwind) ) ) { 0 != ( state & static_cast< int >( state_t::unwind) ) ) {
// set early-exit flag // set early-exit flag
state |= static_cast< int >( state_t::early_exit); state |= static_cast< int >( state_t::early_exit);
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
} }
} }
@ -273,7 +273,7 @@ inline
void void
push_coroutine< void >::control_block::resume() { push_coroutine< void >::control_block::resume() {
other->ctx = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
ctx( preserve_fpu); ctx( nullptr, preserve_fpu);
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }