]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/asio/test/serial_port.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / asio / test / serial_port.cpp
index e018be96e2b4f034f4a8dd6da5ab577c1e075bb8..a2ba204d35063bd3c2484fa377937a837405f7b3 100644 (file)
@@ -2,7 +2,7 @@
 // serial_port.cpp
 // ~~~~~~~~~~~~~~~
 //
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -18,7 +18,7 @@
 #include <boost/asio/serial_port.hpp>
 
 #include "archetypes/async_result.hpp"
-#include <boost/asio/io_service.hpp>
+#include <boost/asio/io_context.hpp>
 #include "unit_test.hpp"
 
 //------------------------------------------------------------------------------
 
 namespace serial_port_compile {
 
-void write_some_handler(const boost::system::error_code&, std::size_t)
+struct write_some_handler
 {
-}
+  write_some_handler() {}
+  void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+  write_some_handler(write_some_handler&&) {}
+private:
+  write_some_handler(const write_some_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
 
-void read_some_handler(const boost::system::error_code&, std::size_t)
+struct read_some_handler
 {
-}
+  read_some_handler() {}
+  void operator()(const boost::system::error_code&, std::size_t) {}
+#if defined(BOOST_ASIO_HAS_MOVE)
+  read_some_handler(read_some_handler&&) {}
+private:
+  read_some_handler(const read_some_handler&);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+};
 
 void test()
 {
@@ -45,7 +59,7 @@ void test()
 
   try
   {
-    io_service ios;
+    io_context ioc;
     char mutable_char_buffer[128] = "";
     const char const_char_buffer[128] = "";
     serial_port::baud_rate serial_port_option;
@@ -54,10 +68,10 @@ void test()
 
     // basic_serial_port constructors.
 
-    serial_port port1(ios);
-    serial_port port2(ios, "null");
+    serial_port port1(ioc);
+    serial_port port2(ioc, "null");
     serial_port::native_handle_type native_port1 = port1.native_handle();
-    serial_port port3(ios, native_port1);
+    serial_port port3(ioc, native_port1);
 
 #if defined(BOOST_ASIO_HAS_MOVE)
     serial_port port4(std::move(port3));
@@ -66,14 +80,22 @@ void test()
     // basic_serial_port operators.
 
 #if defined(BOOST_ASIO_HAS_MOVE)
-    port1 = serial_port(ios);
+    port1 = serial_port(ioc);
     port1 = std::move(port2);
 #endif // defined(BOOST_ASIO_HAS_MOVE)
 
     // basic_io_object functions.
 
-    io_service& ios_ref = port1.get_io_service();
-    (void)ios_ref;
+    serial_port::executor_type ex = port1.get_executor();
+    (void)ex;
+
+#if !defined(BOOST_ASIO_NO_DEPRECATED)
+    io_context& ioc_ref = port1.get_io_context();
+    (void)ioc_ref;
+
+    io_context& ioc_ref2 = port1.get_io_service();
+    (void)ioc_ref2;
+#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
 
     // basic_serial_port functions.
 
@@ -98,12 +120,9 @@ void test()
     port1.close();
     port1.close(ec);
 
-    serial_port::native_type native_port4 = port1.native();
+    serial_port::native_handle_type native_port4 = port1.native_handle();
     (void)native_port4;
 
-    serial_port::native_handle_type native_port5 = port1.native_handle();
-    (void)native_port5;
-
     port1.cancel();
     port1.cancel(ec);
 
@@ -121,8 +140,8 @@ void test()
     port1.write_some(buffer(mutable_char_buffer), ec);
     port1.write_some(buffer(const_char_buffer), ec);
 
-    port1.async_write_some(buffer(mutable_char_buffer), &write_some_handler);
-    port1.async_write_some(buffer(const_char_buffer), &write_some_handler);
+    port1.async_write_some(buffer(mutable_char_buffer), write_some_handler());
+    port1.async_write_some(buffer(const_char_buffer), write_some_handler());
     int i1 = port1.async_write_some(buffer(mutable_char_buffer), lazy);
     (void)i1;
     int i2 = port1.async_write_some(buffer(const_char_buffer), lazy);
@@ -131,7 +150,7 @@ void test()
     port1.read_some(buffer(mutable_char_buffer));
     port1.read_some(buffer(mutable_char_buffer), ec);
 
-    port1.async_read_some(buffer(mutable_char_buffer), &read_some_handler);
+    port1.async_read_some(buffer(mutable_char_buffer), read_some_handler());
     int i3 = port1.async_read_some(buffer(mutable_char_buffer), lazy);
     (void)i3;
   }