diff --git a/examples/work_sharing.cpp b/examples/work_sharing.cpp index 70e5e23b..dbbb60f5 100644 --- a/examples/work_sharing.cpp +++ b/examples/work_sharing.cpp @@ -68,8 +68,6 @@ public: // stash it in separate slot local_queue_.push( ctx); } else { - // detach context from current scheduler - boost::fibers::context::active()->detach( ctx); // ordinary fiber, enqueue on shared queue lock_t lk( mtx_); rqueue_.push( ctx); @@ -86,7 +84,7 @@ public: lk.unlock(); BOOST_ASSERT( nullptr != ctx); // attach context to current scheduler - boost::fibers::context::active()->attach( ctx); + boost::fibers::context::active()->migrate( ctx); } else if ( ! local_queue_.empty() ) { lk.unlock(); // nothing in the ready queue, return dispatcher_ctx_ diff --git a/include/boost/fiber/context.hpp b/include/boost/fiber/context.hpp index d88e20f2..ab9c7250 100644 --- a/include/boost/fiber/context.hpp +++ b/include/boost/fiber/context.hpp @@ -441,9 +441,7 @@ public: void worker_unlink() noexcept; - void attach( context *); - - void detach( context *); + void migrate( context *); friend void intrusive_ptr_add_ref( context * ctx) { BOOST_ASSERT( nullptr != ctx); diff --git a/src/context.cpp b/src/context.cpp index 014c0c00..3ee5d842 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -438,19 +438,13 @@ context::wait_unlink() noexcept { } void -context::attach( context * ctx) { +context::migrate( context * ctx) { BOOST_ASSERT( nullptr != ctx); + BOOST_ASSERT( context::active() != ctx); + ctx->scheduler_->detach_worker_context( ctx); scheduler_->attach_worker_context( ctx); } -void -context::detach( context * ctx) { - BOOST_ASSERT( nullptr != ctx); - BOOST_ASSERT( scheduler_ == ctx->scheduler_); - scheduler_->detach_worker_context( ctx); - ctx->scheduler_ = nullptr; -} - }} #ifdef BOOST_HAS_ABI_HEADERS