]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/asio/example/cpp11/executors/priority_scheduler.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / asio / example / cpp11 / executors / priority_scheduler.cpp
index 7c9bc80d709264abb31bce839b09d967d66c98c9..c73861bf19c0b44fa945e3836e50b02097866e83 100644 (file)
@@ -8,6 +8,7 @@
 
 using boost::asio::dispatch;
 using boost::asio::execution_context;
+namespace execution = boost::asio::execution;
 
 class priority_scheduler : public execution_context
 {
@@ -21,47 +22,20 @@ public:
     {
     }
 
-    priority_scheduler& context() const noexcept
+    priority_scheduler& query(execution::context_t) const noexcept
     {
       return context_;
     }
 
-    void on_work_started() const noexcept
+    template <class Func>
+    void execute(Func f) const
     {
-      // This executor doesn't count work. Instead, the scheduler simply runs
-      // until explicitly stopped.
-    }
-
-    void on_work_finished() const noexcept
-    {
-      // This executor doesn't count work. Instead, the scheduler simply runs
-      // until explicitly stopped.
-    }
-
-    template <class Func, class Alloc>
-    void dispatch(Func&& f, const Alloc& a) const
-    {
-      post(std::forward<Func>(f), a);
-    }
-
-    template <class Func, class Alloc>
-    void post(Func f, const Alloc& a) const
-    {
-      auto p(std::allocate_shared<item<Func>>(
-            typename std::allocator_traits<
-              Alloc>::template rebind_alloc<char>(a),
-            priority_, std::move(f)));
+      auto p(std::make_shared<item<Func>>(priority_, std::move(f)));
       std::lock_guard<std::mutex> lock(context_.mutex_);
       context_.queue_.push(p);
       context_.condition_.notify_one();
     }
 
-    template <class Func, class Alloc>
-    void defer(Func&& f, const Alloc& a) const
-    {
-      post(std::forward<Func>(f), a);
-    }
-
     friend bool operator==(const executor_type& a,
         const executor_type& b) noexcept
     {