diff --git a/include/boost/fiber/context.hpp b/include/boost/fiber/context.hpp index 847177e3..bb43a1cd 100644 --- a/include/boost/fiber/context.hpp +++ b/include/boost/fiber/context.hpp @@ -162,7 +162,7 @@ public: static context * active() noexcept; - static context * active( context * active) noexcept; + static void active( context * active) noexcept; context * nxt; diff --git a/src/context.cpp b/src/context.cpp index 2f8c703d..116692d7 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -33,12 +33,10 @@ context::active() noexcept { return active_; } -context * +void context::active( context * active) noexcept { BOOST_ASSERT( nullptr != active); - context * old( active_); active_ = active; - return old; } context::~context() { @@ -111,9 +109,9 @@ context::get_fss_data( void const * vp) const { void context::set_fss_data( void const * vp, - detail::fss_cleanup_function::ptr_t const& cleanup_fn, - void * data, - bool cleanup_existing) { + detail::fss_cleanup_function::ptr_t const& cleanup_fn, + void * data, + bool cleanup_existing) { BOOST_ASSERT( cleanup_fn); uintptr_t key( reinterpret_cast< uintptr_t >( vp) ); @@ -147,13 +145,11 @@ context::set_properties( fiber_properties * props) { } void -context::do_spawn( fiber const& f_) { +context::do_spawn( fiber const& f) { BOOST_ASSERT( nullptr != scheduler_); BOOST_ASSERT( this == active_); - context * f( f_.impl_.get() ); - f->set_scheduler( scheduler_); - scheduler_->spawn( f); + scheduler_->spawn( f.impl_.get() ); } void diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 2eace170..51c86e52 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -131,8 +131,6 @@ scheduler::run( context * af) { BOOST_ASSERT( nullptr != af); BOOST_ASSERT( context::active() == af); for (;;) { - // destroy terminated fibers from terminated-queue - tqueue_.clear(); // move all fibers which are ready (state_ready) // from waiting-queue to the runnable-queue wqueue_.move_to( sched_algo_.get() ); @@ -142,6 +140,8 @@ scheduler::run( context * af) { BOOST_ASSERT_MSG( f->is_ready(), "fiber with invalid state in ready-queue"); // resume fiber f resume_( af, f); + // destroy terminated fibers from terminated-queue + tqueue_.clear(); return; } else { // no fibers ready to run; the thread should sleep