mirror of
https://github.com/boostorg/coroutine2.git
synced 2025-05-09 23:24:01 +00:00
do not pass data via continuation::resume()
This commit is contained in:
parent
9af8f7a901
commit
0ecc359300
@ -50,7 +50,6 @@ struct pull_coroutine< T >::control_block {
|
|||||||
|
|
||||||
void set( T const&);
|
void set( T const&);
|
||||||
void set( T &&);
|
void set( T &&);
|
||||||
void reset();
|
|
||||||
|
|
||||||
T & get() noexcept;
|
T & get() noexcept;
|
||||||
|
|
||||||
@ -89,7 +88,6 @@ struct pull_coroutine< T & >::control_block {
|
|||||||
void resume();
|
void resume();
|
||||||
|
|
||||||
void set( T &);
|
void set( T &);
|
||||||
void reset();
|
|
||||||
|
|
||||||
T & get() noexcept;
|
T & get() noexcept;
|
||||||
|
|
||||||
|
@ -103,9 +103,6 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc,
|
|||||||
return other->c.resume();
|
return other->c.resume();
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
if ( c.data_available() ) {
|
|
||||||
set( c.get_data< T >() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
@ -139,11 +136,6 @@ template< typename T >
|
|||||||
void
|
void
|
||||||
pull_coroutine< T >::control_block::resume() {
|
pull_coroutine< T >::control_block::resume() {
|
||||||
c = c.resume();
|
c = c.resume();
|
||||||
if ( c.data_available() ) {
|
|
||||||
set( c.get_data< T >() );
|
|
||||||
} else {
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
if ( except) {
|
if ( except) {
|
||||||
std::rethrow_exception( except);
|
std::rethrow_exception( except);
|
||||||
}
|
}
|
||||||
@ -171,16 +163,6 @@ pull_coroutine< T >::control_block::set( T && t) {
|
|||||||
bvalid = true;
|
bvalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
|
||||||
void
|
|
||||||
pull_coroutine< T >::control_block::reset() {
|
|
||||||
// destroy data if set
|
|
||||||
if ( bvalid) {
|
|
||||||
reinterpret_cast< T * >( std::addressof( storage) )->~T();
|
|
||||||
}
|
|
||||||
bvalid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
T &
|
T &
|
||||||
pull_coroutine< T >::control_block::get() noexcept {
|
pull_coroutine< T >::control_block::get() noexcept {
|
||||||
@ -268,9 +250,6 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo
|
|||||||
return other->c.resume();
|
return other->c.resume();
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
if ( c.data_available() ) {
|
|
||||||
set( c.get_data< T & >() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
@ -296,11 +275,6 @@ template< typename T >
|
|||||||
void
|
void
|
||||||
pull_coroutine< T & >::control_block::resume() {
|
pull_coroutine< T & >::control_block::resume() {
|
||||||
c = c.resume();
|
c = c.resume();
|
||||||
if ( c.data_available() ) {
|
|
||||||
set( c.get_data< T & >() );
|
|
||||||
} else {
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
if ( except) {
|
if ( except) {
|
||||||
std::rethrow_exception( except);
|
std::rethrow_exception( except);
|
||||||
}
|
}
|
||||||
@ -313,15 +287,6 @@ pull_coroutine< T & >::control_block::set( T & t) {
|
|||||||
bvalid = true;
|
bvalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
|
||||||
void
|
|
||||||
pull_coroutine< T & >::control_block::reset() {
|
|
||||||
if ( bvalid) {
|
|
||||||
reinterpret_cast< holder * >( std::addressof( storage) )->~holder();
|
|
||||||
}
|
|
||||||
bvalid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
T &
|
T &
|
||||||
pull_coroutine< T & >::control_block::get() noexcept {
|
pull_coroutine< T & >::control_block::get() noexcept {
|
||||||
|
@ -57,12 +57,6 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
|
|||||||
pull_coroutine< T > synthesized{ & synthesized_cb };
|
pull_coroutine< T > synthesized{ & synthesized_cb };
|
||||||
other = & synthesized_cb;
|
other = & synthesized_cb;
|
||||||
other->c = other->c.resume();
|
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) ) {
|
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||||
try {
|
try {
|
||||||
auto fn = std::move( fn_);
|
auto fn = std::move( fn_);
|
||||||
@ -90,12 +84,6 @@ push_coroutine< T >::control_block::control_block( context::preallocated palloc,
|
|||||||
pull_coroutine< T > synthesized{ & synthesized_cb };
|
pull_coroutine< T > synthesized{ & synthesized_cb };
|
||||||
other = & synthesized_cb;
|
other = & synthesized_cb;
|
||||||
other->c = other->c.resume();
|
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) ) {
|
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||||
try {
|
try {
|
||||||
auto fn = std::move( fn_);
|
auto fn = std::move( fn_);
|
||||||
@ -136,8 +124,10 @@ push_coroutine< T >::control_block::deallocate() noexcept {
|
|||||||
template< typename T >
|
template< typename T >
|
||||||
void
|
void
|
||||||
push_coroutine< T >::control_block::resume( T const& data) {
|
push_coroutine< T >::control_block::resume( T const& data) {
|
||||||
// pass an pointer to other context
|
// pass data to other context
|
||||||
c = c.resume( data);
|
other->set( data);
|
||||||
|
// resume other context
|
||||||
|
c = c.resume();
|
||||||
if ( except) {
|
if ( except) {
|
||||||
std::rethrow_exception( except);
|
std::rethrow_exception( except);
|
||||||
}
|
}
|
||||||
@ -146,8 +136,10 @@ push_coroutine< T >::control_block::resume( T const& data) {
|
|||||||
template< typename T >
|
template< typename T >
|
||||||
void
|
void
|
||||||
push_coroutine< T >::control_block::resume( T && data) {
|
push_coroutine< T >::control_block::resume( T && data) {
|
||||||
// pass an pointer to other context
|
// pass data to other context
|
||||||
c = c.resume( std::move( data) );
|
other->set( std::move( data) );
|
||||||
|
// resume other context
|
||||||
|
c = c.resume();
|
||||||
if ( except) {
|
if ( except) {
|
||||||
std::rethrow_exception( except);
|
std::rethrow_exception( except);
|
||||||
}
|
}
|
||||||
@ -189,12 +181,6 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
|
|||||||
pull_coroutine< T & > synthesized{ & synthesized_cb };
|
pull_coroutine< T & > synthesized{ & synthesized_cb };
|
||||||
other = & synthesized_cb;
|
other = & synthesized_cb;
|
||||||
other->c = other->c.resume();
|
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) ) {
|
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||||
try {
|
try {
|
||||||
auto fn = std::move( fn_);
|
auto fn = std::move( fn_);
|
||||||
@ -222,12 +208,6 @@ push_coroutine< T & >::control_block::control_block( context::preallocated pallo
|
|||||||
pull_coroutine< T & > synthesized{ & synthesized_cb };
|
pull_coroutine< T & > synthesized{ & synthesized_cb };
|
||||||
other = & synthesized_cb;
|
other = & synthesized_cb;
|
||||||
other->c = other->c.resume();
|
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) ) {
|
if ( state_t::none == ( state & state_t::destroy) ) {
|
||||||
try {
|
try {
|
||||||
auto fn = std::move( fn_);
|
auto fn = std::move( fn_);
|
||||||
@ -267,9 +247,11 @@ push_coroutine< T & >::control_block::deallocate() noexcept {
|
|||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
void
|
void
|
||||||
push_coroutine< T & >::control_block::resume( T & t) {
|
push_coroutine< T & >::control_block::resume( T & data) {
|
||||||
// pass an pointer to other context
|
// pass data to other context
|
||||||
c = c.resume( std::ref( t) );
|
other->set( data);
|
||||||
|
// resume other context
|
||||||
|
c = c.resume();
|
||||||
if ( except) {
|
if ( except) {
|
||||||
std::rethrow_exception( except);
|
std::rethrow_exception( except);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user