class dispatcher_context final : public context {
private:
- boost::context::continuation
- run_( boost::context::continuation && c) {
- c.resume();
+ boost::context::fiber
+ run_( boost::context::fiber && c) {
+#if (defined(BOOST_USE_UCONTEXT)||defined(BOOST_USE_WINFIB))
+ std::move( c).resume();
+#endif
// execute scheduler::dispatch()
return get_scheduler()->dispatch();
}
public:
- dispatcher_context( boost::context::preallocated const& palloc, default_stack const& salloc) :
+ dispatcher_context( boost::context::preallocated const& palloc, default_stack && salloc) :
context{ 0, type::dispatcher_context, launch::post } {
- c_ = boost::context::callcc(
- std::allocator_arg, palloc, salloc,
- std::bind( & dispatcher_context::run_, this, std::placeholders::_1) );
+ c_ = boost::context::fiber{ std::allocator_arg, palloc, salloc,
+ std::bind( & dispatcher_context::run_, this, std::placeholders::_1) };
+#if (defined(BOOST_USE_UCONTEXT)||defined(BOOST_USE_WINFIB))
+ c_ = std::move( c_).resume();
+#endif
}
};
// placement new of context on top of fiber's stack
return intrusive_ptr< context >{
new ( storage) dispatcher_context{
- boost::context::preallocated{ storage, size, sctx }, salloc } };
+ boost::context::preallocated{ storage, size, sctx }, std::move( salloc) } };
}
// schwarz counter
// main fiber context of this thread
context * main_ctx = new main_context{};
// scheduler of this thread
- scheduler * sched = new scheduler{};
+ auto sched = new scheduler{};
// attach main context to scheduler
sched->attach_main_context( main_ctx);
// create and attach dispatcher context to scheduler
// prev will point to previous active context
std::swap( context_initializer::active_, prev);
// pass pointer to the context that resumes `this`
- c_.resume_with([prev](boost::context::continuation && c){
+ std::move( c_).resume_with([prev](boost::context::fiber && c){
prev->c_ = std::move( c);
- return boost::context::continuation{};
+ return boost::context::fiber{};
});
}
// prev will point to previous active context
std::swap( context_initializer::active_, prev);
// pass pointer to the context that resumes `this`
- c_.resume_with([prev,&lk](boost::context::continuation && c){
+ std::move( c_).resume_with([prev,&lk](boost::context::fiber && c){
prev->c_ = std::move( c);
lk.unlock();
- return boost::context::continuation{};
+ return boost::context::fiber{};
});
}
// prev will point to previous active context
std::swap( context_initializer::active_, prev);
// pass pointer to the context that resumes `this`
- c_.resume_with([prev,ready_ctx](boost::context::continuation && c){
+ std::move( c_).resume_with([prev,ready_ctx](boost::context::fiber && c){
prev->c_ = std::move( c);
context::active()->schedule( ready_ctx);
- return boost::context::continuation{};
+ return boost::context::fiber{};
});
}
get_scheduler()->yield( context::active() );
}
-boost::context::continuation
+boost::context::fiber
context::suspend_with_cc() noexcept {
context * prev = this;
// context_initializer::active_ will point to `this`
// prev will point to previous active context
std::swap( context_initializer::active_, prev);
// pass pointer to the context that resumes `this`
- return c_.resume_with([prev](boost::context::continuation && c){
+ return std::move( c_).resume_with([prev](boost::context::fiber && c){
prev->c_ = std::move( c);
- return boost::context::continuation{};
+ return boost::context::fiber{};
});
}
-boost::context::continuation
+boost::context::fiber
context::terminate() noexcept {
// protect for concurrent access
std::unique_lock< detail::spinlock > lk{ splk_ };
void *
context::get_fss_data( void const * vp) const {
- uintptr_t key = reinterpret_cast< uintptr_t >( vp);
- fss_data_t::const_iterator i = fss_data_.find( key);
+ auto key = reinterpret_cast< uintptr_t >( vp);
+ auto i = fss_data_.find( key);
return fss_data_.end() != i ? i->second.vp : nullptr;
}
void * data,
bool cleanup_existing) {
BOOST_ASSERT( cleanup_fn);
- uintptr_t key = reinterpret_cast< uintptr_t >( vp);
- fss_data_t::iterator i = fss_data_.find( key);
+ auto key = reinterpret_cast< uintptr_t >( vp);
+ auto i = fss_data_.find( key);
if ( fss_data_.end() != i) {
if( cleanup_existing) {
i->second.do_cleanup();
}
if ( nullptr != data) {
- fss_data_.insert(
- i,
- std::make_pair(
- key,
- fss_data{ data, cleanup_fn } ) );
+ i->second = fss_data{ data, cleanup_fn };
} else {
fss_data_.erase( i);
}