]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/fiber/src/context.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / fiber / src / context.cpp
index b2fed9bea896303c2de73eb0d9ab1e75dcf18862..5ad356a7133c89774182f996a224fcef58b37fed 100644 (file)
@@ -29,19 +29,23 @@ public:
 
 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
     }
 };
 
@@ -58,7 +62,7 @@ static intrusive_ptr< context > make_dispatcher_context() {
     // 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
@@ -71,7 +75,7 @@ struct context_initializer {
             // 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
@@ -143,9 +147,9 @@ context::resume() noexcept {
     // 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{};
             });
 }
 
@@ -156,10 +160,10 @@ context::resume( detail::spinlock_lock & lk) noexcept {
     // 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{};
             });
 }
 
@@ -170,10 +174,10 @@ context::resume( context * ready_ctx) noexcept {
     // 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{};
             });
 }
 
@@ -212,20 +216,20 @@ context::yield() noexcept {
     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_ };
@@ -289,8 +293,8 @@ context::schedule( context * ctx) noexcept {
 
 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;
 }
 
@@ -300,18 +304,14 @@ context::set_fss_data( void const * vp,
                        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);
         }