mirror of
https://github.com/boostorg/coroutine2.git
synced 2025-05-10 07:34:03 +00:00
unwind the stack if coroutine gets terminated
- fixes #13064 - unwind the stack via exception (continuation is destroyed)
This commit is contained in:
parent
b6faea151a
commit
5737fb22ae
@ -39,7 +39,6 @@ pull_coroutine< T >::control_block::destroy( control_block * cb) noexcept {
|
|||||||
cb->~control_block();
|
cb->~control_block();
|
||||||
// destroy coroutine's stack
|
// destroy coroutine's stack
|
||||||
cb->state |= state_t::destroy;
|
cb->state |= state_t::destroy;
|
||||||
c.resume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
@ -205,7 +204,6 @@ pull_coroutine< T & >::control_block::destroy( control_block * cb) noexcept {
|
|||||||
cb->~control_block();
|
cb->~control_block();
|
||||||
// destroy coroutine's stack
|
// destroy coroutine's stack
|
||||||
cb->state |= state_t::destroy;
|
cb->state |= state_t::destroy;
|
||||||
c.resume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
@ -347,7 +345,6 @@ pull_coroutine< void >::control_block::destroy( control_block * cb) noexcept {
|
|||||||
cb->~control_block();
|
cb->~control_block();
|
||||||
// destroy coroutine's stack
|
// destroy coroutine's stack
|
||||||
cb->state |= state_t::destroy;
|
cb->state |= state_t::destroy;
|
||||||
c.resume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename StackAllocator, typename Fn >
|
template< typename StackAllocator, typename Fn >
|
||||||
|
@ -38,7 +38,6 @@ push_coroutine< T >::control_block::destroy( control_block * cb) noexcept {
|
|||||||
cb->~control_block();
|
cb->~control_block();
|
||||||
// destroy coroutine's stack
|
// destroy coroutine's stack
|
||||||
cb->state |= state_t::destroy;
|
cb->state |= state_t::destroy;
|
||||||
c.resume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
@ -171,7 +170,6 @@ push_coroutine< T & >::control_block::destroy( control_block * cb) noexcept {
|
|||||||
cb->~control_block();
|
cb->~control_block();
|
||||||
// destroy coroutine's stack
|
// destroy coroutine's stack
|
||||||
cb->state |= state_t::destroy;
|
cb->state |= state_t::destroy;
|
||||||
c.resume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
@ -294,7 +292,6 @@ push_coroutine< void >::control_block::destroy( control_block * cb) noexcept {
|
|||||||
cb->~control_block();
|
cb->~control_block();
|
||||||
// destroy coroutine's stack
|
// destroy coroutine's stack
|
||||||
cb->state |= state_t::destroy;
|
cb->state |= state_t::destroy;
|
||||||
c.resume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename StackAllocator, typename Fn >
|
template< typename StackAllocator, typename Fn >
|
||||||
|
@ -470,7 +470,29 @@ void test_unwind()
|
|||||||
i = 7;
|
i = 7;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
BOOST_CHECK_EQUAL( ( int) 0, i);
|
{
|
||||||
|
BOOST_CHECK_EQUAL( ( int) 0, value1);
|
||||||
|
auto * coro = new coro::coroutine< void >::pull_type(
|
||||||
|
[](coro::coroutine< void >::push_type & coro) mutable {
|
||||||
|
X x;
|
||||||
|
coro();
|
||||||
|
});
|
||||||
|
BOOST_CHECK_EQUAL( ( int) 7, value1);
|
||||||
|
delete coro;
|
||||||
|
BOOST_CHECK_EQUAL( ( int) 0, value1);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
BOOST_CHECK_EQUAL( ( int) 0, value1);
|
||||||
|
auto * coro = new coro::coroutine< void >::push_type(
|
||||||
|
[](coro::coroutine< void >::pull_type & coro) mutable {
|
||||||
|
X x;
|
||||||
|
coro();
|
||||||
|
});
|
||||||
|
( * coro)();
|
||||||
|
BOOST_CHECK_EQUAL( ( int) 7, value1);
|
||||||
|
delete coro;
|
||||||
|
BOOST_CHECK_EQUAL( ( int) 0, value1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_exceptions()
|
void test_exceptions()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user