]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/beast/test/beast/core/async_base.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / beast / test / beast / core / async_base.cpp
index 303cbc754e59a066573f61e321074ec29d7dc361..2125d4e77e35b6b022e5e93998ebf277f116e373 100644 (file)
@@ -25,6 +25,7 @@
 #include <boost/core/ignore_unused.hpp>
 #include <stdexcept>
 
+
 //------------------------------------------------------------------------------
 
 namespace boost {
@@ -32,6 +33,52 @@ namespace beast {
 
 namespace {
 
+#if defined(BOOST_ASIO_NO_TS_EXECUTORS)
+struct ex1_type
+{
+
+    net::execution_context &
+    query(net::execution::context_t c) const noexcept
+    { return *reinterpret_cast<net::execution_context *>(0); }
+
+    net::execution::blocking_t
+    query(net::execution::blocking_t) const noexcept
+    { return net::execution::blocking; };
+
+    net::execution::outstanding_work_t
+    query(net::execution::outstanding_work_t w) const noexcept
+    { return net::execution::outstanding_work; }
+
+    ex1_type
+    require(net::execution::blocking_t::possibly_t b) const
+    { return *this; }
+
+    ex1_type
+    require(net::execution::blocking_t::never_t b) const
+    { return *this; };
+
+    ex1_type
+    prefer(net::execution::outstanding_work_t::untracked_t w) const
+    { return *this; };
+
+    ex1_type
+    prefer(net::execution::outstanding_work_t::tracked_t w) const
+    { return *this; };
+
+    template<class F>
+    void
+    execute(F &&) const
+    {}
+
+    bool
+    operator==(ex1_type const &) const noexcept
+    { return true; }
+    bool
+    operator!=(ex1_type const &) const noexcept
+    { return false; }
+};
+BOOST_STATIC_ASSERT(net::execution::is_executor<ex1_type>::value);
+#else
 struct ex1_type
 {
     void* context() { return nullptr; }
@@ -41,6 +88,9 @@ struct ex1_type
     template<class F> void post(F&&) {}
     template<class F> void defer(F&&) {}
 };
+BOOST_STATIC_ASSERT(net::is_executor<ex1_type>::value);
+#endif
+
 
 struct no_alloc
 {
@@ -430,11 +480,13 @@ public:
         }
         {
             net::io_context ioc;
-            async_base<
-                test::handler,
-                net::io_context::executor_type> op(
-                    test::any_handler(), ioc.get_executor());
-            op.complete(false);
+            auto op = new
+                async_base<
+                    test::handler,
+                    net::io_context::executor_type>(
+                        test::any_handler(), ioc.get_executor());
+            op->complete(false);
+            delete op;
             ioc.run();
         }
         {
@@ -506,12 +558,13 @@ public:
             net::io_context ioc1;
             net::io_context ioc2;
             auto h = net::bind_executor(ioc2, test::any_handler());
-            stable_async_base<
+            auto op = new stable_async_base<
                 decltype(h),
-                net::io_context::executor_type> op(
+                net::io_context::executor_type>(
                     std::move(h),
                     ioc1.get_executor());
-            op.complete(false);
+            op->complete(false);
+            delete op;
             BEAST_EXPECT(ioc1.run() == 0);
             BEAST_EXPECT(ioc2.run() == 1);
         }
@@ -585,7 +638,7 @@ public:
     //--------------------------------------------------------------------------
 
     // Asynchronously read into a buffer until the buffer is full, or an error occurs
-    template<class AsyncReadStream, class ReadHandler>
+    template<class AsyncReadStream, BOOST_BEAST_ASYNC_TPARAM2 ReadHandler>
     typename net::async_result<ReadHandler, void(error_code, std::size_t)>::return_type
     async_read(AsyncReadStream& stream, net::mutable_buffer buffer, ReadHandler&& handler)
     {
@@ -678,7 +731,9 @@ public:
                 : base_type(std::move(handler), stream.get_executor())
                 , stream_(stream)
                 , repeats_(repeats)
-                , data_(allocate_stable<temporary_data>(*this, std::move(message), stream.get_executor().context()))
+                , data_(allocate_stable<temporary_data>(*this,
+                    std::move(message),
+                    net::query(stream.get_executor(), net::execution::context)))
             {
                 (*this)(); // start the operation
             }