2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-18 01:52:24 +00:00

remove forced_unwind and related functions

- unwinding the stack via exception is not always necessary
- usually a fiber returns from its fiber-fn (stack is already unwound)
- if a fiber has to terminate, interrupt that fiber
This commit is contained in:
Oliver Kowalke
2015-11-25 19:30:25 +01:00
parent 26227e31b2
commit a344247f07
4 changed files with 4 additions and 29 deletions

View File

@@ -134,8 +134,7 @@ private:
flag_worker_context = 1 << 3,
flag_terminated = 1 << 4,
flag_interruption_blocked = 1 << 5,
flag_interruption_requested = 1 << 6,
flag_forced_unwind = 1 << 7
flag_interruption_requested = 1 << 6
};
struct BOOST_FIBERS_DECL fss_data {
@@ -284,14 +283,8 @@ public:
std::function< void() > * func( static_cast< std::function< void() > * >( vp) );
( * func)();
}
// check for unwinding
if ( ! unwinding_requested() ) {
boost::context::detail::do_invoke( fn, tpl);
}
boost::context::detail::do_invoke( fn, tpl);
} catch ( fiber_interrupted const&) {
} catch ( forced_unwind const&) {
} catch ( ... ) {
std::terminate();
}
// terminate context
terminate();
@@ -361,12 +354,6 @@ public:
void request_interruption( bool req) noexcept;
bool unwinding_requested() const noexcept {
return 0 != ( flags_ & flag_forced_unwind);
}
void request_unwinding() noexcept;
void * get_fss_data( void const * vp) const;
void set_fss_data(

View File

@@ -24,8 +24,6 @@
namespace boost {
namespace fibers {
struct forced_unwind {};
class fiber_exception : public std::system_error {
public:
fiber_exception() :

View File

@@ -334,13 +334,6 @@ context::request_interruption( bool req) noexcept {
}
}
void
context::request_unwinding() noexcept {
BOOST_ASSERT( ! is_main_context() );
BOOST_ASSERT( ! is_dispatcher_context() );
flags_ |= flag_forced_unwind;
}
void *
context::get_fss_data( void const * vp) const {
uintptr_t key( reinterpret_cast< uintptr_t >( vp) );

View File

@@ -34,9 +34,6 @@ scheduler::resume_( context * active_ctx, context * ctx, std::function< void() >
// resume active-fiber == ctx
ctx->resume( func);
BOOST_ASSERT( context::active() == active_ctx);
if ( active_ctx->unwinding_requested() ) {
throw forced_unwind();
}
}
context *
@@ -185,7 +182,7 @@ scheduler::dispatch() {
// loop till all context' have been terminated
std::unique_lock< detail::spinlock > lk( worker_splk_);
while ( ! worker_queue_.empty() ) {
// force unwinding of all context' in worker-queue
// interrupt all context' in worker-queue
worker_queue_t::iterator e = worker_queue_.end();
for ( worker_queue_t::iterator i = worker_queue_.begin(); i != e;) {
context * ctx = & ( worker_queue_.front() );
@@ -194,7 +191,7 @@ scheduler::dispatch() {
if ( ctx->is_terminated() ) {
i = worker_queue_.erase( i);
} else {
ctx->request_unwinding();
ctx->request_interruption( true);
set_ready( ctx);
++i;
}