Merge branch 'develop'

This commit is contained in:
Oliver Kowalke 2017-08-01 10:15:35 +02:00
commit 6612cdc251
3 changed files with 13 additions and 68 deletions

View File

@ -50,7 +50,6 @@ struct pull_coroutine< T >::control_block {
void set( T const&);
void set( T &&);
void reset();
T & get() noexcept;
@ -89,7 +88,6 @@ struct pull_coroutine< T & >::control_block {
void resume();
void set( T &);
void reset();
T & get() noexcept;

View File

@ -103,9 +103,6 @@ pull_coroutine< T >::control_block::control_block( context::preallocated palloc,
return other->c.resume();
});
#endif
if ( c.data_available() ) {
set( c.get_data< T >() );
}
}
template< typename T >
@ -139,11 +136,6 @@ template< typename T >
void
pull_coroutine< T >::control_block::resume() {
c = c.resume();
if ( c.data_available() ) {
set( c.get_data< T >() );
} else {
reset();
}
if ( except) {
std::rethrow_exception( except);
}
@ -171,16 +163,6 @@ pull_coroutine< T >::control_block::set( T && t) {
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 >
T &
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();
});
#endif
if ( c.data_available() ) {
set( c.get_data< T & >() );
}
}
template< typename T >
@ -296,11 +275,6 @@ template< typename T >
void
pull_coroutine< T & >::control_block::resume() {
c = c.resume();
if ( c.data_available() ) {
set( c.get_data< T & >() );
} else {
reset();
}
if ( except) {
std::rethrow_exception( except);
}
@ -313,15 +287,6 @@ pull_coroutine< T & >::control_block::set( T & t) {
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 >
T &
pull_coroutine< T & >::control_block::get() noexcept {

View File

@ -57,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_);
@ -90,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_);
@ -136,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);
}
@ -146,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);
}
@ -189,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_);
@ -222,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_);
@ -267,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);
}