rename callee and caller

This commit is contained in:
Oliver Kowalke 2015-09-21 17:31:24 +02:00
parent 105ad9c10d
commit b5e475ff36
4 changed files with 77 additions and 77 deletions

View File

@ -23,7 +23,7 @@ namespace detail {
template< typename T > template< typename T >
struct pull_coroutine< T >::control_block { struct pull_coroutine< T >::control_block {
typename push_coroutine< T >::control_block * other; typename push_coroutine< T >::control_block * other;
boost::context::execution_context callee; boost::context::execution_context ctx;
bool preserve_fpu; bool preserve_fpu;
int state; int state;
std::exception_ptr except; std::exception_ptr except;
@ -46,7 +46,7 @@ struct pull_coroutine< T >::control_block {
template< typename T > template< typename T >
struct pull_coroutine< T & >::control_block { struct pull_coroutine< T & >::control_block {
typename push_coroutine< T & >::control_block * other; typename push_coroutine< T & >::control_block * other;
boost::context::execution_context callee; boost::context::execution_context ctx;
bool preserve_fpu; bool preserve_fpu;
int state; int state;
std::exception_ptr except; std::exception_ptr except;
@ -68,7 +68,7 @@ struct pull_coroutine< T & >::control_block {
struct pull_coroutine< void >::control_block { struct pull_coroutine< void >::control_block {
push_coroutine< void >::control_block * other; push_coroutine< void >::control_block * other;
boost::context::execution_context callee; boost::context::execution_context ctx;
bool preserve_fpu; bool preserve_fpu;
int state; int state;
std::exception_ptr except; std::exception_ptr except;

View File

@ -33,10 +33,10 @@ template< typename StackAllocator, typename Fn >
pull_coroutine< T >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, pull_coroutine< T >::control_block::control_block( context::preallocated palloc, StackAllocator salloc,
Fn && fn_, bool preserve_fpu_) : Fn && fn_, bool preserve_fpu_) :
other( nullptr), other( nullptr),
callee( palloc, salloc, ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),caller=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized push_coroutine< T > // create synthesized push_coroutine< T >
typename push_coroutine< T >::control_block synthesized_cb( this, caller); typename push_coroutine< T >::control_block synthesized_cb( this, ctx);
push_coroutine< T > synthesized( & synthesized_cb); push_coroutine< T > synthesized( & synthesized_cb);
other = & synthesized_cb; other = & synthesized_cb;
try { try {
@ -50,22 +50,22 @@ 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 caller // jump back to ctx
other->callee( preserve_fpu); other->ctx( 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
callee( preserve_fpu); ctx( preserve_fpu);
} }
template< typename T > template< typename T >
pull_coroutine< T >::control_block::control_block( typename push_coroutine< T >::control_block * cb, pull_coroutine< T >::control_block::control_block( typename push_coroutine< T >::control_block * cb,
boost::context::execution_context const& caller) : boost::context::execution_context const& ctx_) :
other( cb), other( cb),
callee( caller), ctx( ctx_),
preserve_fpu( other->preserve_fpu), preserve_fpu( other->preserve_fpu),
state( 0), state( 0),
except() { except() {
@ -77,15 +77,15 @@ 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);
callee( preserve_fpu); ctx( preserve_fpu);
} }
} }
template< typename T > template< typename T >
void void
pull_coroutine< T >::control_block::resume() { pull_coroutine< T >::control_block::resume() {
other->callee = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
callee( preserve_fpu); ctx( preserve_fpu);
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -109,10 +109,10 @@ template< typename StackAllocator, typename Fn >
pull_coroutine< T & >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, pull_coroutine< T & >::control_block::control_block( context::preallocated palloc, StackAllocator salloc,
Fn && fn_, bool preserve_fpu_) : Fn && fn_, bool preserve_fpu_) :
other( nullptr), other( nullptr),
callee( palloc, salloc, ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),caller=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized push_coroutine< T > // create synthesized push_coroutine< T >
typename push_coroutine< T & >::control_block synthesized_cb( this, caller); typename push_coroutine< T & >::control_block synthesized_cb( this, ctx);
push_coroutine< T & > synthesized( & synthesized_cb); push_coroutine< T & > synthesized( & synthesized_cb);
other = & synthesized_cb; other = & synthesized_cb;
try { try {
@ -126,22 +126,22 @@ 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 caller // jump back to ctx
other->callee( preserve_fpu); other->ctx( 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
callee( preserve_fpu); ctx( preserve_fpu);
} }
template< typename T > template< typename T >
pull_coroutine< T & >::control_block::control_block( typename push_coroutine< T & >::control_block * cb, pull_coroutine< T & >::control_block::control_block( typename push_coroutine< T & >::control_block * cb,
boost::context::execution_context const& caller) : boost::context::execution_context const& ctx_) :
other( cb), other( cb),
callee( caller), ctx( ctx_),
preserve_fpu( other->preserve_fpu), preserve_fpu( other->preserve_fpu),
state( 0), state( 0),
except() { except() {
@ -153,15 +153,15 @@ 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);
callee( preserve_fpu); ctx( preserve_fpu);
} }
} }
template< typename T > template< typename T >
void void
pull_coroutine< T & >::control_block::resume() { pull_coroutine< T & >::control_block::resume() {
other->callee = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
callee( preserve_fpu); ctx( preserve_fpu);
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }
@ -184,10 +184,10 @@ template< typename StackAllocator, typename Fn >
pull_coroutine< void >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, pull_coroutine< void >::control_block::control_block( context::preallocated palloc, StackAllocator salloc,
Fn && fn_, bool preserve_fpu_) : Fn && fn_, bool preserve_fpu_) :
other( nullptr), other( nullptr),
callee( palloc, salloc, ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),caller=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized push_coroutine< T > // create synthesized push_coroutine< T >
typename push_coroutine< void >::control_block synthesized_cb( this, caller); typename push_coroutine< void >::control_block synthesized_cb( this, ctx);
push_coroutine< void > synthesized( & synthesized_cb); push_coroutine< void > synthesized( & synthesized_cb);
other = & synthesized_cb; other = & synthesized_cb;
try { try {
@ -201,22 +201,22 @@ 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 caller // jump back to ctx
other->callee( preserve_fpu); other->ctx( 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
callee( preserve_fpu); ctx( preserve_fpu);
} }
inline inline
pull_coroutine< void >::control_block::control_block( push_coroutine< void >::control_block * cb, pull_coroutine< void >::control_block::control_block( push_coroutine< void >::control_block * cb,
boost::context::execution_context const& caller) : boost::context::execution_context const& ctx_) :
other( cb), other( cb),
callee( caller), ctx( ctx_),
preserve_fpu( other->preserve_fpu), preserve_fpu( other->preserve_fpu),
state( 0), state( 0),
except() { except() {
@ -228,15 +228,15 @@ 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);
callee( preserve_fpu); ctx( preserve_fpu);
} }
} }
inline inline
void void
pull_coroutine< void >::control_block::resume() { pull_coroutine< void >::control_block::resume() {
other->callee = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
callee( preserve_fpu); ctx( preserve_fpu);
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }

View File

@ -23,7 +23,7 @@ namespace detail {
template< typename T > template< typename T >
struct push_coroutine< T >::control_block { struct push_coroutine< T >::control_block {
typename pull_coroutine< T >::control_block * other; typename pull_coroutine< T >::control_block * other;
boost::context::execution_context callee; boost::context::execution_context ctx;
bool preserve_fpu; bool preserve_fpu;
int state; int state;
std::exception_ptr except; std::exception_ptr except;
@ -49,7 +49,7 @@ struct push_coroutine< T >::control_block {
template< typename T > template< typename T >
struct push_coroutine< T & >::control_block { struct push_coroutine< T & >::control_block {
typename pull_coroutine< T & >::control_block * other; typename pull_coroutine< T & >::control_block * other;
boost::context::execution_context callee; boost::context::execution_context ctx;
bool preserve_fpu; bool preserve_fpu;
int state; int state;
std::exception_ptr except; std::exception_ptr except;
@ -72,7 +72,7 @@ struct push_coroutine< T & >::control_block {
struct push_coroutine< void >::control_block { struct push_coroutine< void >::control_block {
pull_coroutine< void >::control_block * other; pull_coroutine< void >::control_block * other;
boost::context::execution_context callee; boost::context::execution_context ctx;
bool preserve_fpu; bool preserve_fpu;
int state; int state;
std::exception_ptr except; std::exception_ptr except;

View File

@ -34,14 +34,14 @@ template< typename StackAllocator, typename Fn >
push_coroutine< T >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, push_coroutine< T >::control_block::control_block( context::preallocated palloc, StackAllocator salloc,
Fn && fn_, bool preserve_fpu_) : Fn && fn_, bool preserve_fpu_) :
other( nullptr), other( nullptr),
callee( palloc, salloc, ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),caller=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized pull_coroutine< T > // create synthesized pull_coroutine< T >
typename pull_coroutine< T >::control_block synthesized_cb( this, caller); 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
caller( preserve_fpu); ctx( 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);
@ -53,8 +53,8 @@ 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 caller // jump back to ctx
other->callee( preserve_fpu); other->ctx( 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_),
@ -62,14 +62,14 @@ 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
callee( preserve_fpu); ctx( preserve_fpu);
} }
template< typename T > template< typename T >
push_coroutine< T >::control_block::control_block( typename pull_coroutine< T >::control_block * cb, push_coroutine< T >::control_block::control_block( typename pull_coroutine< T >::control_block * cb,
boost::context::execution_context const& caller) : boost::context::execution_context const& ctx_) :
other( cb), other( cb),
callee( caller), ctx( ctx_),
preserve_fpu( other->preserve_fpu), preserve_fpu( other->preserve_fpu),
state( 0), state( 0),
except(), except(),
@ -82,7 +82,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);
callee( preserve_fpu); ctx( preserve_fpu);
} }
} }
@ -93,8 +93,8 @@ push_coroutine< T >::control_block::resume( T const& t_) {
// pass an pointer (address of tmp) to other context // pass an pointer (address of tmp) to other context
T tmp( t_); T tmp( t_);
t = & tmp; t = & tmp;
other->callee = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
callee( preserve_fpu); ctx( preserve_fpu);
t = nullptr; t = nullptr;
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
@ -112,8 +112,8 @@ push_coroutine< T >::control_block::resume( T && t_) {
// pass an pointer (address of tmp) to other context // pass an pointer (address of tmp) to other context
T tmp( std::move( t_) ); T tmp( std::move( t_) );
t = & tmp; t = & tmp;
other->callee = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
callee( preserve_fpu); ctx( preserve_fpu);
t = nullptr; t = nullptr;
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
@ -138,14 +138,14 @@ template< typename StackAllocator, typename Fn >
push_coroutine< T & >::control_block::control_block( context::preallocated palloc, StackAllocator salloc, push_coroutine< T & >::control_block::control_block( context::preallocated palloc, StackAllocator salloc,
Fn && fn_, bool preserve_fpu_) : Fn && fn_, bool preserve_fpu_) :
other( nullptr), other( nullptr),
callee( palloc, salloc, ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),caller=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized pull_coroutine< T > // create synthesized pull_coroutine< T >
typename pull_coroutine< T & >::control_block synthesized_cb( this, caller); 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
caller( preserve_fpu); ctx( 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);
@ -157,8 +157,8 @@ 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 caller // jump back to ctx
other->callee( preserve_fpu); other->ctx( 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_),
@ -166,14 +166,14 @@ 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
callee( preserve_fpu); ctx( preserve_fpu);
} }
template< typename T > template< typename T >
push_coroutine< T & >::control_block::control_block( typename pull_coroutine< T & >::control_block * cb, push_coroutine< T & >::control_block::control_block( typename pull_coroutine< T & >::control_block * cb,
boost::context::execution_context const& caller) : boost::context::execution_context const& ctx_) :
other( cb), other( cb),
callee( caller), ctx( ctx_),
preserve_fpu( other->preserve_fpu), preserve_fpu( other->preserve_fpu),
state( 0), state( 0),
except(), except(),
@ -186,7 +186,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);
callee( preserve_fpu); ctx( preserve_fpu);
} }
} }
@ -194,8 +194,8 @@ template< typename T >
void void
push_coroutine< T & >::control_block::resume( T & t_) { push_coroutine< T & >::control_block::resume( T & t_) {
t = & t_; t = & t_;
other->callee = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
callee( preserve_fpu); ctx( preserve_fpu);
t = nullptr; t = nullptr;
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
@ -218,14 +218,14 @@ push_coroutine< T & >::control_block::valid() const noexcept {
template< typename StackAllocator, typename Fn > 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),
callee( palloc, salloc, ctx( palloc, salloc,
[=,fn=std::forward< Fn >( fn_),caller=boost::context::execution_context::current()] () mutable -> void { [=,fn=std::forward< Fn >( fn_),ctx=boost::context::execution_context::current()] () mutable -> void {
// create synthesized pull_coroutine< T > // create synthesized pull_coroutine< T >
typename pull_coroutine< void >::control_block synthesized_cb( this, caller); 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
caller( preserve_fpu); ctx( 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);
@ -237,22 +237,22 @@ 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 caller // jump back to ctx
other->callee( preserve_fpu); other->ctx( 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
callee( preserve_fpu); ctx( preserve_fpu);
} }
inline inline
push_coroutine< void >::control_block::control_block( pull_coroutine< void >::control_block * cb, push_coroutine< void >::control_block::control_block( pull_coroutine< void >::control_block * cb,
boost::context::execution_context const& caller) : boost::context::execution_context const& ctx_) :
other( cb), other( cb),
callee( caller), ctx( ctx_),
preserve_fpu( other->preserve_fpu), preserve_fpu( other->preserve_fpu),
state( 0), state( 0),
except() { except() {
@ -264,15 +264,15 @@ 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);
callee( preserve_fpu); ctx( preserve_fpu);
} }
} }
inline inline
void void
push_coroutine< void >::control_block::resume() { push_coroutine< void >::control_block::resume() {
other->callee = boost::context::execution_context::current(); other->ctx = boost::context::execution_context::current();
callee( preserve_fpu); ctx( preserve_fpu);
if ( except) { if ( except) {
std::rethrow_exception( except); std::rethrow_exception( except);
} }