diff options
Diffstat (limited to '3rdparty/asio/src/examples')
355 files changed, 21840 insertions, 9269 deletions
diff --git a/3rdparty/asio/src/examples/cpp03/Makefile.am b/3rdparty/asio/src/examples/cpp03/Makefile.am deleted file mode 100644 index adacab88ef6..00000000000 --- a/3rdparty/asio/src/examples/cpp03/Makefile.am +++ /dev/null @@ -1,250 +0,0 @@ -AUTOMAKE_OPTIONS = subdir-objects - -if SEPARATE_COMPILATION -noinst_LIBRARIES = libasio.a -libasio_a_SOURCES = ../../asio.cpp -if HAVE_OPENSSL -libasio_a_SOURCES += ../../asio_ssl.cpp -endif -LDADD = libasio.a -endif - -noinst_PROGRAMS = \ - allocation/server \ - buffers/reference_counted \ - chat/chat_client \ - chat/chat_server \ - echo/async_tcp_echo_server \ - echo/async_udp_echo_server \ - echo/blocking_tcp_echo_client \ - echo/blocking_tcp_echo_server \ - echo/blocking_udp_echo_client \ - echo/blocking_udp_echo_server \ - http/client/async_client \ - http/client/sync_client \ - http/server/http_server \ - http/server2/http_server \ - http/server3/http_server \ - http/server4/http_server \ - icmp/ping \ - invocation/prioritised_handlers \ - iostreams/daytime_client \ - iostreams/daytime_server \ - iostreams/http_client \ - multicast/receiver \ - multicast/sender \ - nonblocking/third_party_lib \ - porthopper/client \ - porthopper/server \ - services/daytime_client \ - socks4/sync_client \ - timeouts/async_tcp_client \ - timeouts/blocking_tcp_client \ - timeouts/blocking_udp_client \ - timeouts/server \ - timers/time_t_timer \ - tutorial/timer1/timer \ - tutorial/timer2/timer \ - tutorial/timer3/timer \ - tutorial/timer4/timer \ - tutorial/timer5/timer \ - tutorial/daytime1/client \ - tutorial/daytime2/server \ - tutorial/daytime3/server \ - tutorial/daytime4/client \ - tutorial/daytime5/server \ - tutorial/daytime6/server \ - tutorial/daytime7/server - -if !WINDOWS_TARGET -noinst_PROGRAMS += \ - chat/posix_chat_client \ - fork/daemon \ - fork/process_per_connection \ - local/connect_pair \ - local/iostream_client \ - local/stream_server \ - local/stream_client -endif - -if WINDOWS_TARGET -noinst_PROGRAMS += \ - windows/transmit_file -endif - -if HAVE_OPENSSL -noinst_PROGRAMS += \ - ssl/client \ - ssl/server -endif - -if HAVE_BOOST_COROUTINE -noinst_PROGRAMS += \ - spawn/echo_server \ - spawn/parallel_grep -endif - -noinst_HEADERS = \ - chat/chat_message.hpp \ - services/basic_logger.hpp \ - services/logger.hpp \ - services/logger_service.hpp - -AM_CXXFLAGS = -I$(srcdir)/../../../include - -allocation_server_SOURCES = allocation/server.cpp -buffers_reference_counted_SOURCES = buffers/reference_counted.cpp -chat_chat_client_SOURCES = chat/chat_client.cpp -chat_chat_server_SOURCES = chat/chat_server.cpp -echo_async_tcp_echo_server_SOURCES = echo/async_tcp_echo_server.cpp -echo_async_udp_echo_server_SOURCES = echo/async_udp_echo_server.cpp -echo_blocking_tcp_echo_client_SOURCES = echo/blocking_tcp_echo_client.cpp -echo_blocking_tcp_echo_server_SOURCES = echo/blocking_tcp_echo_server.cpp -echo_blocking_udp_echo_client_SOURCES = echo/blocking_udp_echo_client.cpp -echo_blocking_udp_echo_server_SOURCES = echo/blocking_udp_echo_server.cpp -http_client_async_client_SOURCES = http/client/async_client.cpp -http_client_sync_client_SOURCES = http/client/sync_client.cpp -http_server_http_server_SOURCES = \ - http/server/connection.cpp \ - http/server/connection_manager.cpp \ - http/server/main.cpp \ - http/server/mime_types.cpp \ - http/server/reply.cpp \ - http/server/request_handler.cpp \ - http/server/request_parser.cpp \ - http/server/server.cpp -http_server2_http_server_SOURCES = \ - http/server2/connection.cpp \ - http/server2/io_context_pool.cpp \ - http/server2/main.cpp \ - http/server2/mime_types.cpp \ - http/server2/reply.cpp \ - http/server2/request_handler.cpp \ - http/server2/request_parser.cpp \ - http/server2/server.cpp -http_server3_http_server_SOURCES = \ - http/server3/connection.cpp \ - http/server3/main.cpp \ - http/server3/mime_types.cpp \ - http/server3/reply.cpp \ - http/server3/request_handler.cpp \ - http/server3/request_parser.cpp \ - http/server3/server.cpp -http_server4_http_server_SOURCES = \ - http/server4/file_handler.cpp \ - http/server4/main.cpp \ - http/server4/mime_types.cpp \ - http/server4/reply.cpp \ - http/server4/request_parser.cpp \ - http/server4/server.cpp -icmp_ping_SOURCES = icmp/ping.cpp -invocation_prioritised_handlers_SOURCES = invocation/prioritised_handlers.cpp -iostreams_daytime_client_SOURCES = iostreams/daytime_client.cpp -iostreams_daytime_server_SOURCES = iostreams/daytime_server.cpp -iostreams_http_client_SOURCES = iostreams/http_client.cpp -multicast_receiver_SOURCES = multicast/receiver.cpp -multicast_sender_SOURCES = multicast/sender.cpp -nonblocking_third_party_lib_SOURCES = nonblocking/third_party_lib.cpp -porthopper_client_SOURCES = porthopper/client.cpp -porthopper_server_SOURCES = porthopper/server.cpp -services_daytime_client_SOURCES = \ - services/daytime_client.cpp \ - services/logger_service.cpp -socks4_sync_client_SOURCES = socks4/sync_client.cpp -timeouts_async_tcp_client_SOURCES = timeouts/async_tcp_client.cpp -timeouts_blocking_tcp_client_SOURCES = timeouts/blocking_tcp_client.cpp -timeouts_blocking_udp_client_SOURCES = timeouts/blocking_udp_client.cpp -timeouts_server_SOURCES = timeouts/server.cpp -timers_time_t_timer_SOURCES = timers/time_t_timer.cpp -tutorial_timer1_timer_SOURCES = tutorial/timer1/timer.cpp -tutorial_timer2_timer_SOURCES = tutorial/timer2/timer.cpp -tutorial_timer3_timer_SOURCES = tutorial/timer3/timer.cpp -tutorial_timer4_timer_SOURCES = tutorial/timer4/timer.cpp -tutorial_timer5_timer_SOURCES = tutorial/timer5/timer.cpp -tutorial_daytime1_client_SOURCES = tutorial/daytime1/client.cpp -tutorial_daytime2_server_SOURCES = tutorial/daytime2/server.cpp -tutorial_daytime3_server_SOURCES = tutorial/daytime3/server.cpp -tutorial_daytime4_client_SOURCES = tutorial/daytime4/client.cpp -tutorial_daytime5_server_SOURCES = tutorial/daytime5/server.cpp -tutorial_daytime6_server_SOURCES = tutorial/daytime6/server.cpp -tutorial_daytime7_server_SOURCES = tutorial/daytime7/server.cpp - -if !WINDOWS_TARGET -chat_posix_chat_client_SOURCES = chat/posix_chat_client.cpp -fork_daemon_SOURCES = fork/daemon.cpp -fork_process_per_connection_SOURCES = fork/process_per_connection.cpp -local_connect_pair_SOURCES = local/connect_pair.cpp -local_iostream_client_SOURCES = local/iostream_client.cpp -local_stream_server_SOURCES = local/stream_server.cpp -local_stream_client_SOURCES = local/stream_client.cpp -endif - -if WINDOWS_TARGET -windows_transmit_file_SOURCES = windows/transmit_file.cpp -endif - -if HAVE_OPENSSL -ssl_client_SOURCES = ssl/client.cpp -ssl_server_SOURCES = ssl/server.cpp -endif - -if HAVE_BOOST_COROUTINE -spawn_echo_server_SOURCES = spawn/echo_server.cpp -spawn_echo_server_LDADD = $(LDADD) -lboost_coroutine -lboost_context -lboost_thread -lboost_chrono -lboost_system -spawn_parallel_grep_SOURCES = spawn/parallel_grep.cpp -spawn_parallel_grep_LDADD = $(LDADD) -lboost_coroutine -lboost_context -lboost_thread -lboost_chrono -lboost_system -endif - -EXTRA_DIST = \ - http/server/connection.hpp \ - http/server/connection_manager.hpp \ - http/server/header.hpp \ - http/server/mime_types.hpp \ - http/server/reply.hpp \ - http/server/request.hpp \ - http/server/request_handler.hpp \ - http/server/request_parser.hpp \ - http/server/server.hpp \ - http/server2/connection.hpp \ - http/server2/io_context_pool.hpp \ - http/server2/header.hpp \ - http/server2/mime_types.hpp \ - http/server2/reply.hpp \ - http/server2/request.hpp \ - http/server2/request_handler.hpp \ - http/server2/request_parser.hpp \ - http/server2/server.hpp \ - http/server3/connection.hpp \ - http/server3/header.hpp \ - http/server3/mime_types.hpp \ - http/server3/reply.hpp \ - http/server3/request.hpp \ - http/server3/request_handler.hpp \ - http/server3/request_parser.hpp \ - http/server3/server.hpp \ - http/server4/file_handler.hpp \ - http/server4/header.hpp \ - http/server4/mime_types.hpp \ - http/server4/reply.hpp \ - http/server4/request.hpp \ - http/server4/request_parser.hpp \ - http/server4/server.hpp \ - icmp/icmp_header.hpp \ - icmp/ipv4_header.hpp \ - porthopper/protocol.hpp \ - serialization/client.cpp \ - serialization/server.cpp \ - serialization/connection.hpp \ - serialization/stock.hpp \ - services/basic_logger.hpp \ - services/logger.hpp \ - services/logger_service.hpp \ - socks4/socks4.hpp \ - ssl/README \ - ssl/ca.pem \ - ssl/server.pem \ - ssl/dh2048.pem \ - timers/tick_count_timer.cpp - -MAINTAINERCLEANFILES = \ - $(srcdir)/Makefile.in diff --git a/3rdparty/asio/src/examples/cpp03/allocation/.gitignore b/3rdparty/asio/src/examples/cpp03/allocation/.gitignore deleted file mode 100644 index 180ba886e58..00000000000 --- a/3rdparty/asio/src/examples/cpp03/allocation/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -server -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/allocation/server.cpp b/3rdparty/asio/src/examples/cpp03/allocation/server.cpp deleted file mode 100644 index e26eb564918..00000000000 --- a/3rdparty/asio/src/examples/cpp03/allocation/server.cpp +++ /dev/null @@ -1,238 +0,0 @@ -// -// server.cpp -// ~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdlib> -#include <iostream> -#include <boost/aligned_storage.hpp> -#include <boost/array.hpp> -#include <boost/bind.hpp> -#include <boost/enable_shared_from_this.hpp> -#include <boost/noncopyable.hpp> -#include <boost/shared_ptr.hpp> -#include "asio.hpp" - -using asio::ip::tcp; - -// Class to manage the memory to be used for handler-based custom allocation. -// It contains a single block of memory which may be returned for allocation -// requests. If the memory is in use when an allocation request is made, the -// allocator delegates allocation to the global heap. -class handler_allocator - : private boost::noncopyable -{ -public: - handler_allocator() - : in_use_(false) - { - } - - void* allocate(std::size_t size) - { - if (!in_use_ && size < storage_.size) - { - in_use_ = true; - return storage_.address(); - } - else - { - return ::operator new(size); - } - } - - void deallocate(void* pointer) - { - if (pointer == storage_.address()) - { - in_use_ = false; - } - else - { - ::operator delete(pointer); - } - } - -private: - // Storage space used for handler-based custom memory allocation. - boost::aligned_storage<1024> storage_; - - // Whether the handler-based custom allocation storage has been used. - bool in_use_; -}; - -// Wrapper class template for handler objects to allow handler memory -// allocation to be customised. Calls to operator() are forwarded to the -// encapsulated handler. -template <typename Handler> -class custom_alloc_handler -{ -public: - custom_alloc_handler(handler_allocator& a, Handler h) - : allocator_(a), - handler_(h) - { - } - - template <typename Arg1> - void operator()(Arg1 arg1) - { - handler_(arg1); - } - - template <typename Arg1, typename Arg2> - void operator()(Arg1 arg1, Arg2 arg2) - { - handler_(arg1, arg2); - } - - friend void* asio_handler_allocate(std::size_t size, - custom_alloc_handler<Handler>* this_handler) - { - return this_handler->allocator_.allocate(size); - } - - friend void asio_handler_deallocate(void* pointer, std::size_t /*size*/, - custom_alloc_handler<Handler>* this_handler) - { - this_handler->allocator_.deallocate(pointer); - } - -private: - handler_allocator& allocator_; - Handler handler_; -}; - -// Helper function to wrap a handler object to add custom allocation. -template <typename Handler> -inline custom_alloc_handler<Handler> make_custom_alloc_handler( - handler_allocator& a, Handler h) -{ - return custom_alloc_handler<Handler>(a, h); -} - -class session - : public boost::enable_shared_from_this<session> -{ -public: - session(asio::io_context& io_context) - : socket_(io_context) - { - } - - tcp::socket& socket() - { - return socket_; - } - - void start() - { - socket_.async_read_some(asio::buffer(data_), - make_custom_alloc_handler(allocator_, - boost::bind(&session::handle_read, - shared_from_this(), - asio::placeholders::error, - asio::placeholders::bytes_transferred))); - } - - void handle_read(const asio::error_code& error, - size_t bytes_transferred) - { - if (!error) - { - asio::async_write(socket_, - asio::buffer(data_, bytes_transferred), - make_custom_alloc_handler(allocator_, - boost::bind(&session::handle_write, - shared_from_this(), - asio::placeholders::error))); - } - } - - void handle_write(const asio::error_code& error) - { - if (!error) - { - socket_.async_read_some(asio::buffer(data_), - make_custom_alloc_handler(allocator_, - boost::bind(&session::handle_read, - shared_from_this(), - asio::placeholders::error, - asio::placeholders::bytes_transferred))); - } - } - -private: - // The socket used to communicate with the client. - tcp::socket socket_; - - // Buffer used to store data received from the client. - boost::array<char, 1024> data_; - - // The allocator to use for handler-based custom memory allocation. - handler_allocator allocator_; -}; - -typedef boost::shared_ptr<session> session_ptr; - -class server -{ -public: - server(asio::io_context& io_context, short port) - : io_context_(io_context), - acceptor_(io_context, tcp::endpoint(tcp::v4(), port)) - { - session_ptr new_session(new session(io_context_)); - acceptor_.async_accept(new_session->socket(), - boost::bind(&server::handle_accept, this, new_session, - asio::placeholders::error)); - } - - void handle_accept(session_ptr new_session, - const asio::error_code& error) - { - if (!error) - { - new_session->start(); - } - - new_session.reset(new session(io_context_)); - acceptor_.async_accept(new_session->socket(), - boost::bind(&server::handle_accept, this, new_session, - asio::placeholders::error)); - } - -private: - asio::io_context& io_context_; - tcp::acceptor acceptor_; -}; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 2) - { - std::cerr << "Usage: server <port>\n"; - return 1; - } - - asio::io_context io_context; - - using namespace std; // For atoi. - server s(io_context, atoi(argv[1])); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/buffers/.gitignore b/3rdparty/asio/src/examples/cpp03/buffers/.gitignore deleted file mode 100644 index abe68c665f5..00000000000 --- a/3rdparty/asio/src/examples/cpp03/buffers/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -reference_counted -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/buffers/reference_counted.cpp b/3rdparty/asio/src/examples/cpp03/buffers/reference_counted.cpp deleted file mode 100644 index 9f7455cdbbd..00000000000 --- a/3rdparty/asio/src/examples/cpp03/buffers/reference_counted.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// -// reference_counted.cpp -// ~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <asio.hpp> -#include <boost/bind.hpp> -#include <boost/enable_shared_from_this.hpp> -#include <boost/shared_ptr.hpp> -#include <iostream> -#include <vector> - -using asio::ip::tcp; - -// A reference-counted non-modifiable buffer class. -class shared_const_buffer -{ -public: - // Construct from a std::string. - explicit shared_const_buffer(const std::string& data) - : data_(new std::vector<char>(data.begin(), data.end())), - buffer_(asio::buffer(*data_)) - { - } - - // Implement the ConstBufferSequence requirements. - typedef asio::const_buffer value_type; - typedef const asio::const_buffer* const_iterator; - const asio::const_buffer* begin() const { return &buffer_; } - const asio::const_buffer* end() const { return &buffer_ + 1; } - -private: - boost::shared_ptr<std::vector<char> > data_; - asio::const_buffer buffer_; -}; - -class session - : public boost::enable_shared_from_this<session> -{ -public: - session(asio::io_context& io_context) - : socket_(io_context) - { - } - - tcp::socket& socket() - { - return socket_; - } - - void start() - { - using namespace std; // For time_t, time and ctime. - time_t now = time(0); - shared_const_buffer buffer(ctime(&now)); - asio::async_write(socket_, buffer, - boost::bind(&session::handle_write, shared_from_this())); - } - - void handle_write() - { - } - -private: - // The socket used to communicate with the client. - tcp::socket socket_; -}; - -typedef boost::shared_ptr<session> session_ptr; - -class server -{ -public: - server(asio::io_context& io_context, short port) - : io_context_(io_context), - acceptor_(io_context, tcp::endpoint(tcp::v4(), port)) - { - session_ptr new_session(new session(io_context_)); - acceptor_.async_accept(new_session->socket(), - boost::bind(&server::handle_accept, this, new_session, - asio::placeholders::error)); - } - - void handle_accept(session_ptr new_session, - const asio::error_code& error) - { - if (!error) - { - new_session->start(); - } - - new_session.reset(new session(io_context_)); - acceptor_.async_accept(new_session->socket(), - boost::bind(&server::handle_accept, this, new_session, - asio::placeholders::error)); - } - -private: - asio::io_context& io_context_; - tcp::acceptor acceptor_; -}; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 2) - { - std::cerr << "Usage: reference_counted <port>\n"; - return 1; - } - - asio::io_context io_context; - - using namespace std; // For atoi. - server s(io_context, atoi(argv[1])); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/chat/.gitignore b/3rdparty/asio/src/examples/cpp03/chat/.gitignore deleted file mode 100644 index 0882fa6ced3..00000000000 --- a/3rdparty/asio/src/examples/cpp03/chat/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/chat/chat_client.cpp b/3rdparty/asio/src/examples/cpp03/chat/chat_client.cpp deleted file mode 100644 index 9dd16145b81..00000000000 --- a/3rdparty/asio/src/examples/cpp03/chat/chat_client.cpp +++ /dev/null @@ -1,177 +0,0 @@ -// -// chat_client.cpp -// ~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdlib> -#include <deque> -#include <iostream> -#include <boost/bind.hpp> -#include "asio.hpp" -#include "chat_message.hpp" - -using asio::ip::tcp; - -typedef std::deque<chat_message> chat_message_queue; - -class chat_client -{ -public: - chat_client(asio::io_context& io_context, - const tcp::resolver::results_type& endpoints) - : io_context_(io_context), - socket_(io_context) - { - asio::async_connect(socket_, endpoints, - boost::bind(&chat_client::handle_connect, this, - asio::placeholders::error)); - } - - void write(const chat_message& msg) - { - asio::post(io_context_, - boost::bind(&chat_client::do_write, this, msg)); - } - - void close() - { - asio::post(io_context_, - boost::bind(&chat_client::do_close, this)); - } - -private: - - void handle_connect(const asio::error_code& error) - { - if (!error) - { - asio::async_read(socket_, - asio::buffer(read_msg_.data(), chat_message::header_length), - boost::bind(&chat_client::handle_read_header, this, - asio::placeholders::error)); - } - } - - void handle_read_header(const asio::error_code& error) - { - if (!error && read_msg_.decode_header()) - { - asio::async_read(socket_, - asio::buffer(read_msg_.body(), read_msg_.body_length()), - boost::bind(&chat_client::handle_read_body, this, - asio::placeholders::error)); - } - else - { - do_close(); - } - } - - void handle_read_body(const asio::error_code& error) - { - if (!error) - { - std::cout.write(read_msg_.body(), read_msg_.body_length()); - std::cout << "\n"; - asio::async_read(socket_, - asio::buffer(read_msg_.data(), chat_message::header_length), - boost::bind(&chat_client::handle_read_header, this, - asio::placeholders::error)); - } - else - { - do_close(); - } - } - - void do_write(chat_message msg) - { - bool write_in_progress = !write_msgs_.empty(); - write_msgs_.push_back(msg); - if (!write_in_progress) - { - asio::async_write(socket_, - asio::buffer(write_msgs_.front().data(), - write_msgs_.front().length()), - boost::bind(&chat_client::handle_write, this, - asio::placeholders::error)); - } - } - - void handle_write(const asio::error_code& error) - { - if (!error) - { - write_msgs_.pop_front(); - if (!write_msgs_.empty()) - { - asio::async_write(socket_, - asio::buffer(write_msgs_.front().data(), - write_msgs_.front().length()), - boost::bind(&chat_client::handle_write, this, - asio::placeholders::error)); - } - } - else - { - do_close(); - } - } - - void do_close() - { - socket_.close(); - } - -private: - asio::io_context& io_context_; - tcp::socket socket_; - chat_message read_msg_; - chat_message_queue write_msgs_; -}; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 3) - { - std::cerr << "Usage: chat_client <host> <port>\n"; - return 1; - } - - asio::io_context io_context; - - tcp::resolver resolver(io_context); - tcp::resolver::results_type endpoints = resolver.resolve(argv[1], argv[2]); - - chat_client c(io_context, endpoints); - - asio::thread t(boost::bind(&asio::io_context::run, &io_context)); - - char line[chat_message::max_body_length + 1]; - while (std::cin.getline(line, chat_message::max_body_length + 1)) - { - using namespace std; // For strlen and memcpy. - chat_message msg; - msg.body_length(strlen(line)); - memcpy(msg.body(), line, msg.body_length()); - msg.encode_header(); - c.write(msg); - } - - c.close(); - t.join(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/chat/chat_message.hpp b/3rdparty/asio/src/examples/cpp03/chat/chat_message.hpp deleted file mode 100644 index ceeef2f03f8..00000000000 --- a/3rdparty/asio/src/examples/cpp03/chat/chat_message.hpp +++ /dev/null @@ -1,93 +0,0 @@ -// -// chat_message.hpp -// ~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef CHAT_MESSAGE_HPP -#define CHAT_MESSAGE_HPP - -#include <cstdio> -#include <cstdlib> -#include <cstring> - -class chat_message -{ -public: - enum { header_length = 4 }; - enum { max_body_length = 512 }; - - chat_message() - : body_length_(0) - { - } - - const char* data() const - { - return data_; - } - - char* data() - { - return data_; - } - - size_t length() const - { - return header_length + body_length_; - } - - const char* body() const - { - return data_ + header_length; - } - - char* body() - { - return data_ + header_length; - } - - size_t body_length() const - { - return body_length_; - } - - void body_length(size_t new_length) - { - body_length_ = new_length; - if (body_length_ > max_body_length) - body_length_ = max_body_length; - } - - bool decode_header() - { - using namespace std; // For strncat and atoi. - char header[header_length + 1] = ""; - strncat(header, data_, header_length); - body_length_ = atoi(header); - if (body_length_ > max_body_length) - { - body_length_ = 0; - return false; - } - return true; - } - - void encode_header() - { - using namespace std; // For sprintf and memcpy. - char header[header_length + 1] = ""; - sprintf(header, "%4d", static_cast<int>(body_length_)); - memcpy(data_, header, header_length); - } - -private: - char data_[header_length + max_body_length]; - size_t body_length_; -}; - -#endif // CHAT_MESSAGE_HPP diff --git a/3rdparty/asio/src/examples/cpp03/chat/chat_server.cpp b/3rdparty/asio/src/examples/cpp03/chat/chat_server.cpp deleted file mode 100644 index 902515b3b54..00000000000 --- a/3rdparty/asio/src/examples/cpp03/chat/chat_server.cpp +++ /dev/null @@ -1,247 +0,0 @@ -// -// chat_server.cpp -// ~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <algorithm> -#include <cstdlib> -#include <deque> -#include <iostream> -#include <list> -#include <set> -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> -#include "asio.hpp" -#include "chat_message.hpp" - -using asio::ip::tcp; - -//---------------------------------------------------------------------- - -typedef std::deque<chat_message> chat_message_queue; - -//---------------------------------------------------------------------- - -class chat_participant -{ -public: - virtual ~chat_participant() {} - virtual void deliver(const chat_message& msg) = 0; -}; - -typedef boost::shared_ptr<chat_participant> chat_participant_ptr; - -//---------------------------------------------------------------------- - -class chat_room -{ -public: - void join(chat_participant_ptr participant) - { - participants_.insert(participant); - std::for_each(recent_msgs_.begin(), recent_msgs_.end(), - boost::bind(&chat_participant::deliver, participant, _1)); - } - - void leave(chat_participant_ptr participant) - { - participants_.erase(participant); - } - - void deliver(const chat_message& msg) - { - recent_msgs_.push_back(msg); - while (recent_msgs_.size() > max_recent_msgs) - recent_msgs_.pop_front(); - - std::for_each(participants_.begin(), participants_.end(), - boost::bind(&chat_participant::deliver, _1, boost::ref(msg))); - } - -private: - std::set<chat_participant_ptr> participants_; - enum { max_recent_msgs = 100 }; - chat_message_queue recent_msgs_; -}; - -//---------------------------------------------------------------------- - -class chat_session - : public chat_participant, - public boost::enable_shared_from_this<chat_session> -{ -public: - chat_session(asio::io_context& io_context, chat_room& room) - : socket_(io_context), - room_(room) - { - } - - tcp::socket& socket() - { - return socket_; - } - - void start() - { - room_.join(shared_from_this()); - asio::async_read(socket_, - asio::buffer(read_msg_.data(), chat_message::header_length), - boost::bind( - &chat_session::handle_read_header, shared_from_this(), - asio::placeholders::error)); - } - - void deliver(const chat_message& msg) - { - bool write_in_progress = !write_msgs_.empty(); - write_msgs_.push_back(msg); - if (!write_in_progress) - { - asio::async_write(socket_, - asio::buffer(write_msgs_.front().data(), - write_msgs_.front().length()), - boost::bind(&chat_session::handle_write, shared_from_this(), - asio::placeholders::error)); - } - } - - void handle_read_header(const asio::error_code& error) - { - if (!error && read_msg_.decode_header()) - { - asio::async_read(socket_, - asio::buffer(read_msg_.body(), read_msg_.body_length()), - boost::bind(&chat_session::handle_read_body, shared_from_this(), - asio::placeholders::error)); - } - else - { - room_.leave(shared_from_this()); - } - } - - void handle_read_body(const asio::error_code& error) - { - if (!error) - { - room_.deliver(read_msg_); - asio::async_read(socket_, - asio::buffer(read_msg_.data(), chat_message::header_length), - boost::bind(&chat_session::handle_read_header, shared_from_this(), - asio::placeholders::error)); - } - else - { - room_.leave(shared_from_this()); - } - } - - void handle_write(const asio::error_code& error) - { - if (!error) - { - write_msgs_.pop_front(); - if (!write_msgs_.empty()) - { - asio::async_write(socket_, - asio::buffer(write_msgs_.front().data(), - write_msgs_.front().length()), - boost::bind(&chat_session::handle_write, shared_from_this(), - asio::placeholders::error)); - } - } - else - { - room_.leave(shared_from_this()); - } - } - -private: - tcp::socket socket_; - chat_room& room_; - chat_message read_msg_; - chat_message_queue write_msgs_; -}; - -typedef boost::shared_ptr<chat_session> chat_session_ptr; - -//---------------------------------------------------------------------- - -class chat_server -{ -public: - chat_server(asio::io_context& io_context, - const tcp::endpoint& endpoint) - : io_context_(io_context), - acceptor_(io_context, endpoint) - { - start_accept(); - } - - void start_accept() - { - chat_session_ptr new_session(new chat_session(io_context_, room_)); - acceptor_.async_accept(new_session->socket(), - boost::bind(&chat_server::handle_accept, this, new_session, - asio::placeholders::error)); - } - - void handle_accept(chat_session_ptr session, - const asio::error_code& error) - { - if (!error) - { - session->start(); - } - - start_accept(); - } - -private: - asio::io_context& io_context_; - tcp::acceptor acceptor_; - chat_room room_; -}; - -typedef boost::shared_ptr<chat_server> chat_server_ptr; -typedef std::list<chat_server_ptr> chat_server_list; - -//---------------------------------------------------------------------- - -int main(int argc, char* argv[]) -{ - try - { - if (argc < 2) - { - std::cerr << "Usage: chat_server <port> [<port> ...]\n"; - return 1; - } - - asio::io_context io_context; - - chat_server_list servers; - for (int i = 1; i < argc; ++i) - { - using namespace std; // For atoi. - tcp::endpoint endpoint(tcp::v4(), atoi(argv[i])); - chat_server_ptr server(new chat_server(io_context, endpoint)); - servers.push_back(server); - } - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/chat/posix_chat_client.cpp b/3rdparty/asio/src/examples/cpp03/chat/posix_chat_client.cpp deleted file mode 100644 index 91428825aad..00000000000 --- a/3rdparty/asio/src/examples/cpp03/chat/posix_chat_client.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// -// posix_chat_client.cpp -// ~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdlib> -#include <cstring> -#include <iostream> -#include <boost/array.hpp> -#include <boost/bind.hpp> -#include "asio.hpp" -#include "chat_message.hpp" - -#if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) - -using asio::ip::tcp; -namespace posix = asio::posix; - -class posix_chat_client -{ -public: - posix_chat_client(asio::io_context& io_context, - const tcp::resolver::results_type& endpoints) - : socket_(io_context), - input_(io_context, ::dup(STDIN_FILENO)), - output_(io_context, ::dup(STDOUT_FILENO)), - input_buffer_(chat_message::max_body_length) - { - asio::async_connect(socket_, endpoints, - boost::bind(&posix_chat_client::handle_connect, this, - asio::placeholders::error)); - } - -private: - - void handle_connect(const asio::error_code& error) - { - if (!error) - { - // Read the fixed-length header of the next message from the server. - asio::async_read(socket_, - asio::buffer(read_msg_.data(), chat_message::header_length), - boost::bind(&posix_chat_client::handle_read_header, this, - asio::placeholders::error)); - - // Read a line of input entered by the user. - asio::async_read_until(input_, input_buffer_, '\n', - boost::bind(&posix_chat_client::handle_read_input, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - } - - void handle_read_header(const asio::error_code& error) - { - if (!error && read_msg_.decode_header()) - { - // Read the variable-length body of the message from the server. - asio::async_read(socket_, - asio::buffer(read_msg_.body(), read_msg_.body_length()), - boost::bind(&posix_chat_client::handle_read_body, this, - asio::placeholders::error)); - } - else - { - close(); - } - } - - void handle_read_body(const asio::error_code& error) - { - if (!error) - { - // Write out the message we just received, terminated by a newline. - static char eol[] = { '\n' }; - boost::array<asio::const_buffer, 2> buffers = {{ - asio::buffer(read_msg_.body(), read_msg_.body_length()), - asio::buffer(eol) }}; - asio::async_write(output_, buffers, - boost::bind(&posix_chat_client::handle_write_output, this, - asio::placeholders::error)); - } - else - { - close(); - } - } - - void handle_write_output(const asio::error_code& error) - { - if (!error) - { - // Read the fixed-length header of the next message from the server. - asio::async_read(socket_, - asio::buffer(read_msg_.data(), chat_message::header_length), - boost::bind(&posix_chat_client::handle_read_header, this, - asio::placeholders::error)); - } - else - { - close(); - } - } - - void handle_read_input(const asio::error_code& error, - std::size_t length) - { - if (!error) - { - // Write the message (minus the newline) to the server. - write_msg_.body_length(length - 1); - input_buffer_.sgetn(write_msg_.body(), length - 1); - input_buffer_.consume(1); // Remove newline from input. - write_msg_.encode_header(); - asio::async_write(socket_, - asio::buffer(write_msg_.data(), write_msg_.length()), - boost::bind(&posix_chat_client::handle_write, this, - asio::placeholders::error)); - } - else if (error == asio::error::not_found) - { - // Didn't get a newline. Send whatever we have. - write_msg_.body_length(input_buffer_.size()); - input_buffer_.sgetn(write_msg_.body(), input_buffer_.size()); - write_msg_.encode_header(); - asio::async_write(socket_, - asio::buffer(write_msg_.data(), write_msg_.length()), - boost::bind(&posix_chat_client::handle_write, this, - asio::placeholders::error)); - } - else - { - close(); - } - } - - void handle_write(const asio::error_code& error) - { - if (!error) - { - // Read a line of input entered by the user. - asio::async_read_until(input_, input_buffer_, '\n', - boost::bind(&posix_chat_client::handle_read_input, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - else - { - close(); - } - } - - void close() - { - // Cancel all outstanding asynchronous operations. - socket_.close(); - input_.close(); - output_.close(); - } - -private: - tcp::socket socket_; - posix::stream_descriptor input_; - posix::stream_descriptor output_; - chat_message read_msg_; - chat_message write_msg_; - asio::streambuf input_buffer_; -}; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 3) - { - std::cerr << "Usage: posix_chat_client <host> <port>\n"; - return 1; - } - - asio::io_context io_context; - - tcp::resolver resolver(io_context); - tcp::resolver::results_type endpoints = resolver.resolve(argv[1], argv[2]); - - posix_chat_client c(io_context, endpoints); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} - -#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) -int main() {} -#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp03/echo/.gitignore b/3rdparty/asio/src/examples/cpp03/echo/.gitignore deleted file mode 100644 index 0882fa6ced3..00000000000 --- a/3rdparty/asio/src/examples/cpp03/echo/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/echo/async_tcp_echo_server.cpp b/3rdparty/asio/src/examples/cpp03/echo/async_tcp_echo_server.cpp deleted file mode 100644 index c26136e89b5..00000000000 --- a/3rdparty/asio/src/examples/cpp03/echo/async_tcp_echo_server.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// -// async_tcp_echo_server.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdlib> -#include <iostream> -#include <boost/bind.hpp> -#include "asio.hpp" - -using asio::ip::tcp; - -class session -{ -public: - session(asio::io_context& io_context) - : socket_(io_context) - { - } - - tcp::socket& socket() - { - return socket_; - } - - void start() - { - socket_.async_read_some(asio::buffer(data_, max_length), - boost::bind(&session::handle_read, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - -private: - void handle_read(const asio::error_code& error, - size_t bytes_transferred) - { - if (!error) - { - asio::async_write(socket_, - asio::buffer(data_, bytes_transferred), - boost::bind(&session::handle_write, this, - asio::placeholders::error)); - } - else - { - delete this; - } - } - - void handle_write(const asio::error_code& error) - { - if (!error) - { - socket_.async_read_some(asio::buffer(data_, max_length), - boost::bind(&session::handle_read, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - else - { - delete this; - } - } - - tcp::socket socket_; - enum { max_length = 1024 }; - char data_[max_length]; -}; - -class server -{ -public: - server(asio::io_context& io_context, short port) - : io_context_(io_context), - acceptor_(io_context, tcp::endpoint(tcp::v4(), port)) - { - start_accept(); - } - -private: - void start_accept() - { - session* new_session = new session(io_context_); - acceptor_.async_accept(new_session->socket(), - boost::bind(&server::handle_accept, this, new_session, - asio::placeholders::error)); - } - - void handle_accept(session* new_session, - const asio::error_code& error) - { - if (!error) - { - new_session->start(); - } - else - { - delete new_session; - } - - start_accept(); - } - - asio::io_context& io_context_; - tcp::acceptor acceptor_; -}; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 2) - { - std::cerr << "Usage: async_tcp_echo_server <port>\n"; - return 1; - } - - asio::io_context io_context; - - using namespace std; // For atoi. - server s(io_context, atoi(argv[1])); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/echo/async_udp_echo_server.cpp b/3rdparty/asio/src/examples/cpp03/echo/async_udp_echo_server.cpp deleted file mode 100644 index 851c46b0803..00000000000 --- a/3rdparty/asio/src/examples/cpp03/echo/async_udp_echo_server.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// -// async_udp_echo_server.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdlib> -#include <iostream> -#include <boost/bind.hpp> -#include "asio.hpp" - -using asio::ip::udp; - -class server -{ -public: - server(asio::io_context& io_context, short port) - : socket_(io_context, udp::endpoint(udp::v4(), port)) - { - socket_.async_receive_from( - asio::buffer(data_, max_length), sender_endpoint_, - boost::bind(&server::handle_receive_from, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - - void handle_receive_from(const asio::error_code& error, - size_t bytes_recvd) - { - if (!error && bytes_recvd > 0) - { - socket_.async_send_to( - asio::buffer(data_, bytes_recvd), sender_endpoint_, - boost::bind(&server::handle_send_to, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - else - { - socket_.async_receive_from( - asio::buffer(data_, max_length), sender_endpoint_, - boost::bind(&server::handle_receive_from, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - } - - void handle_send_to(const asio::error_code& /*error*/, - size_t /*bytes_sent*/) - { - socket_.async_receive_from( - asio::buffer(data_, max_length), sender_endpoint_, - boost::bind(&server::handle_receive_from, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - -private: - udp::socket socket_; - udp::endpoint sender_endpoint_; - enum { max_length = 1024 }; - char data_[max_length]; -}; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 2) - { - std::cerr << "Usage: async_udp_echo_server <port>\n"; - return 1; - } - - asio::io_context io_context; - - using namespace std; // For atoi. - server s(io_context, atoi(argv[1])); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/echo/blocking_tcp_echo_client.cpp b/3rdparty/asio/src/examples/cpp03/echo/blocking_tcp_echo_client.cpp deleted file mode 100644 index 224b9dbb1b2..00000000000 --- a/3rdparty/asio/src/examples/cpp03/echo/blocking_tcp_echo_client.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// -// blocking_tcp_echo_client.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdlib> -#include <cstring> -#include <iostream> -#include "asio.hpp" - -using asio::ip::tcp; - -enum { max_length = 1024 }; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 3) - { - std::cerr << "Usage: blocking_tcp_echo_client <host> <port>\n"; - return 1; - } - - asio::io_context io_context; - - tcp::resolver resolver(io_context); - tcp::resolver::results_type endpoints = - resolver.resolve(tcp::v4(), argv[1], argv[2]); - - tcp::socket s(io_context); - asio::connect(s, endpoints); - - using namespace std; // For strlen. - std::cout << "Enter message: "; - char request[max_length]; - std::cin.getline(request, max_length); - size_t request_length = strlen(request); - asio::write(s, asio::buffer(request, request_length)); - - char reply[max_length]; - size_t reply_length = asio::read(s, - asio::buffer(reply, request_length)); - std::cout << "Reply is: "; - std::cout.write(reply, reply_length); - std::cout << "\n"; - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/echo/blocking_tcp_echo_server.cpp b/3rdparty/asio/src/examples/cpp03/echo/blocking_tcp_echo_server.cpp deleted file mode 100644 index 163dc2a392c..00000000000 --- a/3rdparty/asio/src/examples/cpp03/echo/blocking_tcp_echo_server.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -// blocking_tcp_echo_server.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdlib> -#include <iostream> -#include <boost/bind.hpp> -#include <boost/smart_ptr.hpp> -#include "asio.hpp" - -using asio::ip::tcp; - -const int max_length = 1024; - -typedef boost::shared_ptr<tcp::socket> socket_ptr; - -void session(socket_ptr sock) -{ - try - { - for (;;) - { - char data[max_length]; - - asio::error_code error; - size_t length = sock->read_some(asio::buffer(data), error); - if (error == asio::error::eof) - break; // Connection closed cleanly by peer. - else if (error) - throw asio::system_error(error); // Some other error. - - asio::write(*sock, asio::buffer(data, length)); - } - } - catch (std::exception& e) - { - std::cerr << "Exception in thread: " << e.what() << "\n"; - } -} - -void server(asio::io_context& io_context, unsigned short port) -{ - tcp::acceptor a(io_context, tcp::endpoint(tcp::v4(), port)); - for (;;) - { - socket_ptr sock(new tcp::socket(io_context)); - a.accept(*sock); - asio::thread t(boost::bind(session, sock)); - } -} - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 2) - { - std::cerr << "Usage: blocking_tcp_echo_server <port>\n"; - return 1; - } - - asio::io_context io_context; - - using namespace std; // For atoi. - server(io_context, atoi(argv[1])); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/echo/blocking_udp_echo_client.cpp b/3rdparty/asio/src/examples/cpp03/echo/blocking_udp_echo_client.cpp deleted file mode 100644 index ee90081b7ea..00000000000 --- a/3rdparty/asio/src/examples/cpp03/echo/blocking_udp_echo_client.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// -// blocking_udp_echo_client.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdlib> -#include <cstring> -#include <iostream> -#include "asio.hpp" - -using asio::ip::udp; - -enum { max_length = 1024 }; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 3) - { - std::cerr << "Usage: blocking_udp_echo_client <host> <port>\n"; - return 1; - } - - asio::io_context io_context; - - udp::socket s(io_context, udp::endpoint(udp::v4(), 0)); - - udp::resolver resolver(io_context); - udp::resolver::results_type endpoints = - resolver.resolve(udp::v4(), argv[1], argv[2]); - - using namespace std; // For strlen. - std::cout << "Enter message: "; - char request[max_length]; - std::cin.getline(request, max_length); - size_t request_length = strlen(request); - s.send_to(asio::buffer(request, request_length), *endpoints.begin()); - - char reply[max_length]; - udp::endpoint sender_endpoint; - size_t reply_length = s.receive_from( - asio::buffer(reply, max_length), sender_endpoint); - std::cout << "Reply is: "; - std::cout.write(reply, reply_length); - std::cout << "\n"; - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/echo/blocking_udp_echo_server.cpp b/3rdparty/asio/src/examples/cpp03/echo/blocking_udp_echo_server.cpp deleted file mode 100644 index 3cc364c20b5..00000000000 --- a/3rdparty/asio/src/examples/cpp03/echo/blocking_udp_echo_server.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -// blocking_udp_echo_server.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdlib> -#include <iostream> -#include "asio.hpp" - -using asio::ip::udp; - -enum { max_length = 1024 }; - -void server(asio::io_context& io_context, unsigned short port) -{ - udp::socket sock(io_context, udp::endpoint(udp::v4(), port)); - for (;;) - { - char data[max_length]; - udp::endpoint sender_endpoint; - size_t length = sock.receive_from( - asio::buffer(data, max_length), sender_endpoint); - sock.send_to(asio::buffer(data, length), sender_endpoint); - } -} - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 2) - { - std::cerr << "Usage: blocking_udp_echo_server <port>\n"; - return 1; - } - - asio::io_context io_context; - - using namespace std; // For atoi. - server(io_context, atoi(argv[1])); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/fork/.gitignore b/3rdparty/asio/src/examples/cpp03/fork/.gitignore deleted file mode 100644 index 6b565fe313a..00000000000 --- a/3rdparty/asio/src/examples/cpp03/fork/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds -daemon -process_per_connection diff --git a/3rdparty/asio/src/examples/cpp03/fork/process_per_connection.cpp b/3rdparty/asio/src/examples/cpp03/fork/process_per_connection.cpp deleted file mode 100644 index 483147e9552..00000000000 --- a/3rdparty/asio/src/examples/cpp03/fork/process_per_connection.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// -// process_per_connection.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <asio/io_context.hpp> -#include <asio/ip/tcp.hpp> -#include <asio/signal_set.hpp> -#include <asio/write.hpp> -#include <boost/array.hpp> -#include <boost/bind.hpp> -#include <cstdlib> -#include <iostream> -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> - -using asio::ip::tcp; - -class server -{ -public: - server(asio::io_context& io_context, unsigned short port) - : io_context_(io_context), - signal_(io_context, SIGCHLD), - acceptor_(io_context, tcp::endpoint(tcp::v4(), port)), - socket_(io_context) - { - start_signal_wait(); - start_accept(); - } - -private: - void start_signal_wait() - { - signal_.async_wait(boost::bind(&server::handle_signal_wait, this)); - } - - void handle_signal_wait() - { - // Only the parent process should check for this signal. We can determine - // whether we are in the parent by checking if the acceptor is still open. - if (acceptor_.is_open()) - { - // Reap completed child processes so that we don't end up with zombies. - int status = 0; - while (waitpid(-1, &status, WNOHANG) > 0) {} - - start_signal_wait(); - } - } - - void start_accept() - { - acceptor_.async_accept(socket_, - boost::bind(&server::handle_accept, this, _1)); - } - - void handle_accept(const asio::error_code& ec) - { - if (!ec) - { - // Inform the io_context that we are about to fork. The io_context cleans - // up any internal resources, such as threads, that may interfere with - // forking. - io_context_.notify_fork(asio::io_context::fork_prepare); - - if (fork() == 0) - { - // Inform the io_context that the fork is finished and that this is the - // child process. The io_context uses this opportunity to create any - // internal file descriptors that must be private to the new process. - io_context_.notify_fork(asio::io_context::fork_child); - - // The child won't be accepting new connections, so we can close the - // acceptor. It remains open in the parent. - acceptor_.close(); - - // The child process is not interested in processing the SIGCHLD signal. - signal_.cancel(); - - start_read(); - } - else - { - // Inform the io_context that the fork is finished (or failed) and that - // this is the parent process. The io_context uses this opportunity to - // recreate any internal resources that were cleaned up during - // preparation for the fork. - io_context_.notify_fork(asio::io_context::fork_parent); - - socket_.close(); - start_accept(); - } - } - else - { - std::cerr << "Accept error: " << ec.message() << std::endl; - start_accept(); - } - } - - void start_read() - { - socket_.async_read_some(asio::buffer(data_), - boost::bind(&server::handle_read, this, _1, _2)); - } - - void handle_read(const asio::error_code& ec, std::size_t length) - { - if (!ec) - start_write(length); - } - - void start_write(std::size_t length) - { - asio::async_write(socket_, asio::buffer(data_, length), - boost::bind(&server::handle_write, this, _1)); - } - - void handle_write(const asio::error_code& ec) - { - if (!ec) - start_read(); - } - - asio::io_context& io_context_; - asio::signal_set signal_; - tcp::acceptor acceptor_; - tcp::socket socket_; - boost::array<char, 1024> data_; -}; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 2) - { - std::cerr << "Usage: process_per_connection <port>\n"; - return 1; - } - - asio::io_context io_context; - - using namespace std; // For atoi. - server s(io_context, atoi(argv[1])); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << std::endl; - } -} diff --git a/3rdparty/asio/src/examples/cpp03/http/client/.gitignore b/3rdparty/asio/src/examples/cpp03/http/client/.gitignore deleted file mode 100644 index e80f510d76c..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/client/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/http/doc_root/data_1K.html b/3rdparty/asio/src/examples/cpp03/http/doc_root/data_1K.html deleted file mode 100644 index 1372c4dd177..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/doc_root/data_1K.html +++ /dev/null @@ -1,28 +0,0 @@ -<!-- -Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) - -Distributed under the Boost Software License, Version 1.0. (See accompanying -file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ---> - -<html> -<body> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the<br/> -</body> -</html> - -<!-- boostinspect:nounlinked --> diff --git a/3rdparty/asio/src/examples/cpp03/http/doc_root/data_2K.html b/3rdparty/asio/src/examples/cpp03/http/doc_root/data_2K.html deleted file mode 100644 index 686ce52b0a0..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/doc_root/data_2K.html +++ /dev/null @@ -1,49 +0,0 @@ -<!-- -Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) - -Distributed under the Boost Software License, Version 1.0. (See accompanying -file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ---> - -<html> -<body> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps ove<br/> -</body> -</html> - -<!-- boostinspect:nounlinked --> diff --git a/3rdparty/asio/src/examples/cpp03/http/doc_root/data_4K.html b/3rdparty/asio/src/examples/cpp03/http/doc_root/data_4K.html deleted file mode 100644 index f5db0a2bc00..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/doc_root/data_4K.html +++ /dev/null @@ -1,91 +0,0 @@ -<!-- -Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) - -Distributed under the Boost Software License, Version 1.0. (See accompanying -file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ---> - -<html> -<body> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox<br/> -</body> -</html> - -<!-- boostinspect:nounlinked --> diff --git a/3rdparty/asio/src/examples/cpp03/http/doc_root/data_8K.html b/3rdparty/asio/src/examples/cpp03/http/doc_root/data_8K.html deleted file mode 100644 index 0d42f72886b..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/doc_root/data_8K.html +++ /dev/null @@ -1,175 +0,0 @@ -<!-- -Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) - -Distributed under the Boost Software License, Version 1.0. (See accompanying -file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ---> - -<html> -<body> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -The quick brown fox jumps over the lazy dog<br/> -.... -</body> -</html> - -<!-- boostinspect:nounlinked --> diff --git a/3rdparty/asio/src/examples/cpp03/http/server/.gitignore b/3rdparty/asio/src/examples/cpp03/http/server/.gitignore deleted file mode 100644 index 0882fa6ced3..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/http/server/connection.cpp b/3rdparty/asio/src/examples/cpp03/http/server/connection.cpp deleted file mode 100644 index acbf637b453..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/connection.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// -// connection.cpp -// ~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "connection.hpp" -#include <vector> -#include <boost/bind.hpp> -#include "connection_manager.hpp" -#include "request_handler.hpp" - -namespace http { -namespace server { - -connection::connection(asio::io_context& io_context, - connection_manager& manager, request_handler& handler) - : socket_(io_context), - connection_manager_(manager), - request_handler_(handler) -{ -} - -asio::ip::tcp::socket& connection::socket() -{ - return socket_; -} - -void connection::start() -{ - socket_.async_read_some(asio::buffer(buffer_), - boost::bind(&connection::handle_read, shared_from_this(), - asio::placeholders::error, - asio::placeholders::bytes_transferred)); -} - -void connection::stop() -{ - socket_.close(); -} - -void connection::handle_read(const asio::error_code& e, - std::size_t bytes_transferred) -{ - if (!e) - { - boost::tribool result; - boost::tie(result, boost::tuples::ignore) = request_parser_.parse( - request_, buffer_.data(), buffer_.data() + bytes_transferred); - - if (result) - { - request_handler_.handle_request(request_, reply_); - asio::async_write(socket_, reply_.to_buffers(), - boost::bind(&connection::handle_write, shared_from_this(), - asio::placeholders::error)); - } - else if (!result) - { - reply_ = reply::stock_reply(reply::bad_request); - asio::async_write(socket_, reply_.to_buffers(), - boost::bind(&connection::handle_write, shared_from_this(), - asio::placeholders::error)); - } - else - { - socket_.async_read_some(asio::buffer(buffer_), - boost::bind(&connection::handle_read, shared_from_this(), - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - } - else if (e != asio::error::operation_aborted) - { - connection_manager_.stop(shared_from_this()); - } -} - -void connection::handle_write(const asio::error_code& e) -{ - if (!e) - { - // Initiate graceful connection closure. - asio::error_code ignored_ec; - socket_.shutdown(asio::ip::tcp::socket::shutdown_both, ignored_ec); - } - - if (e != asio::error::operation_aborted) - { - connection_manager_.stop(shared_from_this()); - } -} - -} // namespace server -} // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server/connection.hpp b/3rdparty/asio/src/examples/cpp03/http/server/connection.hpp deleted file mode 100644 index 6193b486443..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/connection.hpp +++ /dev/null @@ -1,83 +0,0 @@ -// -// connection.hpp -// ~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef HTTP_CONNECTION_HPP -#define HTTP_CONNECTION_HPP - -#include <asio.hpp> -#include <boost/array.hpp> -#include <boost/noncopyable.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> -#include "reply.hpp" -#include "request.hpp" -#include "request_handler.hpp" -#include "request_parser.hpp" - -namespace http { -namespace server { - -class connection_manager; - -/// Represents a single connection from a client. -class connection - : public boost::enable_shared_from_this<connection>, - private boost::noncopyable -{ -public: - /// Construct a connection with the given io_context. - explicit connection(asio::io_context& io_context, - connection_manager& manager, request_handler& handler); - - /// Get the socket associated with the connection. - asio::ip::tcp::socket& socket(); - - /// Start the first asynchronous operation for the connection. - void start(); - - /// Stop all asynchronous operations associated with the connection. - void stop(); - -private: - /// Handle completion of a read operation. - void handle_read(const asio::error_code& e, - std::size_t bytes_transferred); - - /// Handle completion of a write operation. - void handle_write(const asio::error_code& e); - - /// Socket for the connection. - asio::ip::tcp::socket socket_; - - /// The manager for this connection. - connection_manager& connection_manager_; - - /// The handler used to process the incoming request. - request_handler& request_handler_; - - /// Buffer for incoming data. - boost::array<char, 8192> buffer_; - - /// The incoming request. - request request_; - - /// The parser for the incoming request. - request_parser request_parser_; - - /// The reply to be sent back to the client. - reply reply_; -}; - -typedef boost::shared_ptr<connection> connection_ptr; - -} // namespace server -} // namespace http - -#endif // HTTP_CONNECTION_HPP diff --git a/3rdparty/asio/src/examples/cpp03/http/server/connection_manager.cpp b/3rdparty/asio/src/examples/cpp03/http/server/connection_manager.cpp deleted file mode 100644 index 8fc9d8f285b..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/connection_manager.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// connection_manager.cpp -// ~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "connection_manager.hpp" -#include <algorithm> -#include <boost/bind.hpp> - -namespace http { -namespace server { - -void connection_manager::start(connection_ptr c) -{ - connections_.insert(c); - c->start(); -} - -void connection_manager::stop(connection_ptr c) -{ - connections_.erase(c); - c->stop(); -} - -void connection_manager::stop_all() -{ - std::for_each(connections_.begin(), connections_.end(), - boost::bind(&connection::stop, _1)); - connections_.clear(); -} - -} // namespace server -} // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server/connection_manager.hpp b/3rdparty/asio/src/examples/cpp03/http/server/connection_manager.hpp deleted file mode 100644 index e67653f6a26..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/connection_manager.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// -// connection_manager.hpp -// ~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef HTTP_CONNECTION_MANAGER_HPP -#define HTTP_CONNECTION_MANAGER_HPP - -#include <set> -#include <boost/noncopyable.hpp> -#include "connection.hpp" - -namespace http { -namespace server { - -/// Manages open connections so that they may be cleanly stopped when the server -/// needs to shut down. -class connection_manager - : private boost::noncopyable -{ -public: - /// Add the specified connection to the manager and start it. - void start(connection_ptr c); - - /// Stop the specified connection. - void stop(connection_ptr c); - - /// Stop all connections. - void stop_all(); - -private: - /// The managed connections. - std::set<connection_ptr> connections_; -}; - -} // namespace server -} // namespace http - -#endif // HTTP_CONNECTION_MANAGER_HPP diff --git a/3rdparty/asio/src/examples/cpp03/http/server/header.hpp b/3rdparty/asio/src/examples/cpp03/http/server/header.hpp deleted file mode 100644 index 22e3c4a7a10..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/header.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// -// header.hpp -// ~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef HTTP_HEADER_HPP -#define HTTP_HEADER_HPP - -#include <string> - -namespace http { -namespace server { - -struct header -{ - std::string name; - std::string value; -}; - -} // namespace server -} // namespace http - -#endif // HTTP_HEADER_HPP diff --git a/3rdparty/asio/src/examples/cpp03/http/server/main.cpp b/3rdparty/asio/src/examples/cpp03/http/server/main.cpp deleted file mode 100644 index 32d6f54dcb5..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/main.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -// main.cpp -// ~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <iostream> -#include <string> -#include <asio.hpp> -#include <boost/bind.hpp> -#include "server.hpp" - -int main(int argc, char* argv[]) -{ - try - { - // Check command line arguments. - if (argc != 4) - { - std::cerr << "Usage: http_server <address> <port> <doc_root>\n"; - std::cerr << " For IPv4, try:\n"; - std::cerr << " receiver 0.0.0.0 80 .\n"; - std::cerr << " For IPv6, try:\n"; - std::cerr << " receiver 0::0 80 .\n"; - return 1; - } - - // Initialise the server. - http::server::server s(argv[1], argv[2], argv[3]); - - // Run the server until stopped. - s.run(); - } - catch (std::exception& e) - { - std::cerr << "exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/http/server/mime_types.cpp b/3rdparty/asio/src/examples/cpp03/http/server/mime_types.cpp deleted file mode 100644 index 80fdfe30e64..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/mime_types.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// mime_types.cpp -// ~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "mime_types.hpp" - -namespace http { -namespace server { -namespace mime_types { - -struct mapping -{ - const char* extension; - const char* mime_type; -} mappings[] = -{ - { "gif", "image/gif" }, - { "htm", "text/html" }, - { "html", "text/html" }, - { "jpg", "image/jpeg" }, - { "png", "image/png" }, - { 0, 0 } // Marks end of list. -}; - -std::string extension_to_type(const std::string& extension) -{ - for (mapping* m = mappings; m->extension; ++m) - { - if (m->extension == extension) - { - return m->mime_type; - } - } - - return "text/plain"; -} - -} // namespace mime_types -} // namespace server -} // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server/mime_types.hpp b/3rdparty/asio/src/examples/cpp03/http/server/mime_types.hpp deleted file mode 100644 index 2fc0332791f..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/mime_types.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// -// mime_types.hpp -// ~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef HTTP_MIME_TYPES_HPP -#define HTTP_MIME_TYPES_HPP - -#include <string> - -namespace http { -namespace server { -namespace mime_types { - -/// Convert a file extension into a MIME type. -std::string extension_to_type(const std::string& extension); - -} // namespace mime_types -} // namespace server -} // namespace http - -#endif // HTTP_MIME_TYPES_HPP diff --git a/3rdparty/asio/src/examples/cpp03/http/server/reply.cpp b/3rdparty/asio/src/examples/cpp03/http/server/reply.cpp deleted file mode 100644 index f3730d3d94d..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/reply.cpp +++ /dev/null @@ -1,256 +0,0 @@ -// -// reply.cpp -// ~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "reply.hpp" -#include <string> -#include <boost/lexical_cast.hpp> - -namespace http { -namespace server { - -namespace status_strings { - -const std::string ok = - "HTTP/1.0 200 OK\r\n"; -const std::string created = - "HTTP/1.0 201 Created\r\n"; -const std::string accepted = - "HTTP/1.0 202 Accepted\r\n"; -const std::string no_content = - "HTTP/1.0 204 No Content\r\n"; -const std::string multiple_choices = - "HTTP/1.0 300 Multiple Choices\r\n"; -const std::string moved_permanently = - "HTTP/1.0 301 Moved Permanently\r\n"; -const std::string moved_temporarily = - "HTTP/1.0 302 Moved Temporarily\r\n"; -const std::string not_modified = - "HTTP/1.0 304 Not Modified\r\n"; -const std::string bad_request = - "HTTP/1.0 400 Bad Request\r\n"; -const std::string unauthorized = - "HTTP/1.0 401 Unauthorized\r\n"; -const std::string forbidden = - "HTTP/1.0 403 Forbidden\r\n"; -const std::string not_found = - "HTTP/1.0 404 Not Found\r\n"; -const std::string internal_server_error = - "HTTP/1.0 500 Internal Server Error\r\n"; -const std::string not_implemented = - "HTTP/1.0 501 Not Implemented\r\n"; -const std::string bad_gateway = - "HTTP/1.0 502 Bad Gateway\r\n"; -const std::string service_unavailable = - "HTTP/1.0 503 Service Unavailable\r\n"; - -asio::const_buffer to_buffer(reply::status_type status) -{ - switch (status) - { - case reply::ok: - return asio::buffer(ok); - case reply::created: - return asio::buffer(created); - case reply::accepted: - return asio::buffer(accepted); - case reply::no_content: - return asio::buffer(no_content); - case reply::multiple_choices: - return asio::buffer(multiple_choices); - case reply::moved_permanently: - return asio::buffer(moved_permanently); - case reply::moved_temporarily: - return asio::buffer(moved_temporarily); - case reply::not_modified: - return asio::buffer(not_modified); - case reply::bad_request: - return asio::buffer(bad_request); - case reply::unauthorized: - return asio::buffer(unauthorized); - case reply::forbidden: - return asio::buffer(forbidden); - case reply::not_found: - return asio::buffer(not_found); - case reply::internal_server_error: - return asio::buffer(internal_server_error); - case reply::not_implemented: - return asio::buffer(not_implemented); - case reply::bad_gateway: - return asio::buffer(bad_gateway); - case reply::service_unavailable: - return asio::buffer(service_unavailable); - default: - return asio::buffer(internal_server_error); - } -} - -} // namespace status_strings - -namespace misc_strings { - -const char name_value_separator[] = { ':', ' ' }; -const char crlf[] = { '\r', '\n' }; - -} // namespace misc_strings - -std::vector<asio::const_buffer> reply::to_buffers() -{ - std::vector<asio::const_buffer> buffers; - buffers.push_back(status_strings::to_buffer(status)); - for (std::size_t i = 0; i < headers.size(); ++i) - { - header& h = headers[i]; - buffers.push_back(asio::buffer(h.name)); - buffers.push_back(asio::buffer(misc_strings::name_value_separator)); - buffers.push_back(asio::buffer(h.value)); - buffers.push_back(asio::buffer(misc_strings::crlf)); - } - buffers.push_back(asio::buffer(misc_strings::crlf)); - buffers.push_back(asio::buffer(content)); - return buffers; -} - -namespace stock_replies { - -const char ok[] = ""; -const char created[] = - "<html>" - "<head><title>Created</title></head>" - "<body><h1>201 Created</h1></body>" - "</html>"; -const char accepted[] = - "<html>" - "<head><title>Accepted</title></head>" - "<body><h1>202 Accepted</h1></body>" - "</html>"; -const char no_content[] = - "<html>" - "<head><title>No Content</title></head>" - "<body><h1>204 Content</h1></body>" - "</html>"; -const char multiple_choices[] = - "<html>" - "<head><title>Multiple Choices</title></head>" - "<body><h1>300 Multiple Choices</h1></body>" - "</html>"; -const char moved_permanently[] = - "<html>" - "<head><title>Moved Permanently</title></head>" - "<body><h1>301 Moved Permanently</h1></body>" - "</html>"; -const char moved_temporarily[] = - "<html>" - "<head><title>Moved Temporarily</title></head>" - "<body><h1>302 Moved Temporarily</h1></body>" - "</html>"; -const char not_modified[] = - "<html>" - "<head><title>Not Modified</title></head>" - "<body><h1>304 Not Modified</h1></body>" - "</html>"; -const char bad_request[] = - "<html>" - "<head><title>Bad Request</title></head>" - "<body><h1>400 Bad Request</h1></body>" - "</html>"; -const char unauthorized[] = - "<html>" - "<head><title>Unauthorized</title></head>" - "<body><h1>401 Unauthorized</h1></body>" - "</html>"; -const char forbidden[] = - "<html>" - "<head><title>Forbidden</title></head>" - "<body><h1>403 Forbidden</h1></body>" - "</html>"; -const char not_found[] = - "<html>" - "<head><title>Not Found</title></head>" - "<body><h1>404 Not Found</h1></body>" - "</html>"; -const char internal_server_error[] = - "<html>" - "<head><title>Internal Server Error</title></head>" - "<body><h1>500 Internal Server Error</h1></body>" - "</html>"; -const char not_implemented[] = - "<html>" - "<head><title>Not Implemented</title></head>" - "<body><h1>501 Not Implemented</h1></body>" - "</html>"; -const char bad_gateway[] = - "<html>" - "<head><title>Bad Gateway</title></head>" - "<body><h1>502 Bad Gateway</h1></body>" - "</html>"; -const char service_unavailable[] = - "<html>" - "<head><title>Service Unavailable</title></head>" - "<body><h1>503 Service Unavailable</h1></body>" - "</html>"; - -std::string to_string(reply::status_type status) -{ - switch (status) - { - case reply::ok: - return ok; - case reply::created: - return created; - case reply::accepted: - return accepted; - case reply::no_content: - return no_content; - case reply::multiple_choices: - return multiple_choices; - case reply::moved_permanently: - return moved_permanently; - case reply::moved_temporarily: - return moved_temporarily; - case reply::not_modified: - return not_modified; - case reply::bad_request: - return bad_request; - case reply::unauthorized: - return unauthorized; - case reply::forbidden: - return forbidden; - case reply::not_found: - return not_found; - case reply::internal_server_error: - return internal_server_error; - case reply::not_implemented: - return not_implemented; - case reply::bad_gateway: - return bad_gateway; - case reply::service_unavailable: - return service_unavailable; - default: - return internal_server_error; - } -} - -} // namespace stock_replies - -reply reply::stock_reply(reply::status_type status) -{ - reply rep; - rep.status = status; - rep.content = stock_replies::to_string(status); - rep.headers.resize(2); - rep.headers[0].name = "Content-Length"; - rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size()); - rep.headers[1].name = "Content-Type"; - rep.headers[1].value = "text/html"; - return rep; -} - -} // namespace server -} // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server/reply.hpp b/3rdparty/asio/src/examples/cpp03/http/server/reply.hpp deleted file mode 100644 index 5189ac4363e..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/reply.hpp +++ /dev/null @@ -1,64 +0,0 @@ -// -// reply.hpp -// ~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef HTTP_REPLY_HPP -#define HTTP_REPLY_HPP - -#include <string> -#include <vector> -#include <asio.hpp> -#include "header.hpp" - -namespace http { -namespace server { - -/// A reply to be sent to a client. -struct reply -{ - /// The status of the reply. - enum status_type - { - ok = 200, - created = 201, - accepted = 202, - no_content = 204, - multiple_choices = 300, - moved_permanently = 301, - moved_temporarily = 302, - not_modified = 304, - bad_request = 400, - unauthorized = 401, - forbidden = 403, - not_found = 404, - internal_server_error = 500, - not_implemented = 501, - bad_gateway = 502, - service_unavailable = 503 - } status; - - /// The headers to be included in the reply. - std::vector<header> headers; - - /// The content to be sent in the reply. - std::string content; - - /// Convert the reply into a vector of buffers. The buffers do not own the - /// underlying memory blocks, therefore the reply object must remain valid and - /// not be changed until the write operation has completed. - std::vector<asio::const_buffer> to_buffers(); - - /// Get a stock reply. - static reply stock_reply(status_type status); -}; - -} // namespace server -} // namespace http - -#endif // HTTP_REPLY_HPP diff --git a/3rdparty/asio/src/examples/cpp03/http/server/request_handler.cpp b/3rdparty/asio/src/examples/cpp03/http/server/request_handler.cpp deleted file mode 100644 index 1201ef109d2..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/request_handler.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// -// request_handler.cpp -// ~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "request_handler.hpp" -#include <fstream> -#include <sstream> -#include <string> -#include <boost/lexical_cast.hpp> -#include "mime_types.hpp" -#include "reply.hpp" -#include "request.hpp" - -namespace http { -namespace server { - -request_handler::request_handler(const std::string& doc_root) - : doc_root_(doc_root) -{ -} - -void request_handler::handle_request(const request& req, reply& rep) -{ - // Decode url to path. - std::string request_path; - if (!url_decode(req.uri, request_path)) - { - rep = reply::stock_reply(reply::bad_request); - return; - } - - // Request path must be absolute and not contain "..". - if (request_path.empty() || request_path[0] != '/' - || request_path.find("..") != std::string::npos) - { - rep = reply::stock_reply(reply::bad_request); - return; - } - - // If path ends in slash (i.e. is a directory) then add "index.html". - if (request_path[request_path.size() - 1] == '/') - { - request_path += "index.html"; - } - - // Determine the file extension. - std::size_t last_slash_pos = request_path.find_last_of("/"); - std::size_t last_dot_pos = request_path.find_last_of("."); - std::string extension; - if (last_dot_pos != std::string::npos && last_dot_pos > last_slash_pos) - { - extension = request_path.substr(last_dot_pos + 1); - } - - // Open the file to send back. - std::string full_path = doc_root_ + request_path; - std::ifstream is(full_path.c_str(), std::ios::in | std::ios::binary); - if (!is) - { - rep = reply::stock_reply(reply::not_found); - return; - } - - // Fill out the reply to be sent to the client. - rep.status = reply::ok; - char buf[512]; - while (is.read(buf, sizeof(buf)).gcount() > 0) - rep.content.append(buf, is.gcount()); - rep.headers.resize(2); - rep.headers[0].name = "Content-Length"; - rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size()); - rep.headers[1].name = "Content-Type"; - rep.headers[1].value = mime_types::extension_to_type(extension); -} - -bool request_handler::url_decode(const std::string& in, std::string& out) -{ - out.clear(); - out.reserve(in.size()); - for (std::size_t i = 0; i < in.size(); ++i) - { - if (in[i] == '%') - { - if (i + 3 <= in.size()) - { - int value = 0; - std::istringstream is(in.substr(i + 1, 2)); - if (is >> std::hex >> value) - { - out += static_cast<char>(value); - i += 2; - } - else - { - return false; - } - } - else - { - return false; - } - } - else if (in[i] == '+') - { - out += ' '; - } - else - { - out += in[i]; - } - } - return true; -} - -} // namespace server -} // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server/request_handler.hpp b/3rdparty/asio/src/examples/cpp03/http/server/request_handler.hpp deleted file mode 100644 index 56a16dd395a..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/request_handler.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// request_handler.hpp -// ~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef HTTP_REQUEST_HANDLER_HPP -#define HTTP_REQUEST_HANDLER_HPP - -#include <string> -#include <boost/noncopyable.hpp> - -namespace http { -namespace server { - -struct reply; -struct request; - -/// The common handler for all incoming requests. -class request_handler - : private boost::noncopyable -{ -public: - /// Construct with a directory containing files to be served. - explicit request_handler(const std::string& doc_root); - - /// Handle a request and produce a reply. - void handle_request(const request& req, reply& rep); - -private: - /// The directory containing the files to be served. - std::string doc_root_; - - /// Perform URL-decoding on a string. Returns false if the encoding was - /// invalid. - static bool url_decode(const std::string& in, std::string& out); -}; - -} // namespace server -} // namespace http - -#endif // HTTP_REQUEST_HANDLER_HPP diff --git a/3rdparty/asio/src/examples/cpp03/http/server/server.cpp b/3rdparty/asio/src/examples/cpp03/http/server/server.cpp deleted file mode 100644 index 89e19d08d42..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/server.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// -// server.cpp -// ~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "server.hpp" -#include <boost/bind.hpp> -#include <signal.h> - -namespace http { -namespace server { - -server::server(const std::string& address, const std::string& port, - const std::string& doc_root) - : io_context_(), - signals_(io_context_), - acceptor_(io_context_), - connection_manager_(), - new_connection_(), - request_handler_(doc_root) -{ - // Register to handle the signals that indicate when the server should exit. - // It is safe to register for the same signal multiple times in a program, - // provided all registration for the specified signal is made through Asio. - signals_.add(SIGINT); - signals_.add(SIGTERM); -#if defined(SIGQUIT) - signals_.add(SIGQUIT); -#endif // defined(SIGQUIT) - signals_.async_wait(boost::bind(&server::handle_stop, this)); - - // Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR). - asio::ip::tcp::resolver resolver(io_context_); - asio::ip::tcp::endpoint endpoint = - *resolver.resolve(address, port).begin(); - acceptor_.open(endpoint.protocol()); - acceptor_.set_option(asio::ip::tcp::acceptor::reuse_address(true)); - acceptor_.bind(endpoint); - acceptor_.listen(); - - start_accept(); -} - -void server::run() -{ - // The io_context::run() call will block until all asynchronous operations - // have finished. While the server is running, there is always at least one - // asynchronous operation outstanding: the asynchronous accept call waiting - // for new incoming connections. - io_context_.run(); -} - -void server::start_accept() -{ - new_connection_.reset(new connection(io_context_, - connection_manager_, request_handler_)); - acceptor_.async_accept(new_connection_->socket(), - boost::bind(&server::handle_accept, this, - asio::placeholders::error)); -} - -void server::handle_accept(const asio::error_code& e) -{ - // Check whether the server was stopped by a signal before this completion - // handler had a chance to run. - if (!acceptor_.is_open()) - { - return; - } - - if (!e) - { - connection_manager_.start(new_connection_); - } - - start_accept(); -} - -void server::handle_stop() -{ - // The server is stopped by cancelling all outstanding asynchronous - // operations. Once all operations have finished the io_context::run() call - // will exit. - acceptor_.close(); - connection_manager_.stop_all(); -} - -} // namespace server -} // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server/server.hpp b/3rdparty/asio/src/examples/cpp03/http/server/server.hpp deleted file mode 100644 index 8b0b1a23296..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server/server.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// -// server.hpp -// ~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef HTTP_SERVER_HPP -#define HTTP_SERVER_HPP - -#include <asio.hpp> -#include <string> -#include <boost/noncopyable.hpp> -#include "connection.hpp" -#include "connection_manager.hpp" -#include "request_handler.hpp" - -namespace http { -namespace server { - -/// The top-level class of the HTTP server. -class server - : private boost::noncopyable -{ -public: - /// Construct the server to listen on the specified TCP address and port, and - /// serve up files from the given directory. - explicit server(const std::string& address, const std::string& port, - const std::string& doc_root); - - /// Run the server's io_context loop. - void run(); - -private: - /// Initiate an asynchronous accept operation. - void start_accept(); - - /// Handle completion of an asynchronous accept operation. - void handle_accept(const asio::error_code& e); - - /// Handle a request to stop the server. - void handle_stop(); - - /// The io_context used to perform asynchronous operations. - asio::io_context io_context_; - - /// The signal_set is used to register for process termination notifications. - asio::signal_set signals_; - - /// Acceptor used to listen for incoming connections. - asio::ip::tcp::acceptor acceptor_; - - /// The connection manager which owns all live connections. - connection_manager connection_manager_; - - /// The next connection to be accepted. - connection_ptr new_connection_; - - /// The handler for all incoming requests. - request_handler request_handler_; -}; - -} // namespace server -} // namespace http - -#endif // HTTP_SERVER_HPP diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/.gitignore b/3rdparty/asio/src/examples/cpp03/http/server2/.gitignore deleted file mode 100644 index 0882fa6ced3..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server2/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/connection.cpp b/3rdparty/asio/src/examples/cpp03/http/server2/connection.cpp deleted file mode 100644 index 81f4a102217..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server2/connection.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// -// connection.cpp -// ~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "connection.hpp" -#include <vector> -#include <boost/bind.hpp> -#include "request_handler.hpp" - -namespace http { -namespace server2 { - -connection::connection(asio::io_context& io_context, - request_handler& handler) - : socket_(io_context), - request_handler_(handler) -{ -} - -asio::ip::tcp::socket& connection::socket() -{ - return socket_; -} - -void connection::start() -{ - socket_.async_read_some(asio::buffer(buffer_), - boost::bind(&connection::handle_read, shared_from_this(), - asio::placeholders::error, - asio::placeholders::bytes_transferred)); -} - -void connection::handle_read(const asio::error_code& e, - std::size_t bytes_transferred) -{ - if (!e) - { - boost::tribool result; - boost::tie(result, boost::tuples::ignore) = request_parser_.parse( - request_, buffer_.data(), buffer_.data() + bytes_transferred); - - if (result) - { - request_handler_.handle_request(request_, reply_); - asio::async_write(socket_, reply_.to_buffers(), - boost::bind(&connection::handle_write, shared_from_this(), - asio::placeholders::error)); - } - else if (!result) - { - reply_ = reply::stock_reply(reply::bad_request); - asio::async_write(socket_, reply_.to_buffers(), - boost::bind(&connection::handle_write, shared_from_this(), - asio::placeholders::error)); - } - else - { - socket_.async_read_some(asio::buffer(buffer_), - boost::bind(&connection::handle_read, shared_from_this(), - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - } - - // If an error occurs then no new asynchronous operations are started. This - // means that all shared_ptr references to the connection object will - // disappear and the object will be destroyed automatically after this - // handler returns. The connection class's destructor closes the socket. -} - -void connection::handle_write(const asio::error_code& e) -{ - if (!e) - { - // Initiate graceful connection closure. - asio::error_code ignored_ec; - socket_.shutdown(asio::ip::tcp::socket::shutdown_both, ignored_ec); - } - - // No new asynchronous operations are started. This means that all shared_ptr - // references to the connection object will disappear and the object will be - // destroyed automatically after this handler returns. The connection class's - // destructor closes the socket. -} - -} // namespace server2 -} // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/.gitignore b/3rdparty/asio/src/examples/cpp03/http/server3/.gitignore deleted file mode 100644 index 0882fa6ced3..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server3/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/connection.cpp b/3rdparty/asio/src/examples/cpp03/http/server3/connection.cpp deleted file mode 100644 index 5db960a9109..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server3/connection.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// -// connection.cpp -// ~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "connection.hpp" -#include <vector> -#include <boost/bind.hpp> -#include "request_handler.hpp" - -namespace http { -namespace server3 { - -connection::connection(asio::io_context& io_context, - request_handler& handler) - : strand_(io_context), - socket_(io_context), - request_handler_(handler) -{ -} - -asio::ip::tcp::socket& connection::socket() -{ - return socket_; -} - -void connection::start() -{ - socket_.async_read_some(asio::buffer(buffer_), - asio::bind_executor(strand_, - boost::bind(&connection::handle_read, shared_from_this(), - asio::placeholders::error, - asio::placeholders::bytes_transferred))); -} - -void connection::handle_read(const asio::error_code& e, - std::size_t bytes_transferred) -{ - if (!e) - { - boost::tribool result; - boost::tie(result, boost::tuples::ignore) = request_parser_.parse( - request_, buffer_.data(), buffer_.data() + bytes_transferred); - - if (result) - { - request_handler_.handle_request(request_, reply_); - asio::async_write(socket_, reply_.to_buffers(), - asio::bind_executor(strand_, - boost::bind(&connection::handle_write, shared_from_this(), - asio::placeholders::error))); - } - else if (!result) - { - reply_ = reply::stock_reply(reply::bad_request); - asio::async_write(socket_, reply_.to_buffers(), - asio::bind_executor(strand_, - boost::bind(&connection::handle_write, shared_from_this(), - asio::placeholders::error))); - } - else - { - socket_.async_read_some(asio::buffer(buffer_), - asio::bind_executor(strand_, - boost::bind(&connection::handle_read, shared_from_this(), - asio::placeholders::error, - asio::placeholders::bytes_transferred))); - } - } - - // If an error occurs then no new asynchronous operations are started. This - // means that all shared_ptr references to the connection object will - // disappear and the object will be destroyed automatically after this - // handler returns. The connection class's destructor closes the socket. -} - -void connection::handle_write(const asio::error_code& e) -{ - if (!e) - { - // Initiate graceful connection closure. - asio::error_code ignored_ec; - socket_.shutdown(asio::ip::tcp::socket::shutdown_both, ignored_ec); - } - - // No new asynchronous operations are started. This means that all shared_ptr - // references to the connection object will disappear and the object will be - // destroyed automatically after this handler returns. The connection class's - // destructor closes the socket. -} - -} // namespace server3 -} // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/.gitignore b/3rdparty/asio/src/examples/cpp03/http/server4/.gitignore deleted file mode 100644 index 0882fa6ced3..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server4/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/request.hpp b/3rdparty/asio/src/examples/cpp03/http/server4/request.hpp deleted file mode 100644 index 43947d7f09e..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server4/request.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// request.hpp -// ~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef HTTP_SERVER4_REQUEST_HPP -#define HTTP_SERVER4_REQUEST_HPP - -#include <string> -#include <vector> -#include "header.hpp" - -namespace http { -namespace server4 { - -/// A request received from a client. -struct request -{ - /// The request method, e.g. "GET", "POST". - std::string method; - - /// The requested URI, such as a path to a file. - std::string uri; - - /// Major version number, usually 1. - int http_version_major; - - /// Minor version number, usually 0 or 1. - int http_version_minor; - - /// The headers included with the request. - std::vector<header> headers; - - /// The optional content sent with the request. - std::string content; -}; - -} // namespace server4 -} // namespace http - -#endif // HTTP_SERVER4_REQUEST_HPP diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/request_parser.cpp b/3rdparty/asio/src/examples/cpp03/http/server4/request_parser.cpp deleted file mode 100644 index 0ec31ad3939..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server4/request_parser.cpp +++ /dev/null @@ -1,226 +0,0 @@ -// -// request_parser.cpp -// ~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "request_parser.hpp" -#include <algorithm> -#include <cctype> -#include <boost/lexical_cast.hpp> -#include "request.hpp" - -namespace http { -namespace server4 { - -// Enable the pseudo-keywords reenter, yield and fork. -#include <asio/yield.hpp> - -std::string request_parser::content_length_name_ = "Content-Length"; - -boost::tribool request_parser::consume(request& req, char c) -{ - reenter (this) - { - req.method.clear(); - req.uri.clear(); - req.http_version_major = 0; - req.http_version_minor = 0; - req.headers.clear(); - req.content.clear(); - content_length_ = 0; - - // Request method. - while (is_char(c) && !is_ctl(c) && !is_tspecial(c) && c != ' ') - { - req.method.push_back(c); - yield return boost::indeterminate; - } - if (req.method.empty()) - return false; - - // Space. - if (c != ' ') return false; - yield return boost::indeterminate; - - // URI. - while (!is_ctl(c) && c != ' ') - { - req.uri.push_back(c); - yield return boost::indeterminate; - } - if (req.uri.empty()) return false; - - // Space. - if (c != ' ') return false; - yield return boost::indeterminate; - - // HTTP protocol identifier. - if (c != 'H') return false; - yield return boost::indeterminate; - if (c != 'T') return false; - yield return boost::indeterminate; - if (c != 'T') return false; - yield return boost::indeterminate; - if (c != 'P') return false; - yield return boost::indeterminate; - - // Slash. - if (c != '/') return false; - yield return boost::indeterminate; - - // Major version number. - if (!is_digit(c)) return false; - while (is_digit(c)) - { - req.http_version_major = req.http_version_major * 10 + c - '0'; - yield return boost::indeterminate; - } - - // Dot. - if (c != '.') return false; - yield return boost::indeterminate; - - // Minor version number. - if (!is_digit(c)) return false; - while (is_digit(c)) - { - req.http_version_minor = req.http_version_minor * 10 + c - '0'; - yield return boost::indeterminate; - } - - // CRLF. - if (c != '\r') return false; - yield return boost::indeterminate; - if (c != '\n') return false; - yield return boost::indeterminate; - - // Headers. - while ((is_char(c) && !is_ctl(c) && !is_tspecial(c) && c != '\r') - || (c == ' ' || c == '\t')) - { - if (c == ' ' || c == '\t') - { - // Leading whitespace. Must be continuation of previous header's value. - if (req.headers.empty()) return false; - while (c == ' ' || c == '\t') - yield return boost::indeterminate; - } - else - { - // Start the next header. - req.headers.push_back(header()); - - // Header name. - while (is_char(c) && !is_ctl(c) && !is_tspecial(c) && c != ':') - { - req.headers.back().name.push_back(c); - yield return boost::indeterminate; - } - - // Colon and space separates the header name from the header value. - if (c != ':') return false; - yield return boost::indeterminate; - if (c != ' ') return false; - yield return boost::indeterminate; - } - - // Header value. - while (is_char(c) && !is_ctl(c) && c != '\r') - { - req.headers.back().value.push_back(c); - yield return boost::indeterminate; - } - - // CRLF. - if (c != '\r') return false; - yield return boost::indeterminate; - if (c != '\n') return false; - yield return boost::indeterminate; - } - - // CRLF. - if (c != '\r') return false; - yield return boost::indeterminate; - if (c != '\n') return false; - - // Check for optional Content-Length header. - for (std::size_t i = 0; i < req.headers.size(); ++i) - { - if (headers_equal(req.headers[i].name, content_length_name_)) - { - try - { - content_length_ = - boost::lexical_cast<std::size_t>(req.headers[i].value); - } - catch (boost::bad_lexical_cast&) - { - return false; - } - } - } - - // Content. - while (req.content.size() < content_length_) - { - yield return boost::indeterminate; - req.content.push_back(c); - } - } - - return true; -} - -// Disable the pseudo-keywords reenter, yield and fork. -#include <asio/unyield.hpp> - -bool request_parser::is_char(int c) -{ - return c >= 0 && c <= 127; -} - -bool request_parser::is_ctl(int c) -{ - return (c >= 0 && c <= 31) || (c == 127); -} - -bool request_parser::is_tspecial(int c) -{ - switch (c) - { - case '(': case ')': case '<': case '>': case '@': - case ',': case ';': case ':': case '\\': case '"': - case '/': case '[': case ']': case '?': case '=': - case '{': case '}': case ' ': case '\t': - return true; - default: - return false; - } -} - -bool request_parser::is_digit(int c) -{ - return c >= '0' && c <= '9'; -} - -bool request_parser::tolower_compare(char a, char b) -{ - return std::tolower(a) == std::tolower(b); -} - -bool request_parser::headers_equal(const std::string& a, const std::string& b) -{ - if (a.length() != b.length()) - return false; - - return std::equal(a.begin(), a.end(), b.begin(), - &request_parser::tolower_compare); -} - -} // namespace server4 -} // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/request_parser.hpp b/3rdparty/asio/src/examples/cpp03/http/server4/request_parser.hpp deleted file mode 100644 index a61356e36a6..00000000000 --- a/3rdparty/asio/src/examples/cpp03/http/server4/request_parser.hpp +++ /dev/null @@ -1,78 +0,0 @@ -// -// request_parser.hpp -// ~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef HTTP_SERVER4_REQUEST_PARSER_HPP -#define HTTP_SERVER4_REQUEST_PARSER_HPP - -#include <string> -#include <boost/logic/tribool.hpp> -#include <boost/tuple/tuple.hpp> -#include <asio/coroutine.hpp> - -namespace http { -namespace server4 { - -struct request; - -/// Parser for incoming requests. -class request_parser : asio::coroutine -{ -public: - /// Parse some data. The tribool return value is true when a complete request - /// has been parsed, false if the data is invalid, indeterminate when more - /// data is required. The InputIterator return value indicates how much of the - /// input has been consumed. - template <typename InputIterator> - boost::tuple<boost::tribool, InputIterator> parse(request& req, - InputIterator begin, InputIterator end) - { - while (begin != end) - { - boost::tribool result = consume(req, *begin++); - if (result || !result) - return boost::make_tuple(result, begin); - } - boost::tribool result = boost::indeterminate; - return boost::make_tuple(result, begin); - } - -private: - /// The name of the content length header. - static std::string content_length_name_; - - /// Content length as decoded from headers. Defaults to 0. - std::size_t content_length_; - - /// Handle the next character of input. - boost::tribool consume(request& req, char input); - - /// Check if a byte is an HTTP character. - static bool is_char(int c); - - /// Check if a byte is an HTTP control character. - static bool is_ctl(int c); - - /// Check if a byte is defined as an HTTP tspecial character. - static bool is_tspecial(int c); - - /// Check if a byte is a digit. - static bool is_digit(int c); - - /// Check if two characters are equal, without regard to case. - static bool tolower_compare(char a, char b); - - /// Check whether the two request header names match. - bool headers_equal(const std::string& a, const std::string& b); -}; - -} // namespace server4 -} // namespace http - -#endif // HTTP_SERVER4_REQUEST_PARSER_HPP diff --git a/3rdparty/asio/src/examples/cpp03/icmp/.gitignore b/3rdparty/asio/src/examples/cpp03/icmp/.gitignore deleted file mode 100644 index 62ea912e2e4..00000000000 --- a/3rdparty/asio/src/examples/cpp03/icmp/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -ping -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/invocation/.gitignore b/3rdparty/asio/src/examples/cpp03/invocation/.gitignore deleted file mode 100644 index e5876b7811a..00000000000 --- a/3rdparty/asio/src/examples/cpp03/invocation/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -prioritised_handlers -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/invocation/prioritised_handlers.cpp b/3rdparty/asio/src/examples/cpp03/invocation/prioritised_handlers.cpp deleted file mode 100644 index 73897946966..00000000000 --- a/3rdparty/asio/src/examples/cpp03/invocation/prioritised_handlers.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// -// prioritised_handlers.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "asio.hpp" -#include <boost/function.hpp> -#include <iostream> -#include <queue> - -using asio::ip::tcp; - -class handler_priority_queue -{ -public: - void add(int priority, boost::function<void()> function) - { - handlers_.push(queued_handler(priority, function)); - } - - void execute_all() - { - while (!handlers_.empty()) - { - queued_handler handler = handlers_.top(); - handler.execute(); - handlers_.pop(); - } - } - - // A generic wrapper class for handlers to allow the invocation to be hooked. - template <typename Handler> - class wrapped_handler - { - public: - wrapped_handler(handler_priority_queue& q, int p, Handler h) - : queue_(q), priority_(p), handler_(h) - { - } - - void operator()() - { - handler_(); - } - - template <typename Arg1> - void operator()(Arg1 arg1) - { - handler_(arg1); - } - - template <typename Arg1, typename Arg2> - void operator()(Arg1 arg1, Arg2 arg2) - { - handler_(arg1, arg2); - } - - //private: - handler_priority_queue& queue_; - int priority_; - Handler handler_; - }; - - template <typename Handler> - wrapped_handler<Handler> wrap(int priority, Handler handler) - { - return wrapped_handler<Handler>(*this, priority, handler); - } - -private: - class queued_handler - { - public: - queued_handler(int p, boost::function<void()> f) - : priority_(p), function_(f) - { - } - - void execute() - { - function_(); - } - - friend bool operator<(const queued_handler& a, - const queued_handler& b) - { - return a.priority_ < b.priority_; - } - - private: - int priority_; - boost::function<void()> function_; - }; - - std::priority_queue<queued_handler> handlers_; -}; - -// Custom invocation hook for wrapped handlers. -template <typename Function, typename Handler> -void asio_handler_invoke(Function f, - handler_priority_queue::wrapped_handler<Handler>* h) -{ - h->queue_.add(h->priority_, f); -} - -//---------------------------------------------------------------------- - -void high_priority_handler(const asio::error_code& /*ec*/) -{ - std::cout << "High priority handler\n"; -} - -void middle_priority_handler(const asio::error_code& /*ec*/) -{ - std::cout << "Middle priority handler\n"; -} - -void low_priority_handler() -{ - std::cout << "Low priority handler\n"; -} - -int main() -{ - asio::io_context io_context; - - handler_priority_queue pri_queue; - - // Post a completion handler to be run immediately. - asio::post(io_context, pri_queue.wrap(0, low_priority_handler)); - - // Start an asynchronous accept that will complete immediately. - tcp::endpoint endpoint(asio::ip::address_v4::loopback(), 0); - tcp::acceptor acceptor(io_context, endpoint); - tcp::socket server_socket(io_context); - acceptor.async_accept(server_socket, - pri_queue.wrap(100, high_priority_handler)); - tcp::socket client_socket(io_context); - client_socket.connect(acceptor.local_endpoint()); - - // Set a deadline timer to expire immediately. - asio::deadline_timer timer(io_context); - timer.expires_at(boost::posix_time::neg_infin); - timer.async_wait(pri_queue.wrap(42, middle_priority_handler)); - - while (io_context.run_one()) - { - // The custom invocation hook adds the handlers to the priority queue - // rather than executing them from within the poll_one() call. - while (io_context.poll_one()) - ; - - pri_queue.execute_all(); - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/iostreams/.gitignore b/3rdparty/asio/src/examples/cpp03/iostreams/.gitignore deleted file mode 100644 index bc2b4f8f7fe..00000000000 --- a/3rdparty/asio/src/examples/cpp03/iostreams/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_client -*_server -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/iostreams/http_client.cpp b/3rdparty/asio/src/examples/cpp03/iostreams/http_client.cpp deleted file mode 100644 index 247df0f37e4..00000000000 --- a/3rdparty/asio/src/examples/cpp03/iostreams/http_client.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// -// http_client.cpp -// ~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <iostream> -#include <istream> -#include <ostream> -#include <string> -#include <asio/ip/tcp.hpp> - -using asio::ip::tcp; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 3) - { - std::cout << "Usage: http_client <server> <path>\n"; - std::cout << "Example:\n"; - std::cout << " http_client www.boost.org /LICENSE_1_0.txt\n"; - return 1; - } - - asio::ip::tcp::iostream s; - - // The entire sequence of I/O operations must complete within 60 seconds. - // If an expiry occurs, the socket is automatically closed and the stream - // becomes bad. - s.expires_after(boost::posix_time::seconds(60)); - - // Establish a connection to the server. - s.connect(argv[1], "http"); - if (!s) - { - std::cout << "Unable to connect: " << s.error().message() << "\n"; - return 1; - } - - // Send the request. We specify the "Connection: close" header so that the - // server will close the socket after transmitting the response. This will - // allow us to treat all data up until the EOF as the content. - s << "GET " << argv[2] << " HTTP/1.0\r\n"; - s << "Host: " << argv[1] << "\r\n"; - s << "Accept: */*\r\n"; - s << "Connection: close\r\n\r\n"; - - // By default, the stream is tied with itself. This means that the stream - // automatically flush the buffered output before attempting a read. It is - // not necessary not explicitly flush the stream at this point. - - // Check that response is OK. - std::string http_version; - s >> http_version; - unsigned int status_code; - s >> status_code; - std::string status_message; - std::getline(s, status_message); - if (!s || http_version.substr(0, 5) != "HTTP/") - { - std::cout << "Invalid response\n"; - return 1; - } - if (status_code != 200) - { - std::cout << "Response returned with status code " << status_code << "\n"; - return 1; - } - - // Process the response headers, which are terminated by a blank line. - std::string header; - while (std::getline(s, header) && header != "\r") - std::cout << header << "\n"; - std::cout << "\n"; - - // Write the remaining data to output. - std::cout << s.rdbuf(); - } - catch (std::exception& e) - { - std::cout << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/local/.gitignore b/3rdparty/asio/src/examples/cpp03/local/.gitignore deleted file mode 100644 index 688277b48d0..00000000000 --- a/3rdparty/asio/src/examples/cpp03/local/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -connect_pair -stream_server -stream_client -iostream_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/local/connect_pair.cpp b/3rdparty/asio/src/examples/cpp03/local/connect_pair.cpp deleted file mode 100644 index 92e0ae866d5..00000000000 --- a/3rdparty/asio/src/examples/cpp03/local/connect_pair.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// -// connect_pair.cpp -// ~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <iostream> -#include <string> -#include <cctype> -#include <asio.hpp> -#include <boost/array.hpp> -#include <boost/bind.hpp> - -#if defined(ASIO_HAS_LOCAL_SOCKETS) - -using asio::local::stream_protocol; - -class uppercase_filter -{ -public: - uppercase_filter(asio::io_context& io_context) - : socket_(io_context) - { - } - - stream_protocol::socket& socket() - { - return socket_; - } - - void start() - { - // Wait for request. - socket_.async_read_some(asio::buffer(data_), - boost::bind(&uppercase_filter::handle_read, - this, asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - -private: - void handle_read(const asio::error_code& ec, std::size_t size) - { - if (!ec) - { - // Compute result. - for (std::size_t i = 0; i < size; ++i) - data_[i] = std::toupper(data_[i]); - - // Send result. - asio::async_write(socket_, asio::buffer(data_, size), - boost::bind(&uppercase_filter::handle_write, - this, asio::placeholders::error)); - } - else - { - throw asio::system_error(ec); - } - } - - void handle_write(const asio::error_code& ec) - { - if (!ec) - { - // Wait for request. - socket_.async_read_some(asio::buffer(data_), - boost::bind(&uppercase_filter::handle_read, - this, asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - else - { - throw asio::system_error(ec); - } - } - - stream_protocol::socket socket_; - boost::array<char, 512> data_; -}; - -void run(asio::io_context* io_context) -{ - try - { - io_context->run(); - } - catch (std::exception& e) - { - std::cerr << "Exception in thread: " << e.what() << "\n"; - std::exit(1); - } -} - -int main() -{ - try - { - asio::io_context io_context; - - // Create filter and establish a connection to it. - uppercase_filter filter(io_context); - stream_protocol::socket socket(io_context); - asio::local::connect_pair(socket, filter.socket()); - filter.start(); - - // The io_context runs in a background thread to perform filtering. - asio::thread thread(boost::bind(run, &io_context)); - - for (;;) - { - // Collect request from user. - std::cout << "Enter a string: "; - std::string request; - std::getline(std::cin, request); - - // Send request to filter. - asio::write(socket, asio::buffer(request)); - - // Wait for reply from filter. - std::vector<char> reply(request.size()); - asio::read(socket, asio::buffer(reply)); - - // Show reply to user. - std::cout << "Result: "; - std::cout.write(&reply[0], request.size()); - std::cout << std::endl; - } - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - std::exit(1); - } -} - -#else // defined(ASIO_HAS_LOCAL_SOCKETS) -# error Local sockets not available on this platform. -#endif // defined(ASIO_HAS_LOCAL_SOCKETS) diff --git a/3rdparty/asio/src/examples/cpp03/local/stream_server.cpp b/3rdparty/asio/src/examples/cpp03/local/stream_server.cpp deleted file mode 100644 index 0bfe2788cae..00000000000 --- a/3rdparty/asio/src/examples/cpp03/local/stream_server.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// -// stream_server.cpp -// ~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdio> -#include <iostream> -#include <boost/array.hpp> -#include <boost/bind.hpp> -#include <boost/enable_shared_from_this.hpp> -#include <boost/shared_ptr.hpp> -#include "asio.hpp" - -#if defined(ASIO_HAS_LOCAL_SOCKETS) - -using asio::local::stream_protocol; - -class session - : public boost::enable_shared_from_this<session> -{ -public: - session(asio::io_context& io_context) - : socket_(io_context) - { - } - - stream_protocol::socket& socket() - { - return socket_; - } - - void start() - { - socket_.async_read_some(asio::buffer(data_), - boost::bind(&session::handle_read, - shared_from_this(), - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - - void handle_read(const asio::error_code& error, - size_t bytes_transferred) - { - if (!error) - { - asio::async_write(socket_, - asio::buffer(data_, bytes_transferred), - boost::bind(&session::handle_write, - shared_from_this(), - asio::placeholders::error)); - } - } - - void handle_write(const asio::error_code& error) - { - if (!error) - { - socket_.async_read_some(asio::buffer(data_), - boost::bind(&session::handle_read, - shared_from_this(), - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - } - -private: - // The socket used to communicate with the client. - stream_protocol::socket socket_; - - // Buffer used to store data received from the client. - boost::array<char, 1024> data_; -}; - -typedef boost::shared_ptr<session> session_ptr; - -class server -{ -public: - server(asio::io_context& io_context, const std::string& file) - : io_context_(io_context), - acceptor_(io_context, stream_protocol::endpoint(file)) - { - session_ptr new_session(new session(io_context_)); - acceptor_.async_accept(new_session->socket(), - boost::bind(&server::handle_accept, this, new_session, - asio::placeholders::error)); - } - - void handle_accept(session_ptr new_session, - const asio::error_code& error) - { - if (!error) - { - new_session->start(); - } - - new_session.reset(new session(io_context_)); - acceptor_.async_accept(new_session->socket(), - boost::bind(&server::handle_accept, this, new_session, - asio::placeholders::error)); - } - -private: - asio::io_context& io_context_; - stream_protocol::acceptor acceptor_; -}; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 2) - { - std::cerr << "Usage: stream_server <file>\n"; - std::cerr << "*** WARNING: existing file is removed ***\n"; - return 1; - } - - asio::io_context io_context; - - std::remove(argv[1]); - server s(io_context, argv[1]); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} - -#else // defined(ASIO_HAS_LOCAL_SOCKETS) -# error Local sockets not available on this platform. -#endif // defined(ASIO_HAS_LOCAL_SOCKETS) diff --git a/3rdparty/asio/src/examples/cpp03/multicast/.gitignore b/3rdparty/asio/src/examples/cpp03/multicast/.gitignore deleted file mode 100644 index 0c30ebdd7df..00000000000 --- a/3rdparty/asio/src/examples/cpp03/multicast/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -receiver -sender -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/nonblocking/.gitignore b/3rdparty/asio/src/examples/cpp03/nonblocking/.gitignore deleted file mode 100644 index 760e0dcebb4..00000000000 --- a/3rdparty/asio/src/examples/cpp03/nonblocking/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -third_party_lib -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/nonblocking/third_party_lib.cpp b/3rdparty/asio/src/examples/cpp03/nonblocking/third_party_lib.cpp deleted file mode 100644 index 8ec06f6034d..00000000000 --- a/3rdparty/asio/src/examples/cpp03/nonblocking/third_party_lib.cpp +++ /dev/null @@ -1,240 +0,0 @@ -// -// third_party_lib.cpp -// ~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <asio.hpp> -#include <boost/array.hpp> -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> -#include <iostream> - -using asio::ip::tcp; - -namespace third_party_lib { - -// Simulation of a third party library that wants to perform read and write -// operations directly on a socket. It needs to be polled to determine whether -// it requires a read or write operation, and notified when the socket is ready -// for reading or writing. -class session -{ -public: - session(tcp::socket& socket) - : socket_(socket), - state_(reading) - { - } - - // Returns true if the third party library wants to be notified when the - // socket is ready for reading. - bool want_read() const - { - return state_ == reading; - } - - // Notify that third party library that it should perform its read operation. - void do_read(asio::error_code& ec) - { - if (std::size_t len = socket_.read_some(asio::buffer(data_), ec)) - { - write_buffer_ = asio::buffer(data_, len); - state_ = writing; - } - } - - // Returns true if the third party library wants to be notified when the - // socket is ready for writing. - bool want_write() const - { - return state_ == writing; - } - - // Notify that third party library that it should perform its write operation. - void do_write(asio::error_code& ec) - { - if (std::size_t len = socket_.write_some( - asio::buffer(write_buffer_), ec)) - { - write_buffer_ = write_buffer_ + len; - state_ = asio::buffer_size(write_buffer_) > 0 ? writing : reading; - } - } - -private: - tcp::socket& socket_; - enum { reading, writing } state_; - boost::array<char, 128> data_; - asio::const_buffer write_buffer_; -}; - -} // namespace third_party_lib - -// The glue between asio's sockets and the third party library. -class connection - : public boost::enable_shared_from_this<connection> -{ -public: - typedef boost::shared_ptr<connection> pointer; - - static pointer create(asio::io_context& io_context) - { - return pointer(new connection(io_context)); - } - - tcp::socket& socket() - { - return socket_; - } - - void start() - { - // Put the socket into non-blocking mode. - socket_.non_blocking(true); - - start_operations(); - } - -private: - connection(asio::io_context& io_context) - : socket_(io_context), - session_impl_(socket_), - read_in_progress_(false), - write_in_progress_(false) - { - } - - void start_operations() - { - // Start a read operation if the third party library wants one. - if (session_impl_.want_read() && !read_in_progress_) - { - read_in_progress_ = true; - socket_.async_wait(tcp::socket::wait_read, - boost::bind(&connection::handle_read, - shared_from_this(), - asio::placeholders::error)); - } - - // Start a write operation if the third party library wants one. - if (session_impl_.want_write() && !write_in_progress_) - { - write_in_progress_ = true; - socket_.async_wait(tcp::socket::wait_write, - boost::bind(&connection::handle_write, - shared_from_this(), - asio::placeholders::error)); - } - } - - void handle_read(asio::error_code ec) - { - read_in_progress_ = false; - - // Notify third party library that it can perform a read. - if (!ec) - session_impl_.do_read(ec); - - // The third party library successfully performed a read on the socket. - // Start new read or write operations based on what it now wants. - if (!ec || ec == asio::error::would_block) - start_operations(); - - // Otherwise, an error occurred. Closing the socket cancels any outstanding - // asynchronous read or write operations. The connection object will be - // destroyed automatically once those outstanding operations complete. - else - socket_.close(); - } - - void handle_write(asio::error_code ec) - { - write_in_progress_ = false; - - // Notify third party library that it can perform a write. - if (!ec) - session_impl_.do_write(ec); - - // The third party library successfully performed a write on the socket. - // Start new read or write operations based on what it now wants. - if (!ec || ec == asio::error::would_block) - start_operations(); - - // Otherwise, an error occurred. Closing the socket cancels any outstanding - // asynchronous read or write operations. The connection object will be - // destroyed automatically once those outstanding operations complete. - else - socket_.close(); - } - -private: - tcp::socket socket_; - third_party_lib::session session_impl_; - bool read_in_progress_; - bool write_in_progress_; -}; - -class server -{ -public: - server(asio::io_context& io_context, unsigned short port) - : acceptor_(io_context, tcp::endpoint(tcp::v4(), port)) - { - start_accept(); - } - -private: - void start_accept() - { - connection::pointer new_connection = - connection::create(acceptor_.get_executor().context()); - - acceptor_.async_accept(new_connection->socket(), - boost::bind(&server::handle_accept, this, new_connection, - asio::placeholders::error)); - } - - void handle_accept(connection::pointer new_connection, - const asio::error_code& error) - { - if (!error) - { - new_connection->start(); - } - - start_accept(); - } - - tcp::acceptor acceptor_; -}; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 2) - { - std::cerr << "Usage: third_party_lib <port>\n"; - return 1; - } - - asio::io_context io_context; - - using namespace std; // For atoi. - server s(io_context, atoi(argv[1])); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/porthopper/.gitignore b/3rdparty/asio/src/examples/cpp03/porthopper/.gitignore deleted file mode 100644 index 692ea7e7e65..00000000000 --- a/3rdparty/asio/src/examples/cpp03/porthopper/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -client -server -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/serialization/.gitignore b/3rdparty/asio/src/examples/cpp03/serialization/.gitignore deleted file mode 100644 index 692ea7e7e65..00000000000 --- a/3rdparty/asio/src/examples/cpp03/serialization/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -client -server -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/services/.gitignore b/3rdparty/asio/src/examples/cpp03/services/.gitignore deleted file mode 100644 index 701b1b85834..00000000000 --- a/3rdparty/asio/src/examples/cpp03/services/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_client -*.ilk -*.manifest -*.pdb -*.tds -log.txt diff --git a/3rdparty/asio/src/examples/cpp03/socks4/.gitignore b/3rdparty/asio/src/examples/cpp03/socks4/.gitignore deleted file mode 100644 index e11e0de344e..00000000000 --- a/3rdparty/asio/src/examples/cpp03/socks4/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -sync_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/spawn/.gitignore b/3rdparty/asio/src/examples/cpp03/spawn/.gitignore deleted file mode 100644 index 6b8a121e099..00000000000 --- a/3rdparty/asio/src/examples/cpp03/spawn/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -.deps -.dirstamp -parallel_grep -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/spawn/echo_server.cpp b/3rdparty/asio/src/examples/cpp03/spawn/echo_server.cpp deleted file mode 100644 index 415f6da8f33..00000000000 --- a/3rdparty/asio/src/examples/cpp03/spawn/echo_server.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// -// echo_server.cpp -// ~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <asio/deadline_timer.hpp> -#include <asio/io_context.hpp> -#include <asio/ip/tcp.hpp> -#include <asio/spawn.hpp> -#include <asio/write.hpp> -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> -#include <iostream> - -using asio::ip::tcp; - -class session : public boost::enable_shared_from_this<session> -{ -public: - explicit session(asio::io_context& io_context) - : strand_(io_context), - socket_(io_context), - timer_(io_context) - { - } - - tcp::socket& socket() - { - return socket_; - } - - void go() - { - asio::spawn(strand_, - boost::bind(&session::echo, - shared_from_this(), _1)); - asio::spawn(strand_, - boost::bind(&session::timeout, - shared_from_this(), _1)); - } - -private: - void echo(asio::yield_context yield) - { - try - { - char data[128]; - for (;;) - { - timer_.expires_from_now(boost::posix_time::seconds(10)); - std::size_t n = socket_.async_read_some(asio::buffer(data), yield); - asio::async_write(socket_, asio::buffer(data, n), yield); - } - } - catch (std::exception& e) - { - socket_.close(); - timer_.cancel(); - } - } - - void timeout(asio::yield_context yield) - { - while (socket_.is_open()) - { - asio::error_code ignored_ec; - timer_.async_wait(yield[ignored_ec]); - if (timer_.expires_from_now() <= boost::posix_time::seconds(0)) - socket_.close(); - } - } - - asio::io_context::strand strand_; - tcp::socket socket_; - asio::deadline_timer timer_; -}; - -void do_accept(asio::io_context& io_context, - unsigned short port, asio::yield_context yield) -{ - tcp::acceptor acceptor(io_context, tcp::endpoint(tcp::v4(), port)); - - for (;;) - { - asio::error_code ec; - boost::shared_ptr<session> new_session(new session(io_context)); - acceptor.async_accept(new_session->socket(), yield[ec]); - if (!ec) new_session->go(); - } -} - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 2) - { - std::cerr << "Usage: echo_server <port>\n"; - return 1; - } - - asio::io_context io_context; - - asio::spawn(io_context, - boost::bind(do_accept, - boost::ref(io_context), atoi(argv[1]), _1)); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/spawn/parallel_grep.cpp b/3rdparty/asio/src/examples/cpp03/spawn/parallel_grep.cpp deleted file mode 100644 index d742f196d78..00000000000 --- a/3rdparty/asio/src/examples/cpp03/spawn/parallel_grep.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// -// parallel_grep.cpp -// ~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <asio/dispatch.hpp> -#include <asio/post.hpp> -#include <asio/spawn.hpp> -#include <asio/strand.hpp> -#include <asio/thread_pool.hpp> -#include <boost/bind.hpp> -#include <fstream> -#include <iostream> -#include <string> - -using asio::dispatch; -using asio::spawn; -using asio::strand; -using asio::thread_pool; -using asio::yield_context; - -void print_match(std::string input_file, std::string line) -{ - std::cout << input_file << ':' << line << std::endl; -} - -void search_file(std::string search_string, std::string input_file, - strand<thread_pool::executor_type> output_strand, yield_context yield) -{ - std::ifstream is(input_file.c_str()); - std::string line; - std::size_t line_num = 0; - while (std::getline(is, line)) - { - // If we find a match, send a message to the output. - if (line.find(search_string) != std::string::npos) - { - dispatch(output_strand, boost::bind(&print_match, input_file, line)); - } - - // Every so often we yield control to another coroutine. - if (++line_num % 10 == 0) - post(yield); - } -} - -int main(int argc, char* argv[]) -{ - try - { - if (argc < 2) - { - std::cerr << "Usage: parallel_grep <string> <files...>\n"; - return 1; - } - - // We use a fixed size pool of threads for reading the input files. The - // number of threads is automatically determined based on the number of - // CPUs available in the system. - thread_pool pool; - - // To prevent the output from being garbled, we use a strand to synchronise - // printing. - strand<thread_pool::executor_type> output_strand(pool.get_executor()); - - // Spawn a new coroutine for each file specified on the command line. - std::string search_string = argv[1]; - for (int argn = 2; argn < argc; ++argn) - { - std::string input_file = argv[argn]; - spawn(pool, boost::bind(&search_file, - search_string, input_file, output_strand, _1)); - } - - // Join the thread pool to wait for all the spawned tasks to complete. - pool.join(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/ssl/.gitignore b/3rdparty/asio/src/examples/cpp03/ssl/.gitignore deleted file mode 100644 index a67811253d9..00000000000 --- a/3rdparty/asio/src/examples/cpp03/ssl/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -server -client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/ssl/ca.pem b/3rdparty/asio/src/examples/cpp03/ssl/ca.pem deleted file mode 100644 index 1ee5f2ca43b..00000000000 --- a/3rdparty/asio/src/examples/cpp03/ssl/ca.pem +++ /dev/null @@ -1,49 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDlzCCAn+gAwIBAgIJAMJYU3U6A0IRMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNV -BAYTAkFVMQwwCgYDVQQIEwNOU1cxDzANBgNVBAcTBlN5ZG5leTENMAsGA1UEChME -YXNpbzAeFw0xNTExMTgyMjMzNDhaFw0yMDExMTYyMjMzNDhaMDsxCzAJBgNVBAYT -AkFVMQwwCgYDVQQIEwNOU1cxDzANBgNVBAcTBlN5ZG5leTENMAsGA1UEChMEYXNp -bzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMcRJocHdVMdLUJ/pypY -QVSTC0t3IIgjwjazrK3kAaoIMvzPmDFxEXWcDx+nyz8kQ/E38Ir/ef2BCNGci5hu -wkfMSuMoW9l2N4hx3QCcF46tTDEZztFxWAH7QbE2wYMlMgKZSxWimNfq0YjxEEXb -QM0lGPLFh7Xoko29H0F3LKaaQV9u/vop3Hs0h12HeWlY4PiLp7QQTNGqbWcXycA0 -NZ/fyismireyEvPAgo6L8iXuAi7g0TVKVNlrticGGjMcMq6IMvxzEpSMkuMQ5rWj -pZjWOoBjSYBuXdblcBRvXhOr2Ws8jJLMZfehKq9q1reQfoGV6xMnbwmumSXbWRWT -0vkCAwEAAaOBnTCBmjAdBgNVHQ4EFgQUK/Zv/AVtfIeucJw8VEtux1dhI1YwawYD -VR0jBGQwYoAUK/Zv/AVtfIeucJw8VEtux1dhI1ahP6Q9MDsxCzAJBgNVBAYTAkFV -MQwwCgYDVQQIEwNOU1cxDzANBgNVBAcTBlN5ZG5leTENMAsGA1UEChMEYXNpb4IJ -AMJYU3U6A0IRMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBABLYXimq -v/HLyIJi7Xn8AJUsICj8LKF/J24nwwiF+ibf7UkoChJURs4nN78bod/lpDVPTEVl -gTBdV/vBJs416sCEFfsGjqB9OBYj4gb0VaJDsQd0+NMvXp0faKv2y9wgScxG9/cg -aM7eRmyfMn1qjb6tpNxVOPpe/nFi8Vx/1orejBRaZr4zF5TkoPepfwLWQeXDUIdE -+QHZ60jZAkR5RXTVU4u3kOKcJs839pmJYyxM4H2VxpR18vy4/YdIVWkREIUM2OgT -5iznIQIIgR56QRGP85uef+I6n0BHzrBk6du69bkQFxrFjLVGlal4bIQqSg4KGWgx -dEdymMWzmMxpO9s= ------END CERTIFICATE----- ------BEGIN RSA PRIVATE KEY----- -MIIEpgIBAAKCAQEAxxEmhwd1Ux0tQn+nKlhBVJMLS3cgiCPCNrOsreQBqggy/M+Y -MXERdZwPH6fLPyRD8Tfwiv95/YEI0ZyLmG7CR8xK4yhb2XY3iHHdAJwXjq1MMRnO -0XFYAftBsTbBgyUyAplLFaKY1+rRiPEQRdtAzSUY8sWHteiSjb0fQXcspppBX27+ -+incezSHXYd5aVjg+IuntBBM0aptZxfJwDQ1n9/KKyaKt7IS88CCjovyJe4CLuDR -NUpU2Wu2JwYaMxwyrogy/HMSlIyS4xDmtaOlmNY6gGNJgG5d1uVwFG9eE6vZazyM -ksxl96Eqr2rWt5B+gZXrEydvCa6ZJdtZFZPS+QIDAQABAoIBAQCOma+SvPoDzvvU -DiPOxqgOEMPfjHfGbm86xl0luBalGfiEd6WbjVanfGKtF4MWOUFec+chez+FJMEP -fufVC0qrKiJfNVMOpYvEd2SMgkSx1VymM8me6WXVDYsSipn2+1cm228ZEYAR9Emj -oqQ4loaGLlP/3RaJbhBF7ruMJvXaZZQ4fZy74Z4tyRaaE1B659ua7Rjne7eNhQE8 -cR7cQDkxsNNN3LTbfLRwEc/gcDXWgLe5JlR/K4ZrdKc3lyivm+Uew3ubKs+fgkyY -kHmuI3RJGIjpnsZW0/So+pHm3b/fo6lmlhTXtNNd+tkkKn2K9ttbXT3Sc13Pc+4w -c4MLyUpdAoGBAOxTtGDpeF6U4s+GPuOCzHCwKQyzfOyCL/UTZv1UJX7Kn1FYycJH -eOjtBRtS661cGkGd1MPfjdX2VV84AmBGDUmRqJ2KfTI1NjLAEJ115ANTpmSTm3lF -UYncgbzl6aflLpjE1mgY+JTJykYeN5jhhO0r2bsdY7S+zaMCSI5NLuznAoGBANej -aMtqLg2qKoq+fUkNBHHLXelR5dBXFnKgSrTj++H4yeW9pYbl8bK3gTF3I5+dSjHW -DdC4+X09iPqY7p8vm8Gq/vgO8Bu+EnKNVr80PJSj7AzFGd6mk/CVrAzoY2XJWbAp -YFwpo1WfHjS5wBfQzBlXY7kWVB7fj32kk14PYmUfAoGBAJXfd7NGHPoOfdCSGGv8 -VV7ZuQ6+/WiYH4XS6iuaI7VHFsZmAn3dCcbeGbD8Y04r7NLUH0yhB7g7YmTihk87 -3c1cPIy8eS1QJbEFsQPK8fFSKWH7YkwEM/O0DesX+5hodaaYnkiiHXNujYLuQuAH -lV87wfcyajsEDjFkj1L/i9TdAoGBAKYfRUQv8HqmdU+doHb+iEYCHb75UMpHzQtR -YTwpxoo3V5Kdnz9lNeYwaF7rIY59ZgMunEYHumw5U6V625nW228/hF0lZOR6cUu+ -hu2WGHWKMvdDgMJ+IcpeA8WN4cUwcN+9gHZ/vUzg4CxOTSYLvLBpGnIkOXnvUGPC -vaTgxTSRAoGBAOHcuZ9hcUrPuVI1HVkjQQLu5mLZ3tz6linEbe/RCdJMK8JrRX4w -ubB7gFclMYGbLlDNAJVYkydJaCy/2NAI3rfsOda+VmDqGx6z4BbSGceHhomyU1Oo -1H7YaXsuzDkzl23HRsyp0pKJpTdghZdbVsGF8vAB8ygK3ehM233neSln ------END RSA PRIVATE KEY----- diff --git a/3rdparty/asio/src/examples/cpp03/ssl/client.cpp b/3rdparty/asio/src/examples/cpp03/ssl/client.cpp deleted file mode 100644 index 02a3ce8b3ca..00000000000 --- a/3rdparty/asio/src/examples/cpp03/ssl/client.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// -// client.cpp -// ~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdlib> -#include <iostream> -#include <boost/bind.hpp> -#include "asio.hpp" -#include "asio/ssl.hpp" - -enum { max_length = 1024 }; - -class client -{ -public: - client(asio::io_context& io_context, - asio::ssl::context& context, - asio::ip::tcp::resolver::results_type endpoints) - : socket_(io_context, context) - { - socket_.set_verify_mode(asio::ssl::verify_peer); - socket_.set_verify_callback( - boost::bind(&client::verify_certificate, this, _1, _2)); - - asio::async_connect(socket_.lowest_layer(), endpoints, - boost::bind(&client::handle_connect, this, - asio::placeholders::error)); - } - - bool verify_certificate(bool preverified, - asio::ssl::verify_context& ctx) - { - // The verify callback can be used to check whether the certificate that is - // being presented is valid for the peer. For example, RFC 2818 describes - // the steps involved in doing this for HTTPS. Consult the OpenSSL - // documentation for more details. Note that the callback is called once - // for each certificate in the certificate chain, starting from the root - // certificate authority. - - // In this example we will simply print the certificate's subject name. - char subject_name[256]; - X509* cert = X509_STORE_CTX_get_current_cert(ctx.native_handle()); - X509_NAME_oneline(X509_get_subject_name(cert), subject_name, 256); - std::cout << "Verifying " << subject_name << "\n"; - - return preverified; - } - - void handle_connect(const asio::error_code& error) - { - if (!error) - { - socket_.async_handshake(asio::ssl::stream_base::client, - boost::bind(&client::handle_handshake, this, - asio::placeholders::error)); - } - else - { - std::cout << "Connect failed: " << error.message() << "\n"; - } - } - - void handle_handshake(const asio::error_code& error) - { - if (!error) - { - std::cout << "Enter message: "; - std::cin.getline(request_, max_length); - size_t request_length = strlen(request_); - - asio::async_write(socket_, - asio::buffer(request_, request_length), - boost::bind(&client::handle_write, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - else - { - std::cout << "Handshake failed: " << error.message() << "\n"; - } - } - - void handle_write(const asio::error_code& error, - size_t bytes_transferred) - { - if (!error) - { - asio::async_read(socket_, - asio::buffer(reply_, bytes_transferred), - boost::bind(&client::handle_read, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - else - { - std::cout << "Write failed: " << error.message() << "\n"; - } - } - - void handle_read(const asio::error_code& error, - size_t bytes_transferred) - { - if (!error) - { - std::cout << "Reply: "; - std::cout.write(reply_, bytes_transferred); - std::cout << "\n"; - } - else - { - std::cout << "Read failed: " << error.message() << "\n"; - } - } - -private: - asio::ssl::stream<asio::ip::tcp::socket> socket_; - char request_[max_length]; - char reply_[max_length]; -}; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 3) - { - std::cerr << "Usage: client <host> <port>\n"; - return 1; - } - - asio::io_context io_context; - - asio::ip::tcp::resolver resolver(io_context); - asio::ip::tcp::resolver::results_type endpoints = - resolver.resolve(argv[1], argv[2]); - - asio::ssl::context ctx(asio::ssl::context::sslv23); - ctx.load_verify_file("ca.pem"); - - client c(io_context, ctx, endpoints); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/ssl/dh2048.pem b/3rdparty/asio/src/examples/cpp03/ssl/dh2048.pem deleted file mode 100644 index 07250cca62f..00000000000 --- a/3rdparty/asio/src/examples/cpp03/ssl/dh2048.pem +++ /dev/null @@ -1,8 +0,0 @@ ------BEGIN DH PARAMETERS----- -MIIBCAKCAQEAyNnxZSYc6J89mDNnqOH8bnwBiAJxcaUS3PkIEcwW8D9o2BlNq6EO -XKMIbdfwPFZi80GMpNu3YP2A2B42sAHmb7w7ZA92QDv3JjqzR0QuS/CkMv4CEjha -QBFwBDDWnnHBSj4w/t54ii0SH34mWcjBItI2eMtnM9J6fnvNiWqJxdt4iA4mZjZD -qZTjIRyjgKAevzkqAlBqQRoVUUgu+9Cf29wXjVl3bE+0VU5CdFeyT+Y9yunz88mq -rGyx1uPt+zbIfxuNLH+coY67y1ht7iZEL5WLd3wGCycRT+lYy2AL/rxGBPxStFIT -2bOkQao6sAfb4UdGEUlwHUXZrAV51oM30wIBAg== ------END DH PARAMETERS----- diff --git a/3rdparty/asio/src/examples/cpp03/ssl/server.cpp b/3rdparty/asio/src/examples/cpp03/ssl/server.cpp deleted file mode 100644 index ad3d73a2c44..00000000000 --- a/3rdparty/asio/src/examples/cpp03/ssl/server.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// -// server.cpp -// ~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <cstdlib> -#include <iostream> -#include <boost/bind.hpp> -#include "asio.hpp" -#include "asio/ssl.hpp" - -typedef asio::ssl::stream<asio::ip::tcp::socket> ssl_socket; - -class session -{ -public: - session(asio::io_context& io_context, - asio::ssl::context& context) - : socket_(io_context, context) - { - } - - ssl_socket::lowest_layer_type& socket() - { - return socket_.lowest_layer(); - } - - void start() - { - socket_.async_handshake(asio::ssl::stream_base::server, - boost::bind(&session::handle_handshake, this, - asio::placeholders::error)); - } - - void handle_handshake(const asio::error_code& error) - { - if (!error) - { - socket_.async_read_some(asio::buffer(data_, max_length), - boost::bind(&session::handle_read, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - else - { - delete this; - } - } - - void handle_read(const asio::error_code& error, - size_t bytes_transferred) - { - if (!error) - { - asio::async_write(socket_, - asio::buffer(data_, bytes_transferred), - boost::bind(&session::handle_write, this, - asio::placeholders::error)); - } - else - { - delete this; - } - } - - void handle_write(const asio::error_code& error) - { - if (!error) - { - socket_.async_read_some(asio::buffer(data_, max_length), - boost::bind(&session::handle_read, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } - else - { - delete this; - } - } - -private: - ssl_socket socket_; - enum { max_length = 1024 }; - char data_[max_length]; -}; - -class server -{ -public: - server(asio::io_context& io_context, unsigned short port) - : io_context_(io_context), - acceptor_(io_context, - asio::ip::tcp::endpoint(asio::ip::tcp::v4(), port)), - context_(asio::ssl::context::sslv23) - { - context_.set_options( - asio::ssl::context::default_workarounds - | asio::ssl::context::no_sslv2 - | asio::ssl::context::single_dh_use); - context_.set_password_callback(boost::bind(&server::get_password, this)); - context_.use_certificate_chain_file("server.pem"); - context_.use_private_key_file("server.pem", asio::ssl::context::pem); - context_.use_tmp_dh_file("dh2048.pem"); - - start_accept(); - } - - std::string get_password() const - { - return "test"; - } - - void start_accept() - { - session* new_session = new session(io_context_, context_); - acceptor_.async_accept(new_session->socket(), - boost::bind(&server::handle_accept, this, new_session, - asio::placeholders::error)); - } - - void handle_accept(session* new_session, - const asio::error_code& error) - { - if (!error) - { - new_session->start(); - } - else - { - delete new_session; - } - - start_accept(); - } - -private: - asio::io_context& io_context_; - asio::ip::tcp::acceptor acceptor_; - asio::ssl::context context_; -}; - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 2) - { - std::cerr << "Usage: server <port>\n"; - return 1; - } - - asio::io_context io_context; - - using namespace std; // For atoi. - server s(io_context, atoi(argv[1])); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/ssl/server.pem b/3rdparty/asio/src/examples/cpp03/ssl/server.pem deleted file mode 100644 index 37ea6e26715..00000000000 --- a/3rdparty/asio/src/examples/cpp03/ssl/server.pem +++ /dev/null @@ -1,71 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDAzCCAesCCQD9QcRiWk0y9TANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJB -VTEMMAoGA1UECBMDTlNXMQ8wDQYDVQQHEwZTeWRuZXkxDTALBgNVBAoTBGFzaW8w -HhcNMTUxMTE4MjIzNzMxWhcNMjAxMTE2MjIzNzMxWjBMMQswCQYDVQQGEwJBVTEM -MAoGA1UECBMDTlNXMQ8wDQYDVQQHEwZTeWRuZXkxDTALBgNVBAoTBGFzaW8xDzAN -BgNVBAsTBnNlcnZlcjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALr0 -+NXSklsGJR7HYHP/H4V5+KpYrmFKva/K7iiqi+XyWEjGnj+/iImJW26phhg9GouN -JJxdrP7/0LwpMsEC/9v09dMNAEewtYhPgD4kiUH/E/79wVmayMZZZGrpF9Rw+wWv -q58y3L1wKge3qilX6slVDdNhqU3vBiMKEJfsjE4PKcEVjPCjVJG2562eHK9FxyjQ -DykyH61lQKBQOiElilPQKzAO7U36yTvs+chWuUfK47B8EC+PJ5KcLEppli4ljlwE -w01HnGxwvjDLobKm2jL6CWi3aYGWudyTsNAd7YC5C7psktBypQLBcfp7uUrrR5Bb -PEjFHJUWIlyoYvm2OjMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAtceVW6tixFsB -ZRhjL5aRCcbx2iMwEXd54lcP6BWe1qOcDPHoSYI1zvvGzohbEvBfqUv78S9MtzaT -gMe5rIU9M1ZM09PyaM6ZutGpKHE8L4qcOslTt41GQFsSqPFdcbgSV20MvBzjGayR -AI/WV0avW3oasdetJPZCR7bRbCbMbWTgclUfv5F25ENcR+BhNuilfL15owL0s4sS -Wb4jOOHhXV9iXeS2dH0snFqv4BmQ9ZoA7zbM9lG3EU5DuxHESYkCnzJyEqqY3vWv -PFRViCxLp5LQLmkTQ3dglVQA4x6ZaonaewdPtdhjkLUuIqDvQx5+kIaOELbSws+c -bREYlnGrFw== ------END CERTIFICATE----- ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: AES-256-CBC,D459676347D389E9135496D8AAFA7953 - -wbrjxr9NHur8kgxDsgXOY9qFGKpONIQLxkuahUrDD/H+s/l7ugsLWOPsOXbjNL/7 -QYUBAx85HKm9D8BQ5g78Y82qfArap3/3IIuysDfQDh4fQodhVtmGTFiCOvudlGEp -lq1niQRLThlxeRoFphH8KKiOTO9a/d8tdL7zRmiFwnVnhK4014mgVmgcSefA1AF5 -RbJAeMclUKddG6ltQK00ptg84CDXiMWQXFBGGmQ1av2lyFzC+xLP+qDqZAYTM9lZ -NFRo2oEZP1ozfOVNSbXTanJgZ0DSSmhGE1PcVrHSeE/v+k1kPh3oVKi9GV51kIDC -Zd9f/XltuDOzy1Ybn6gRy4nzNpzcwjSCIHEdSD5nxU5JfHfQ3OtnsEab7qf989iP -s2LbCSp5uGTMvfesMIkixIZAQp2FeahZTAgU2Vx+wi5Kks68rOqeywEfzACL/Um5 -7XZu8gDs4MgRRWnxK1BbJDPifICLvSJZvgB9FKX/hk4FHFF+MtcrkalehCuLooDV -3rfHNvRSbg7J97XQ3QC+k9ZDaumpy6n+LhaVv7BIJRBnBBtZ5Eg3DmPg6flqaHAU -Y/8d82wb/pCmbvR3B1/Ebgs84DPJ+uZnY9M5Iwx19oqlVSR2ts/Tx619LGAm+BiQ -7YDoC4CFmpAA8Uw0xnUbNgx94NdNmlnLeLtS50b0XlWpHKbVzmVbNYEjY6NHMlLt -aqxWHTYTa7g/c1bg2/nxF1Lbfu5VSTROGBUuer1c3yzVuyBrjcX92Jp4BJH78qOp -N6lY6MnH4HYRXHjzlt/S0ZzO0faPPe18Q8SWvnDVuE3fYzzL772B56d2t8eodc+/ -t6M3qJ60eXdsmgYOaPRLRUovN2xT2UUr0+biuguHyqfaVfcEU/adw+b9oUVE+5Nw -nZHI5qhPnhLxChyZqbBl68zMUyKlfff4OyLvRGpfcHwBw6DTGjduB+DDsqqkcIB9 -2VL6nps7ZVCwMPI18siUd6cttEOf6ZXrVqHg9wfDvJOlh2NNKNLxSAFubHc90Jlj -KejrWenXo2w6YkSUeTV4t4cWu7U8rXIkTJXDl1S6NO8DWqNDo5KjgJ2SK5NlSOJ7 -jgECn390ooneJOxxytPVQO2xppXQZZS65RHrvhB+ss5xUknly9q+ICyt6xTR9nqA -PKkeSE6qVY0J4JgFXpkgQxgwMnjSED3LKr3jlz28pr5cC6tsc5SSlekHjT2fcSrX -uccaVahaJRigf+q+4XzmJtdwbZU+YWGZRVMlQLA5yzPHQHDYkPpOeYU4WReND8S4 -TZRkPHaxOZ2lKQwJB93V8Vbt2MvwRy392452a33S4TcQLaWzoOljXjmZjrp2rvRz -prBaNe8LnO4V8Oliv+H+E0UWiWFDuI+HBy4X4O9plsbw/gk64Phl9qLiBwaX/AIR -66FXvC/czABo9oSt2jekcMtJofYr8Gr2bsJlt5ZX+GEOxz4jMv7xvz5/L3W7jVav -pHGIv4xfN9FrXzL47O7UuUF9xZg4Rp/fxwpgEDNZmX/3DnP0ewZQUcgUX0pdqNGQ -YVqJXcRF7KqG2NSQFuwPESZQnxU0WzSgRyUae7xg1WKfSuN8NVAzKhOgeqlD2IAo ------END RSA PRIVATE KEY----- ------BEGIN CERTIFICATE----- -MIIDlzCCAn+gAwIBAgIJAMJYU3U6A0IRMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNV -BAYTAkFVMQwwCgYDVQQIEwNOU1cxDzANBgNVBAcTBlN5ZG5leTENMAsGA1UEChME -YXNpbzAeFw0xNTExMTgyMjMzNDhaFw0yMDExMTYyMjMzNDhaMDsxCzAJBgNVBAYT -AkFVMQwwCgYDVQQIEwNOU1cxDzANBgNVBAcTBlN5ZG5leTENMAsGA1UEChMEYXNp -bzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMcRJocHdVMdLUJ/pypY -QVSTC0t3IIgjwjazrK3kAaoIMvzPmDFxEXWcDx+nyz8kQ/E38Ir/ef2BCNGci5hu -wkfMSuMoW9l2N4hx3QCcF46tTDEZztFxWAH7QbE2wYMlMgKZSxWimNfq0YjxEEXb -QM0lGPLFh7Xoko29H0F3LKaaQV9u/vop3Hs0h12HeWlY4PiLp7QQTNGqbWcXycA0 -NZ/fyismireyEvPAgo6L8iXuAi7g0TVKVNlrticGGjMcMq6IMvxzEpSMkuMQ5rWj -pZjWOoBjSYBuXdblcBRvXhOr2Ws8jJLMZfehKq9q1reQfoGV6xMnbwmumSXbWRWT -0vkCAwEAAaOBnTCBmjAdBgNVHQ4EFgQUK/Zv/AVtfIeucJw8VEtux1dhI1YwawYD -VR0jBGQwYoAUK/Zv/AVtfIeucJw8VEtux1dhI1ahP6Q9MDsxCzAJBgNVBAYTAkFV -MQwwCgYDVQQIEwNOU1cxDzANBgNVBAcTBlN5ZG5leTENMAsGA1UEChMEYXNpb4IJ -AMJYU3U6A0IRMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBABLYXimq -v/HLyIJi7Xn8AJUsICj8LKF/J24nwwiF+ibf7UkoChJURs4nN78bod/lpDVPTEVl -gTBdV/vBJs416sCEFfsGjqB9OBYj4gb0VaJDsQd0+NMvXp0faKv2y9wgScxG9/cg -aM7eRmyfMn1qjb6tpNxVOPpe/nFi8Vx/1orejBRaZr4zF5TkoPepfwLWQeXDUIdE -+QHZ60jZAkR5RXTVU4u3kOKcJs839pmJYyxM4H2VxpR18vy4/YdIVWkREIUM2OgT -5iznIQIIgR56QRGP85uef+I6n0BHzrBk6du69bkQFxrFjLVGlal4bIQqSg4KGWgx -dEdymMWzmMxpO9s= ------END CERTIFICATE----- diff --git a/3rdparty/asio/src/examples/cpp03/timeouts/.gitignore b/3rdparty/asio/src/examples/cpp03/timeouts/.gitignore deleted file mode 100644 index dda7f39c3c2..00000000000 --- a/3rdparty/asio/src/examples/cpp03/timeouts/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_client -server -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/timeouts/blocking_tcp_client.cpp b/3rdparty/asio/src/examples/cpp03/timeouts/blocking_tcp_client.cpp deleted file mode 100644 index 69d467af1bb..00000000000 --- a/3rdparty/asio/src/examples/cpp03/timeouts/blocking_tcp_client.cpp +++ /dev/null @@ -1,242 +0,0 @@ -// -// blocking_tcp_client.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "asio/connect.hpp" -#include "asio/deadline_timer.hpp" -#include "asio/io_context.hpp" -#include "asio/ip/tcp.hpp" -#include "asio/read_until.hpp" -#include "asio/streambuf.hpp" -#include "asio/system_error.hpp" -#include "asio/write.hpp" -#include "asio/thread.hpp" -#include <cstdlib> -#include <iostream> -#include <string> -#include <boost/lambda/bind.hpp> -#include <boost/lambda/lambda.hpp> - -using asio::deadline_timer; -using asio::ip::tcp; -using boost::lambda::bind; -using boost::lambda::var; -using boost::lambda::_1; - -//---------------------------------------------------------------------- - -// -// This class manages socket timeouts by applying the concept of a deadline. -// Each asynchronous operation is given a deadline by which it must complete. -// Deadlines are enforced by an "actor" that persists for the lifetime of the -// client object: -// -// +----------------+ -// | | -// | check_deadline |<---+ -// | | | -// +----------------+ | async_wait() -// | | -// +---------+ -// -// If the actor determines that the deadline has expired, the socket is closed -// and any outstanding operations are consequently cancelled. The socket -// operations themselves use boost::lambda function objects as completion -// handlers. For a given socket operation, the client object runs the -// io_context to block thread execution until the actor completes. -// -class client -{ -public: - client() - : socket_(io_context_), - deadline_(io_context_) - { - // No deadline is required until the first socket operation is started. We - // set the deadline to positive infinity so that the actor takes no action - // until a specific deadline is set. - deadline_.expires_at(boost::posix_time::pos_infin); - - // Start the persistent actor that checks for deadline expiry. - check_deadline(); - } - - void connect(const std::string& host, const std::string& service, - boost::posix_time::time_duration timeout) - { - // Resolve the host name and service to a list of endpoints. - tcp::resolver::results_type endpoints = - tcp::resolver(io_context_).resolve(host, service); - - // Set a deadline for the asynchronous operation. As a host name may - // resolve to multiple endpoints, this function uses the composed operation - // async_connect. The deadline applies to the entire operation, rather than - // individual connection attempts. - deadline_.expires_from_now(timeout); - - // Set up the variable that receives the result of the asynchronous - // operation. The error code is set to would_block to signal that the - // operation is incomplete. Asio guarantees that its asynchronous - // operations will never fail with would_block, so any other value in - // ec indicates completion. - asio::error_code ec = asio::error::would_block; - - // Start the asynchronous operation itself. The boost::lambda function - // object is used as a callback and will update the ec variable when the - // operation completes. The blocking_udp_client.cpp example shows how you - // can use boost::bind rather than boost::lambda. - asio::async_connect(socket_, endpoints, var(ec) = _1); - - // Block until the asynchronous operation has completed. - do io_context_.run_one(); while (ec == asio::error::would_block); - - // Determine whether a connection was successfully established. The - // deadline actor may have had a chance to run and close our socket, even - // though the connect operation notionally succeeded. Therefore we must - // check whether the socket is still open before deciding if we succeeded - // or failed. - if (ec || !socket_.is_open()) - throw asio::system_error( - ec ? ec : asio::error::operation_aborted); - } - - std::string read_line(boost::posix_time::time_duration timeout) - { - // Set a deadline for the asynchronous operation. Since this function uses - // a composed operation (async_read_until), the deadline applies to the - // entire operation, rather than individual reads from the socket. - deadline_.expires_from_now(timeout); - - // Set up the variable that receives the result of the asynchronous - // operation. The error code is set to would_block to signal that the - // operation is incomplete. Asio guarantees that its asynchronous - // operations will never fail with would_block, so any other value in - // ec indicates completion. - asio::error_code ec = asio::error::would_block; - - // Start the asynchronous operation itself. The boost::lambda function - // object is used as a callback and will update the ec variable when the - // operation completes. The blocking_udp_client.cpp example shows how you - // can use boost::bind rather than boost::lambda. - asio::async_read_until(socket_, input_buffer_, '\n', var(ec) = _1); - - // Block until the asynchronous operation has completed. - do io_context_.run_one(); while (ec == asio::error::would_block); - - if (ec) - throw asio::system_error(ec); - - std::string line; - std::istream is(&input_buffer_); - std::getline(is, line); - return line; - } - - void write_line(const std::string& line, - boost::posix_time::time_duration timeout) - { - std::string data = line + "\n"; - - // Set a deadline for the asynchronous operation. Since this function uses - // a composed operation (async_write), the deadline applies to the entire - // operation, rather than individual writes to the socket. - deadline_.expires_from_now(timeout); - - // Set up the variable that receives the result of the asynchronous - // operation. The error code is set to would_block to signal that the - // operation is incomplete. Asio guarantees that its asynchronous - // operations will never fail with would_block, so any other value in - // ec indicates completion. - asio::error_code ec = asio::error::would_block; - - // Start the asynchronous operation itself. The boost::lambda function - // object is used as a callback and will update the ec variable when the - // operation completes. The blocking_udp_client.cpp example shows how you - // can use boost::bind rather than boost::lambda. - asio::async_write(socket_, asio::buffer(data), var(ec) = _1); - - // Block until the asynchronous operation has completed. - do io_context_.run_one(); while (ec == asio::error::would_block); - - if (ec) - throw asio::system_error(ec); - } - -private: - void check_deadline() - { - // Check whether the deadline has passed. We compare the deadline against - // the current time since a new asynchronous operation may have moved the - // deadline before this actor had a chance to run. - if (deadline_.expires_at() <= deadline_timer::traits_type::now()) - { - // The deadline has passed. The socket is closed so that any outstanding - // asynchronous operations are cancelled. This allows the blocked - // connect(), read_line() or write_line() functions to return. - asio::error_code ignored_ec; - socket_.close(ignored_ec); - - // There is no longer an active deadline. The expiry is set to positive - // infinity so that the actor takes no action until a new deadline is set. - deadline_.expires_at(boost::posix_time::pos_infin); - } - - // Put the actor back to sleep. - deadline_.async_wait(bind(&client::check_deadline, this)); - } - - asio::io_context io_context_; - tcp::socket socket_; - deadline_timer deadline_; - asio::streambuf input_buffer_; -}; - -//---------------------------------------------------------------------- - -int main(int argc, char* argv[]) -{ - try - { - if (argc != 4) - { - std::cerr << "Usage: blocking_tcp <host> <port> <message>\n"; - return 1; - } - - client c; - c.connect(argv[1], argv[2], boost::posix_time::seconds(10)); - - boost::posix_time::ptime time_sent = - boost::posix_time::microsec_clock::universal_time(); - - c.write_line(argv[3], boost::posix_time::seconds(10)); - - for (;;) - { - std::string line = c.read_line(boost::posix_time::seconds(10)); - - // Keep going until we get back the line that was sent. - if (line == argv[3]) - break; - } - - boost::posix_time::ptime time_received = - boost::posix_time::microsec_clock::universal_time(); - - std::cout << "Round trip time: "; - std::cout << (time_received - time_sent).total_microseconds(); - std::cout << " microseconds\n"; - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/timeouts/blocking_udp_client.cpp b/3rdparty/asio/src/examples/cpp03/timeouts/blocking_udp_client.cpp deleted file mode 100644 index fd2da7640b8..00000000000 --- a/3rdparty/asio/src/examples/cpp03/timeouts/blocking_udp_client.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// -// blocking_udp_client.cpp -// ~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include "asio/deadline_timer.hpp" -#include "asio/io_context.hpp" -#include "asio/ip/udp.hpp" -#include <cstdlib> -#include <boost/bind.hpp> -#include <boost/date_time/posix_time/posix_time_types.hpp> -#include <iostream> - -using asio::deadline_timer; -using asio::ip::udp; - -//---------------------------------------------------------------------- - -// -// This class manages socket timeouts by applying the concept of a deadline. -// Each asynchronous operation is given a deadline by which it must complete. -// Deadlines are enforced by an "actor" that persists for the lifetime of the -// client object: -// -// +----------------+ -// | | -// | check_deadline |<---+ -// | | | -// +----------------+ | async_wait() -// | | -// +---------+ -// -// If the actor determines that the deadline has expired, any outstanding -// socket operations are cancelled. The socket operations themselves are -// implemented as transient actors: -// -// +---------------+ -// | | -// | receive | -// | | -// +---------------+ -// | -// async_- | +----------------+ -// receive() | | | -// +--->| handle_receive | -// | | -// +----------------+ -// -// The client object runs the io_context to block thread execution until the -// actor completes. -// -class client -{ -public: - client(const udp::endpoint& listen_endpoint) - : socket_(io_context_, listen_endpoint), - deadline_(io_context_) - { - // No deadline is required until the first socket operation is started. We - // set the deadline to positive infinity so that the actor takes no action - // until a specific deadline is set. - deadline_.expires_at(boost::posix_time::pos_infin); - - // Start the persistent actor that checks for deadline expiry. - check_deadline(); - } - - std::size_t receive(const asio::mutable_buffer& buffer, - boost::posix_time::time_duration timeout, asio::error_code& ec) - { - // Set a deadline for the asynchronous operation. - deadline_.expires_from_now(timeout); - - // Set up the variables that receive the result of the asynchronous - // operation. The error code is set to would_block to signal that the - // operation is incomplete. Asio guarantees that its asynchronous - // operations will never fail with would_block, so any other value in - // ec indicates completion. - ec = asio::error::would_block; - std::size_t length = 0; - - // Start the asynchronous operation itself. The handle_receive function - // used as a callback will update the ec and length variables. - socket_.async_receive(asio::buffer(buffer), - boost::bind(&client::handle_receive, _1, _2, &ec, &length)); - - // Block until the asynchronous operation has completed. - do io_context_.run_one(); while (ec == asio::error::would_block); - - return length; - } - -private: - void check_deadline() - { - // Check whether the deadline has passed. We compare the deadline against - // the current time since a new asynchronous operation may have moved the - // deadline before this actor had a chance to run. - if (deadline_.expires_at() <= deadline_timer::traits_type::now()) - { - // The deadline has passed. The outstanding asynchronous operation needs - // to be cancelled so that the blocked receive() function will return. - // - // Please note that cancel() has portability issues on some versions of - // Microsoft Windows, and it may be necessary to use close() instead. - // Consult the documentation for cancel() for further information. - socket_.cancel(); - - // There is no longer an active deadline. The expiry is set to positive - // infinity so that the actor takes no action until a new deadline is set. - deadline_.expires_at(boost::posix_time::pos_infin); - } - - // Put the actor back to sleep. - deadline_.async_wait(boost::bind(&client::check_deadline, this)); - } - - static void handle_receive( - const asio::error_code& ec, std::size_t length, - asio::error_code* out_ec, std::size_t* out_length) - { - *out_ec = ec; - *out_length = length; - } - -private: - asio::io_context io_context_; - udp::socket socket_; - deadline_timer deadline_; -}; - -//---------------------------------------------------------------------- - -int main(int argc, char* argv[]) -{ - try - { - using namespace std; // For atoi. - - if (argc != 3) - { - std::cerr << "Usage: blocking_udp_timeout <listen_addr> <listen_port>\n"; - return 1; - } - - udp::endpoint listen_endpoint( - asio::ip::make_address(argv[1]), - std::atoi(argv[2])); - - client c(listen_endpoint); - - for (;;) - { - char data[1024]; - asio::error_code ec; - std::size_t n = c.receive(asio::buffer(data), - boost::posix_time::seconds(10), ec); - - if (ec) - { - std::cout << "Receive error: " << ec.message() << "\n"; - } - else - { - std::cout << "Received: "; - std::cout.write(data, n); - std::cout << "\n"; - } - } - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/timeouts/server.cpp b/3rdparty/asio/src/examples/cpp03/timeouts/server.cpp deleted file mode 100644 index 212cd90d820..00000000000 --- a/3rdparty/asio/src/examples/cpp03/timeouts/server.cpp +++ /dev/null @@ -1,427 +0,0 @@ -// -// server.cpp -// ~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <algorithm> -#include <cstdlib> -#include <deque> -#include <iostream> -#include <set> -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> -#include "asio/deadline_timer.hpp" -#include "asio/io_context.hpp" -#include "asio/ip/tcp.hpp" -#include "asio/ip/udp.hpp" -#include "asio/read_until.hpp" -#include "asio/streambuf.hpp" -#include "asio/write.hpp" - -using asio::deadline_timer; -using asio::ip::tcp; -using asio::ip::udp; - -//---------------------------------------------------------------------- - -class subscriber -{ -public: - virtual ~subscriber() {} - virtual void deliver(const std::string& msg) = 0; -}; - -typedef boost::shared_ptr<subscriber> subscriber_ptr; - -//---------------------------------------------------------------------- - -class channel -{ -public: - void join(subscriber_ptr subscriber) - { - subscribers_.insert(subscriber); - } - - void leave(subscriber_ptr subscriber) - { - subscribers_.erase(subscriber); - } - - void deliver(const std::string& msg) - { - std::for_each(subscribers_.begin(), subscribers_.end(), - boost::bind(&subscriber::deliver, _1, boost::ref(msg))); - } - -private: - std::set<subscriber_ptr> subscribers_; -}; - -//---------------------------------------------------------------------- - -// -// This class manages socket timeouts by applying the concept of a deadline. -// Some asynchronous operations are given deadlines by which they must complete. -// Deadlines are enforced by two "actors" that persist for the lifetime of the -// session object, one for input and one for output: -// -// +----------------+ +----------------+ -// | | | | -// | check_deadline |<---+ | check_deadline |<---+ -// | | | async_wait() | | | async_wait() -// +----------------+ | on input +----------------+ | on output -// | | deadline | | deadline -// +---------+ +---------+ -// -// If either deadline actor determines that the corresponding deadline has -// expired, the socket is closed and any outstanding operations are cancelled. -// -// The input actor reads messages from the socket, where messages are delimited -// by the newline character: -// -// +------------+ -// | | -// | start_read |<---+ -// | | | -// +------------+ | -// | | -// async_- | +-------------+ -// read_- | | | -// until() +--->| handle_read | -// | | -// +-------------+ -// -// The deadline for receiving a complete message is 30 seconds. If a non-empty -// message is received, it is delivered to all subscribers. If a heartbeat (a -// message that consists of a single newline character) is received, a heartbeat -// is enqueued for the client, provided there are no other messages waiting to -// be sent. -// -// The output actor is responsible for sending messages to the client: -// -// +--------------+ -// | |<---------------------+ -// | await_output | | -// | |<---+ | -// +--------------+ | | -// | | | async_wait() | -// | +--------+ | -// V | -// +-------------+ +--------------+ -// | | async_write() | | -// | start_write |-------------->| handle_write | -// | | | | -// +-------------+ +--------------+ -// -// The output actor first waits for an output message to be enqueued. It does -// this by using a deadline_timer as an asynchronous condition variable. The -// deadline_timer will be signalled whenever the output queue is non-empty. -// -// Once a message is available, it is sent to the client. The deadline for -// sending a complete message is 30 seconds. After the message is successfully -// sent, the output actor again waits for the output queue to become non-empty. -// -class tcp_session - : public subscriber, - public boost::enable_shared_from_this<tcp_session> -{ -public: - tcp_session(asio::io_context& io_context, channel& ch) - : channel_(ch), - socket_(io_context), - input_deadline_(io_context), - non_empty_output_queue_(io_context), - output_deadline_(io_context) - { - input_deadline_.expires_at(boost::posix_time::pos_infin); - output_deadline_.expires_at(boost::posix_time::pos_infin); - - // The non_empty_output_queue_ deadline_timer is set to pos_infin whenever - // the output queue is empty. This ensures that the output actor stays - // asleep until a message is put into the queue. - non_empty_output_queue_.expires_at(boost::posix_time::pos_infin); - } - - tcp::socket& socket() - { - return socket_; - } - - // Called by the server object to initiate the four actors. - void start() - { - channel_.join(shared_from_this()); - - start_read(); - - input_deadline_.async_wait( - boost::bind(&tcp_session::check_deadline, - shared_from_this(), &input_deadline_)); - - await_output(); - - output_deadline_.async_wait( - boost::bind(&tcp_session::check_deadline, - shared_from_this(), &output_deadline_)); - } - -private: - void stop() - { - channel_.leave(shared_from_this()); - - asio::error_code ignored_ec; - socket_.close(ignored_ec); - input_deadline_.cancel(); - non_empty_output_queue_.cancel(); - output_deadline_.cancel(); - } - - bool stopped() const - { - return !socket_.is_open(); - } - - void deliver(const std::string& msg) - { - output_queue_.push_back(msg + "\n"); - - // Signal that the output queue contains messages. Modifying the expiry - // will wake the output actor, if it is waiting on the timer. - non_empty_output_queue_.expires_at(boost::posix_time::neg_infin); - } - - void start_read() - { - // Set a deadline for the read operation. - input_deadline_.expires_from_now(boost::posix_time::seconds(30)); - - // Start an asynchronous operation to read a newline-delimited message. - asio::async_read_until(socket_, input_buffer_, '\n', - boost::bind(&tcp_session::handle_read, shared_from_this(), _1)); - } - - void handle_read(const asio::error_code& ec) - { - if (stopped()) - return; - - if (!ec) - { - // Extract the newline-delimited message from the buffer. - std::string msg; - std::istream is(&input_buffer_); - std::getline(is, msg); - - if (!msg.empty()) - { - channel_.deliver(msg); - } - else - { - // We received a heartbeat message from the client. If there's nothing - // else being sent or ready to be sent, send a heartbeat right back. - if (output_queue_.empty()) - { - output_queue_.push_back("\n"); - - // Signal that the output queue contains messages. Modifying the - // expiry will wake the output actor, if it is waiting on the timer. - non_empty_output_queue_.expires_at(boost::posix_time::neg_infin); - } - } - - start_read(); - } - else - { - stop(); - } - } - - void await_output() - { - if (stopped()) - return; - - if (output_queue_.empty()) - { - // There are no messages that are ready to be sent. The actor goes to - // sleep by waiting on the non_empty_output_queue_ timer. When a new - // message is added, the timer will be modified and the actor will wake. - non_empty_output_queue_.expires_at(boost::posix_time::pos_infin); - non_empty_output_queue_.async_wait( - boost::bind(&tcp_session::await_output, shared_from_this())); - } - else - { - start_write(); - } - } - - void start_write() - { - // Set a deadline for the write operation. - output_deadline_.expires_from_now(boost::posix_time::seconds(30)); - - // Start an asynchronous operation to send a message. - asio::async_write(socket_, - asio::buffer(output_queue_.front()), - boost::bind(&tcp_session::handle_write, shared_from_this(), _1)); - } - - void handle_write(const asio::error_code& ec) - { - if (stopped()) - return; - - if (!ec) - { - output_queue_.pop_front(); - - await_output(); - } - else - { - stop(); - } - } - - void check_deadline(deadline_timer* deadline) - { - if (stopped()) - return; - - // Check whether the deadline has passed. We compare the deadline against - // the current time since a new asynchronous operation may have moved the - // deadline before this actor had a chance to run. - if (deadline->expires_at() <= deadline_timer::traits_type::now()) - { - // The deadline has passed. Stop the session. The other actors will - // terminate as soon as possible. - stop(); - } - else - { - // Put the actor back to sleep. - deadline->async_wait( - boost::bind(&tcp_session::check_deadline, - shared_from_this(), deadline)); - } - } - - channel& channel_; - tcp::socket socket_; - asio::streambuf input_buffer_; - deadline_timer input_deadline_; - std::deque<std::string> output_queue_; - deadline_timer non_empty_output_queue_; - deadline_timer output_deadline_; -}; - -typedef boost::shared_ptr<tcp_session> tcp_session_ptr; - -//---------------------------------------------------------------------- - -class udp_broadcaster - : public subscriber -{ -public: - udp_broadcaster(asio::io_context& io_context, - const udp::endpoint& broadcast_endpoint) - : socket_(io_context) - { - socket_.connect(broadcast_endpoint); - } - -private: - void deliver(const std::string& msg) - { - asio::error_code ignored_ec; - socket_.send(asio::buffer(msg), 0, ignored_ec); - } - - udp::socket socket_; -}; - -//---------------------------------------------------------------------- - -class server -{ -public: - server(asio::io_context& io_context, - const tcp::endpoint& listen_endpoint, - const udp::endpoint& broadcast_endpoint) - : io_context_(io_context), - acceptor_(io_context, listen_endpoint) - { - subscriber_ptr bc(new udp_broadcaster(io_context_, broadcast_endpoint)); - channel_.join(bc); - - start_accept(); - } - - void start_accept() - { - tcp_session_ptr new_session(new tcp_session(io_context_, channel_)); - - acceptor_.async_accept(new_session->socket(), - boost::bind(&server::handle_accept, this, new_session, _1)); - } - - void handle_accept(tcp_session_ptr session, - const asio::error_code& ec) - { - if (!ec) - { - session->start(); - } - - start_accept(); - } - -private: - asio::io_context& io_context_; - tcp::acceptor acceptor_; - channel channel_; -}; - -//---------------------------------------------------------------------- - -int main(int argc, char* argv[]) -{ - try - { - using namespace std; // For atoi. - - if (argc != 4) - { - std::cerr << "Usage: server <listen_port> <bcast_address> <bcast_port>\n"; - return 1; - } - - asio::io_context io_context; - - tcp::endpoint listen_endpoint(tcp::v4(), atoi(argv[1])); - - udp::endpoint broadcast_endpoint( - asio::ip::make_address(argv[2]), atoi(argv[3])); - - server s(io_context, listen_endpoint, broadcast_endpoint); - - io_context.run(); - } - catch (std::exception& e) - { - std::cerr << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/timers/.gitignore b/3rdparty/asio/src/examples/cpp03/timers/.gitignore deleted file mode 100644 index a3fe695226f..00000000000 --- a/3rdparty/asio/src/examples/cpp03/timers/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*timer -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/timers/tick_count_timer.cpp b/3rdparty/asio/src/examples/cpp03/timers/tick_count_timer.cpp deleted file mode 100644 index 8b98cfd2a54..00000000000 --- a/3rdparty/asio/src/examples/cpp03/timers/tick_count_timer.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// -// tick_count_timer.cpp -// ~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <asio.hpp> -#include <ctime> -#include <iostream> - -#if defined(WIN32) -# include <windows.h> -#else -# error This example is for Windows only! -#endif - -struct tick_count_traits -{ - // The time type. This type has no constructor that takes a DWORD to ensure - // that the timer can only be used with relative times. - class time_type - { - public: - time_type() : ticks_(0) {} - private: - friend struct tick_count_traits; - DWORD ticks_; - }; - - // The duration type. According to the TimeTraits requirements, the duration - // must be a signed type. This means we can't handle durations larger than - // 2^31. - class duration_type - { - public: - duration_type() : ticks_(0) {} - duration_type(LONG ticks) : ticks_(ticks) {} - private: - friend struct tick_count_traits; - LONG ticks_; - }; - - // Get the current time. - static time_type now() - { - time_type result; - result.ticks_ = ::GetTickCount(); - return result; - } - - // Add a duration to a time. - static time_type add(const time_type& t, const duration_type& d) - { - time_type result; - result.ticks_ = t.ticks_ + d.ticks_; - return result; - } - - // Subtract one time from another. - static duration_type subtract(const time_type& t1, const time_type& t2) - { - // DWORD tick count values can wrap (see less_than() below). We'll convert - // to a duration by taking the absolute difference and adding the sign - // based on which is the "lesser" absolute time. - return duration_type(less_than(t1, t2) - ? -static_cast<LONG>(t2.ticks_ - t1.ticks_) - : static_cast<LONG>(t1.ticks_ - t2.ticks_)); - } - - // Test whether one time is less than another. - static bool less_than(const time_type& t1, const time_type& t2) - { - // DWORD tick count values wrap periodically, so we'll use a heuristic that - // says that if subtracting t1 from t2 yields a value smaller than 2^31, - // then t1 is probably less than t2. This means that we can't handle - // durations larger than 2^31, which shouldn't be a problem in practice. - return (t2.ticks_ - t1.ticks_) < static_cast<DWORD>(1 << 31); - } - - // Convert to POSIX duration type. - static boost::posix_time::time_duration to_posix_duration( - const duration_type& d) - { - return boost::posix_time::milliseconds(d.ticks_); - } -}; - -typedef asio::basic_deadline_timer< - DWORD, tick_count_traits> tick_count_timer; - -void handle_timeout(const asio::error_code&) -{ - std::cout << "handle_timeout\n"; -} - -int main() -{ - try - { - asio::io_context io_context; - - tick_count_timer timer(io_context, 5000); - std::cout << "Starting synchronous wait\n"; - timer.wait(); - std::cout << "Finished synchronous wait\n"; - - timer.expires_from_now(5000); - std::cout << "Starting asynchronous wait\n"; - timer.async_wait(&handle_timeout); - io_context.run(); - std::cout << "Finished asynchronous wait\n"; - } - catch (std::exception& e) - { - std::cout << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/timers/time_t_timer.cpp b/3rdparty/asio/src/examples/cpp03/timers/time_t_timer.cpp deleted file mode 100644 index 8a434e9b20c..00000000000 --- a/3rdparty/asio/src/examples/cpp03/timers/time_t_timer.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// -// time_t_timer.cpp -// ~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include <asio.hpp> -#include <ctime> -#include <iostream> - -struct time_t_traits -{ - // The time type. - typedef std::time_t time_type; - - // The duration type. - struct duration_type - { - duration_type() : value(0) {} - duration_type(std::time_t v) : value(v) {} - std::time_t value; - }; - - // Get the current time. - static time_type now() - { - return std::time(0); - } - - // Add a duration to a time. - static time_type add(const time_type& t, const duration_type& d) - { - return t + d.value; - } - - // Subtract one time from another. - static duration_type subtract(const time_type& t1, const time_type& t2) - { - return duration_type(t1 - t2); - } - - // Test whether one time is less than another. - static bool less_than(const time_type& t1, const time_type& t2) - { - return t1 < t2; - } - - // Convert to POSIX duration type. - static boost::posix_time::time_duration to_posix_duration( - const duration_type& d) - { - return boost::posix_time::seconds(d.value); - } -}; - -typedef asio::basic_deadline_timer< - std::time_t, time_t_traits> time_t_timer; - -void handle_timeout(const asio::error_code&) -{ - std::cout << "handle_timeout\n"; -} - -int main() -{ - try - { - asio::io_context io_context; - - time_t_timer timer(io_context); - - timer.expires_from_now(5); - std::cout << "Starting synchronous wait\n"; - timer.wait(); - std::cout << "Finished synchronous wait\n"; - - timer.expires_from_now(5); - std::cout << "Starting asynchronous wait\n"; - timer.async_wait(&handle_timeout); - io_context.run(); - std::cout << "Finished asynchronous wait\n"; - } - catch (std::exception& e) - { - std::cout << "Exception: " << e.what() << "\n"; - } - - return 0; -} diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime1/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/daytime1/.gitignore deleted file mode 100644 index 2926eaf9bf6..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime1/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -client -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime2/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/daytime2/.gitignore deleted file mode 100644 index 7f06efb3296..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime2/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -server -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime3/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/daytime3/.gitignore deleted file mode 100644 index 7f06efb3296..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime3/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -server -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime4/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/daytime4/.gitignore deleted file mode 100644 index 2926eaf9bf6..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime4/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -client -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime5/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/daytime5/.gitignore deleted file mode 100644 index 7f06efb3296..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime5/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -server -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime6/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/daytime6/.gitignore deleted file mode 100644 index 7f06efb3296..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime6/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -server -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime7/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/daytime7/.gitignore deleted file mode 100644 index 7f06efb3296..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime7/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -server -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime_dox.txt b/3rdparty/asio/src/examples/cpp03/tutorial/daytime_dox.txt deleted file mode 100644 index 1bf591a43a8..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime_dox.txt +++ /dev/null @@ -1,502 +0,0 @@ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -/** -\page tutdaytime1 Daytime.1 - A synchronous TCP daytime client - -This tutorial program shows how to use asio to implement a client application -with TCP. - -\dontinclude daytime1/client.cpp -\skip #include - -We start by including the necessary header files. - -\until asio.hpp - -The purpose of this application is to access a daytime service, -so we need the user to specify the server. - -\until } - -All programs that use asio need to have at least one asio::io_service -object. - -\until asio::io_service - -We need to turn the server name that was specified as a parameter to the -application, into a TCP endpoint. To do this we use an -asio::ip::tcp::resolver object. - -\until tcp::resolver - -A resolver takes a query object and turns it into a list of endpoints. We -construct a query using the name of the server, specified in <tt>argv[1]</tt>, -and the name of the service, in this case <tt>"daytime"</tt>. - -\until tcp::resolver::query - -The list of endpoints is returned using an iterator of type -asio::ip::tcp::resolver::iterator. (Note that a default constructed -asio::ip::tcp::resolver::iterator object can be used as an end iterator.) - -\until tcp::resolver::iterator - -Now we create and connect the socket. The list of endpoints obtained above may -contain both IPv4 and IPv6 endpoints, so we need to try each of them until we -find one that works. This keeps the client program independent of a specific IP -version. The asio::connect() function does this for us automatically. - -\until asio::connect - -The connection is open. All we need to do now is read the response from the -daytime service. - -We use a <tt>boost::array</tt> to hold the received data. The asio::buffer() -function automatically determines the size of the array to help prevent buffer -overruns. Instead of a <tt>boost::array</tt>, we could have used a <tt>char -[]</tt> or <tt>std::vector</tt>. - -\until read_some - -When the server closes the connection, the asio::ip::tcp::socket::read_some() -function will exit with the asio::error::eof error, which is how we know to -exit the loop. - -\until } - -Finally, handle any exceptions that may have been thrown. - -\until } -\until } - -See the \ref tutdaytime1src "full source listing" \n -Return to the \ref index "tutorial index" \n -Next: \ref tutdaytime2 - -*/ - -/** -\page tutdaytime1src Source listing for Daytime.1 -\include daytime1/client.cpp -Return to \ref tutdaytime1 -*/ - -/** -\page tutdaytime2 Daytime.2 - A synchronous TCP daytime server - -This tutorial program shows how to use asio to implement a server application -with TCP. - -\dontinclude daytime2/server.cpp -\skip #include - -\until using - -We define the function <tt>make_daytime_string()</tt> to create the string to -be sent back to the client. This function will be reused in all of our daytime -server applications. - -\until asio::io_service - -A asio::ip::tcp::acceptor object needs to be created to listen -for new connections. It is initialised to listen on TCP port 13, for IP version 4. - -\until tcp::acceptor - -This is an iterative server, which means that it will handle one -connection at a time. Create a socket that will represent the connection to the -client, and then wait for a connection. - -\until acceptor.accept - -A client is accessing our service. Determine the current time -and transfer this information to the client. - -\until } -\until } - -Finally, handle any exceptions. - -\until } -\until } - -See the \ref tutdaytime2src "full source listing" \n -Return to the \ref index "tutorial index" \n -Previous: \ref tutdaytime1 \n -Next: \ref tutdaytime3 - -*/ - -/** -\page tutdaytime2src Source listing for Daytime.2 -\include daytime2/server.cpp -Return to \ref tutdaytime2 -*/ - -/** -\page tutdaytime3 Daytime.3 - An asynchronous TCP daytime server - -\section tutdaytime3funcmain The main() function - -\dontinclude daytime3/server.cpp -\skip int main() -\until try -\until { - -We need to create a server object to accept incoming client connections. The -asio::io_service object provides I/O services, such as sockets, that the -server object will use. - -\until tcp_server - -Run the asio::io_service object so that it will perform asynchronous operations -on your behalf. - -\until return 0; -\until } - -\section tutdaytime3classtcp_server The tcp_server class - -\dontinclude daytime3/server.cpp -\skip class tcp_server -\until public: - -The constructor initialises an acceptor to listen on TCP port 13. - -\until private: - -The function <tt>start_accept()</tt> creates a socket and initiates an -asynchronous accept operation to wait for a new connection. - -\until } - -The function <tt>handle_accept()</tt> is called when the asynchronous accept -operation initiated by <tt>start_accept()</tt> finishes. It services the client -request, and then calls <tt>start_accept()</tt> to initiate the next accept -operation. - -\until } -\until } - -\section tutdaytime3classtcp_connection The tcp_connection class - -We will use <tt>shared_ptr</tt> and <tt>enable_shared_from_this</tt> because we -want to keep the <tt>tcp_connection</tt> object alive as long as there is an -operation that refers to it. - -\dontinclude daytime3/server.cpp -\skip class tcp_connection -\until shared_ptr -\until } -\until } - -In the function <tt>start()</tt>, we call asio::async_write() to serve the data -to the client. Note that we are using asio::async_write(), rather than -asio::ip::tcp::socket::async_write_some(), to ensure that the entire block of -data is sent. - -\until { - -The data to be sent is stored in the class member <tt>message_</tt> as we need -to keep the data valid until the asynchronous operation is complete. - -\until message_ - -When initiating the asynchronous operation, and if using \ref boost_bind, you -must specify only the arguments that match the handler's parameter list. In -this program, both of the argument placeholders (asio::placeholders::error and -asio::placeholders::bytes_transferred) could potentially have been removed, -since they are not being used in <tt>handle_write()</tt>. - -\until placeholders::bytes_transferred - -Any further actions for this client connection are now the responsibility of -<tt>handle_write()</tt>. - -\until }; - -\section tutdaytime3remunused Removing unused handler parameters - -You may have noticed that the <tt>error</tt>, and <tt>bytes_transferred</tt> -parameters are not used in the body of the <tt>handle_write()</tt> function. If -parameters are not needed, it is possible to remove them from the function so -that it looks like: - -\code - void handle_write() - { - } -\endcode - -The asio::async_write() call used to initiate the call can then be changed to -just: - -\code - asio::async_write(socket_, asio::buffer(message_), - boost::bind(&tcp_connection::handle_write, shared_from_this())); -\endcode - -See the \ref tutdaytime3src "full source listing" \n -Return to the \ref index "tutorial index" \n -Previous: \ref tutdaytime2 \n -Next: \ref tutdaytime4 - -*/ - -/** -\page tutdaytime3src Source listing for Daytime.3 -\include daytime3/server.cpp -Return to \ref tutdaytime3 -*/ - -/** -\page tutdaytime4 Daytime.4 - A synchronous UDP daytime client - -This tutorial program shows how to use asio to implement a client application -with UDP. - -\dontinclude daytime4/client.cpp -\skip #include -\until using asio::ip::udp; - -The start of the application is essentially the same as for the TCP daytime -client. - -\until asio::io_service - -We use an asio::ip::udp::resolver object to find the correct remote endpoint to -use based on the host and service names. The query is restricted to return only -IPv4 endpoints by the asio::ip::udp::v4() argument. - -\until udp::v4 - -The asio::ip::udp::resolver::resolve() function is guaranteed to return at -least one endpoint in the list if it does not fail. This means it is safe to -dereference the return value directly. - -\until udp::endpoint - -Since UDP is datagram-oriented, we will not be using a stream socket. Create an -asio::ip::udp::socket and initiate contact with the remote endpoint. - -\until receiver_endpoint - -Now we need to be ready to accept whatever the server sends back to us. The -endpoint on our side that receives the server's response will be initialised by -asio::ip::udp::socket::receive_from(). - -\until } - -Finally, handle any exceptions that may have been thrown. - -\until } -\until } -See the \ref tutdaytime4src "full source listing" \n -Return to the \ref index "tutorial index" \n -Previous: \ref tutdaytime3 \n -Next: \ref tutdaytime5 - -*/ - -/** -\page tutdaytime4src Source listing for Daytime.4 -\include daytime4/client.cpp -Return to \ref tutdaytime4 -*/ - -/** -\page tutdaytime5 Daytime.5 - A synchronous UDP daytime server - -This tutorial program shows how to use asio to implement a server application -with UDP. - -\dontinclude daytime5/server.cpp -\skip int main() -\until asio::io_service - -Create an asio::ip::udp::socket object to receive requests on UDP port 13. - -\until udp::socket - -Wait for a client to initiate contact with us. The remote_endpoint object will -be populated by asio::ip::udp::socket::receive_from(). - -\until throw - -Determine what we are going to send back to the client. - -\until std::string message - -Send the response to the remote_endpoint. - -\until } -\until } - -Finally, handle any exceptions. - -\until } -\until } - -See the \ref tutdaytime5src "full source listing" \n -Return to the \ref index "tutorial index" \n -Previous: \ref tutdaytime4 \n -Next: \ref tutdaytime6 - -*/ - -/** -\page tutdaytime5src Source listing for Daytime.5 -\include daytime5/server.cpp -Return to \ref tutdaytime5 -*/ - -/** -\page tutdaytime6 Daytime.6 - An asynchronous UDP daytime server - -\section tutdaytime6funcmain The main() function - -\dontinclude daytime6/server.cpp -\skip int main() -\until try -\until { - -Create a server object to accept incoming client requests, and run -the asio::io_service object. - -\until return 0; -\until } - -\section tutdaytime6classudp_server The udp_server class - -\dontinclude daytime6/server.cpp -\skip class udp_server -\until public: - -The constructor initialises a socket to listen on UDP port 13. - -\until private: -\until { - -The function asio::ip::udp::socket::async_receive_from() will cause the -application to listen in the background for a new request. When such a request -is received, the asio::io_service object will invoke the -<tt>handle_receive()</tt> function with two arguments: a value of type -asio::error_code indicating whether the operation succeeded or failed, and a -<tt>size_t</tt> value <tt>bytes_transferred</tt> specifying the number of bytes -received. - -\until } - -The function <tt>handle_receive()</tt> will service the client request. - -\until { - -The <tt>error</tt> parameter contains the result of the asynchronous operation. -Since we only provide the 1-byte <tt>recv_buffer_</tt> to contain the client's -request, the asio::io_service object would return an error if the client sent -anything larger. We can ignore such an error if it comes up. - -\until { - -Determine what we are going to send. - -\until make_daytime_string() - -We now call asio::ip::udp::socket::async_send_to() to serve the data to the -client. - -\until asio::placeholders::bytes_transferred - -When initiating the asynchronous operation, and if using \ref boost_bind, you -must specify only the arguments that match the handler's parameter list. In -this program, both of the argument placeholders (asio::placeholders::error and -asio::placeholders::bytes_transferred) could potentially have been removed. - -Start listening for the next client request. - -\until start_receive - -Any further actions for this client request are now the responsibility of -<tt>handle_send()</tt>. - -\until } -\until } - -The function <tt>handle_send()</tt> is invoked after the service request has -been completed. - -\until } -\until } - -See the \ref tutdaytime6src "full source listing" \n -Return to the \ref index "tutorial index" \n -Previous: \ref tutdaytime5 \n -Next: \ref tutdaytime7 - -*/ - -/** -\page tutdaytime6src Source listing for Daytime.6 -\include daytime6/server.cpp -Return to \ref tutdaytime6 -*/ - -/** -\page tutdaytime7 Daytime.7 - A combined TCP/UDP asynchronous server - -This tutorial program shows how to combine the two asynchronous servers that we -have just written, into a single server application. - -\section tutdaytime7funcmain The main() function - -\dontinclude daytime7/server.cpp -\skip int main() -\until asio::io_service - -We will begin by creating a server object to accept a TCP client connection. - -\until tcp_server - -We also need a server object to accept a UDP client request. - -\until udp_server - -We have created two lots of work for the asio::io_service object to do. - -\until return 0; -\until } - -\section tutdaytime7classtcp The tcp_connection and tcp_server classes - -The following two classes are taken from \ref tutdaytime3 "Daytime.3". - -\dontinclude daytime7/server.cpp -\skip class tcp_connection -\until }; -\until }; - -\section tutdaytime7classudp The udp_server class - -Similarly, this next class is taken from the -\ref tutdaytime6 "previous tutorial step". - -\dontinclude daytime7/server.cpp -\skip class udp_server -\until }; - -See the \ref tutdaytime7src "full source listing" \n -Return to the \ref index "tutorial index" \n -Previous: \ref tutdaytime6 - -*/ - -/** -\page tutdaytime7src Source listing for Daytime.7 -\include daytime7/server.cpp -Return to \ref tutdaytime7 -*/ diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/index_dox.txt b/3rdparty/asio/src/examples/cpp03/tutorial/index_dox.txt deleted file mode 100644 index 7d3bd1a2912..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/index_dox.txt +++ /dev/null @@ -1,48 +0,0 @@ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -/** -\mainpage asio Tutorial - -\section tuttimer Basic Skills - -The tutorial programs in this first section introduce the fundamental concepts -required to use the asio toolkit. Before plunging into the complex world of -network programming, these tutorial programs illustrate the basic skills using -simple asynchronous timers. - -\li \ref tuttimer1 -\li \ref tuttimer2 -\li \ref tuttimer3 -\li \ref tuttimer4 -\li \ref tuttimer5 - -\section tutdaytime Introduction to Sockets - -The tutorial programs in this section show how to use asio to develop simple -client and server programs. These tutorial programs are based around the <a -href="http://www.ietf.org/rfc/rfc867.txt">daytime</a> protocol, which supports -both TCP and UDP. - -The first three tutorial programs implement the daytime protocol using TCP. - -\li \ref tutdaytime1 -\li \ref tutdaytime2 -\li \ref tutdaytime3 - -The next three tutorial programs implement the daytime protocol using UDP. - -\li \ref tutdaytime4 -\li \ref tutdaytime5 -\li \ref tutdaytime6 - -The last tutorial program in this section demonstrates how asio allows the TCP -and UDP servers to be easily combined into a single program. - -\li \ref tutdaytime7 - -*/ diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/timer1/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/timer1/.gitignore deleted file mode 100644 index 1d47ca67c43..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/timer1/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -timer -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/timer2/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/timer2/.gitignore deleted file mode 100644 index 1d47ca67c43..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/timer2/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -timer -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/timer3/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/timer3/.gitignore deleted file mode 100644 index 1d47ca67c43..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/timer3/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -timer -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/timer4/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/timer4/.gitignore deleted file mode 100644 index 1d47ca67c43..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/timer4/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -timer -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/timer5/.gitignore b/3rdparty/asio/src/examples/cpp03/tutorial/timer5/.gitignore deleted file mode 100644 index 1d47ca67c43..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/timer5/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -timer -.deps -.dirstamp -*.o -*.obj -*.exe -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/timer_dox.txt b/3rdparty/asio/src/examples/cpp03/tutorial/timer_dox.txt deleted file mode 100644 index 7c5a0a099a6..00000000000 --- a/3rdparty/asio/src/examples/cpp03/tutorial/timer_dox.txt +++ /dev/null @@ -1,383 +0,0 @@ -// -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -/** -\page tuttimer1 Timer.1 - Using a timer synchronously - -This tutorial program introduces asio by showing how to perform a blocking -wait on a timer. - -\dontinclude timer1/timer.cpp -\skip #include - -We start by including the necessary header files. - -All of the asio classes can be used by simply including the <tt>"asio.hpp"</tt> -header file. - -\until asio.hpp - -Since this example uses timers, we need to include the appropriate -Boost.Date_Time header file for manipulating times. - -\until posix_time.hpp - -All programs that use asio need to have at least one asio::io_service object. -This class provides access to I/O functionality. We declare an object of this -type first thing in the main function. - -\until asio::io_service - -Next we declare an object of type asio::deadline_timer. The core asio classes -that provide I/O functionality (or as in this case timer functionality) always -take a reference to an io_service as their first constructor argument. The -second argument to the constructor sets the timer to expire 5 seconds from now. - -\until asio::deadline_timer - -In this simple example we perform a blocking wait on the timer. -That is, the call to asio::deadline_timer::wait() will not return until the -timer has expired, 5 seconds after it was created (i.e. <b>not</b> from when the -wait starts). - -A deadline timer is always in one of two states: "expired" or "not expired". If -the asio::deadline_timer::wait() function is called on an expired timer, it -will return immediately. - -\until wait - -Finally we print the obligatory <tt>"Hello, world!"</tt> -message to show when the timer has expired. - -\until } - -See the \ref tuttimer1src "full source listing" \n -Return to the \ref index "tutorial index" \n -Next: \ref tuttimer2 - -*/ - -/** -\page tuttimer1src Source listing for Timer.1 -\include timer1/timer.cpp -Return to \ref tuttimer1 -*/ - -/** -\page tuttimer2 Timer.2 - Using a timer asynchronously - -This tutorial program demonstrates how to use asio's asynchronous callback -functionality by modifying the program from tutorial Timer.1 to perform an -asynchronous wait on the timer. - -\dontinclude timer2/timer.cpp -\skip #include - -\until posix_time.hpp - -Using asio's asynchronous functionality means having a callback -function that will be called when an asynchronous operation completes. In this -program we define a function called <tt>print</tt> to be called when the -asynchronous wait finishes. - -\until asio::deadline_timer - -Next, instead of doing a blocking wait as in tutorial Timer.1, -we call the asio::deadline_timer::async_wait() function to perform an -asynchronous wait. When calling this function we pass the <tt>print</tt> -callback handler that was defined above. - -\skipline async_wait - -Finally, we must call the asio::io_service::run() member function -on the io_service object. - -The asio library provides a guarantee that callback handlers will <b>only</b> -be called from threads that are currently calling asio::io_service::run(). -Therefore unless the asio::io_service::run() function is called the callback for -the asynchronous wait completion will never be invoked. - -The asio::io_service::run() function will also continue to run while there is -still "work" to do. In this example, the work is the asynchronous wait on the -timer, so the call will not return until the timer has expired and the -callback has completed. - -It is important to remember to give the io_service some work to do before -calling asio::io_service::run(). For example, if we had omitted the above call -to asio::deadline_timer::async_wait(), the io_service would not have had any -work to do, and consequently asio::io_service::run() would have returned -immediately. - -\skip run -\until } - -See the \ref tuttimer2src "full source listing" \n -Return to the \ref index "tutorial index" \n -Previous: \ref tuttimer1 \n -Next: \ref tuttimer3 - -*/ - -/** -\page tuttimer2src Source listing for Timer.2 -\include timer2/timer.cpp -Return to \ref tuttimer2 -*/ - -/** -\page tuttimer3 Timer.3 - Binding arguments to a handler - -In this tutorial we will modify the program from tutorial Timer.2 so that the -timer fires once a second. This will show how to pass additional parameters to -your handler function. - -\dontinclude timer3/timer.cpp -\skip #include - -\until posix_time.hpp - -To implement a repeating timer using asio you need to change -the timer's expiry time in your callback function, and to then start a new -asynchronous wait. Obviously this means that the callback function will need -to be able to access the timer object. To this end we add two new parameters -to the <tt>print</tt> function: - -\li A pointer to a timer object. - -\li A counter so that we can stop the program when the timer fires for the -sixth time. - -\until { - -As mentioned above, this tutorial program uses a counter to -stop running when the timer fires for the sixth time. However you will observe -that there is no explicit call to ask the io_service to stop. Recall that in -tutorial Timer.2 we learnt that the asio::io_service::run() function completes -when there is no more "work" to do. By not starting a new asynchronous wait on -the timer when <tt>count</tt> reaches 5, the io_service will run out of work and -stop running. - -\until ++ - -Next we move the expiry time for the timer along by one second -from the previous expiry time. By calculating the new expiry time relative to -the old, we can ensure that the timer does not drift away from the -whole-second mark due to any delays in processing the handler. - -\until expires_at - -Then we start a new asynchronous wait on the timer. As you can -see, the \ref boost_bind function is used to associate the extra parameters -with your callback handler. The asio::deadline_timer::async_wait() function -expects a handler function (or function object) with the signature -<tt>void(const asio::error_code&)</tt>. Binding the additional parameters -converts your <tt>print</tt> function into a function object that matches the -signature correctly. - -See the <a href="http://www.boost.org/libs/bind/bind.html">Boost.Bind -documentation</a> for more information on how to use \ref boost_bind. - -In this example, the asio::placeholders::error argument to \ref boost_bind is a -named placeholder for the error object passed to the handler. When initiating -the asynchronous operation, and if using \ref boost_bind, you must specify only -the arguments that match the handler's parameter list. In tutorial Timer.4 you -will see that this placeholder may be elided if the parameter is not needed by -the callback handler. - -\until asio::io_service - -A new <tt>count</tt> variable is added so that we can stop the -program when the timer fires for the sixth time. - -\until asio::deadline_timer - -As in Step 4, when making the call to -asio::deadline_timer::async_wait() from <tt>main</tt> we bind the additional -parameters needed for the <tt>print</tt> function. - -\until run - -Finally, just to prove that the <tt>count</tt> variable was -being used in the <tt>print</tt> handler function, we will print out its new -value. - -\until } - -See the \ref tuttimer3src "full source listing" \n -Return to the \ref index "tutorial index" \n -Previous: \ref tuttimer2 \n -Next: \ref tuttimer4 - -*/ - -/** -\page tuttimer3src Source listing for Timer.3 -\include timer3/timer.cpp -Return to \ref tuttimer3 -*/ - -/** -\page tuttimer4 Timer.4 - Using a member function as a handler - -In this tutorial we will see how to use a class member function as a callback -handler. The program should execute identically to the tutorial program from -tutorial Timer.3. - -\dontinclude timer4/timer.cpp -\skip #include - -\until posix_time.hpp - -Instead of defining a free function <tt>print</tt> as the -callback handler, as we did in the earlier tutorial programs, we now define a -class called <tt>printer</tt>. - -\until public - -The constructor of this class will take a reference to the -io_service object and use it when initialising the <tt>timer_</tt> member. The -counter used to shut down the program is now also a member of the class. - -\until { - -The \ref boost_bind function works just as well with class -member functions as with free functions. Since all non-static class member -functions have an implicit <tt>this</tt> parameter, we need to bind -<tt>this</tt> to the function. As in tutorial Timer.3, \ref boost_bind -converts our callback handler (now a member function) into a function object -that can be invoked as though it has the signature <tt>void(const -asio::error_code&)</tt>. - -You will note that the asio::placeholders::error placeholder is not specified -here, as the <tt>print</tt> member function does not accept an error object as -a parameter. - -\until } - -In the class destructor we will print out the final value of -the counter. - -\until } - -The <tt>print</tt> member function is very similar to the -<tt>print</tt> function from tutorial Timer.3, except that it now operates on -the class data members instead of having the timer and counter passed in as -parameters. - -\until }; - -The <tt>main</tt> function is much simpler than before, as it -now declares a local <tt>printer</tt> object before running the io_service as -normal. - -\until } - -See the \ref tuttimer4src "full source listing" \n -Return to the \ref index "tutorial index" \n -Previous: \ref tuttimer3 \n -Next: \ref tuttimer5 \n - -*/ - -/** -\page tuttimer4src Source listing for Timer.4 -\include timer4/timer.cpp -Return to \ref tuttimer4 -*/ - -/** -\page tuttimer5 Timer.5 - Synchronising handlers in multithreaded programs - -This tutorial demonstrates the use of the asio::io_service::strand class to -synchronise callback handlers in a multithreaded program. - -The previous four tutorials avoided the issue of handler synchronisation by -calling the asio::io_service::run() function from one thread only. As you -already know, the asio library provides a guarantee that callback handlers will -<b>only</b> be called from threads that are currently calling -asio::io_service::run(). Consequently, calling asio::io_service::run() from -only one thread ensures that callback handlers cannot run concurrently. - -The single threaded approach is usually the best place to start when -developing applications using asio. The downside is the limitations it places -on programs, particularly servers, including: - -<ul> -<li>Poor responsiveness when handlers can take a long time to complete.</li> -<li>An inability to scale on multiprocessor systems.</li> -</ul> - -If you find yourself running into these limitations, an alternative approach -is to have a pool of threads calling asio::io_service::run(). However, as this -allows handlers to execute concurrently, we need a method of synchronisation -when handlers might be accessing a shared, thread-unsafe resource. - -\dontinclude timer5/timer.cpp -\skip #include - -\until posix_time.hpp - -We start by defining a class called <tt>printer</tt>, similar -to the class in the previous tutorial. This class will extend the previous -tutorial by running two timers in parallel. - -\until public - -In addition to initialising a pair of asio::deadline_timer members, the -constructor initialises the <tt>strand_</tt> member, an object of type -asio::io_service::strand. - -An asio::io_service::strand is an executor that guarantees that, for those -handlers that are dispatched through it, an executing handler will be allowed -to complete before the next one is started. This is guaranteed irrespective of -the number of threads that are calling asio::io_service::run(). Of course, the -handlers may still execute concurrently with other handlers that were -<b>not</b> dispatched through an asio::io_service::strand, or were dispatched -through a different asio::io_service::strand object. - -\until { - -When initiating the asynchronous operations, each callback handler is "bound" -to an asio::io_service::strand object. The -asio::io_service::strand::bind_executor() function returns a new handler that -automatically dispatches its contained handler through the -asio::io_service::strand object. By binding the handlers to the same -asio::io_service::strand, we are ensuring that they cannot execute -concurrently. - -\until } -\until } - -In a multithreaded program, the handlers for asynchronous -operations should be synchronised if they access shared resources. In this -tutorial, the shared resources used by the handlers (<tt>print1</tt> and -<tt>print2</tt>) are <tt>std::cout</tt> and the <tt>count_</tt> data member. - -\until }; - -The <tt>main</tt> function now causes asio::io_service::run() to -be called from two threads: the main thread and one additional thread. This is -accomplished using an asio::thread object. - -Just as it would with a call from a single thread, concurrent calls to -asio::io_service::run() will continue to execute while there is "work" left to -do. The background thread will not exit until all asynchronous operations have -completed. - -\until } - -See the \ref tuttimer5src "full source listing" \n -Return to the \ref index "tutorial index" \n -Previous: \ref tuttimer4 \n - -*/ - -/** -\page tuttimer5src Source listing for Timer.5 -\include timer5/timer.cpp -Return to \ref tuttimer5 -*/ diff --git a/3rdparty/asio/src/examples/cpp03/windows/.gitignore b/3rdparty/asio/src/examples/cpp03/windows/.gitignore deleted file mode 100644 index 180ba886e58..00000000000 --- a/3rdparty/asio/src/examples/cpp03/windows/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -server -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp11/Makefile.am b/3rdparty/asio/src/examples/cpp11/Makefile.am index 182c711229f..a132a469ff5 100644 --- a/3rdparty/asio/src/examples/cpp11/Makefile.am +++ b/3rdparty/asio/src/examples/cpp11/Makefile.am @@ -14,6 +14,8 @@ noinst_PROGRAMS = \ buffers/reference_counted \ chat/chat_client \ chat/chat_server \ + deferred/deferred_1 \ + deferred/deferred_2 \ echo/async_tcp_echo_server \ echo/async_udp_echo_server \ echo/blocking_tcp_echo_client \ @@ -26,9 +28,84 @@ noinst_PROGRAMS = \ executors/fork_join \ executors/pipeline \ executors/priority_scheduler \ + files/blocking_file_copy \ + files/async_file_copy \ futures/daytime_client \ + handler_tracking/async_tcp_echo_server \ + http/client/async_client \ + http/client/sync_client \ http/server/http_server \ - iostreams/http_client + http/server2/http_server \ + http/server3/http_server \ + http/server4/http_server \ + icmp/ping \ + invocation/prioritised_handlers \ + iostreams/daytime_client \ + iostreams/daytime_server \ + iostreams/http_client \ + multicast/receiver \ + multicast/sender \ + nonblocking/third_party_lib \ + operations/composed_1 \ + operations/composed_2 \ + operations/composed_3 \ + operations/composed_4 \ + operations/composed_5 \ + operations/composed_6 \ + operations/composed_7 \ + operations/composed_8 \ + parallel_group/ranged_wait_for_all \ + parallel_group/wait_for_all \ + parallel_group/wait_for_one \ + parallel_group/wait_for_one_error \ + parallel_group/wait_for_one_success \ + porthopper/client \ + porthopper/server \ + services/daytime_client \ + socks4/sync_client \ + timeouts/async_tcp_client \ + timeouts/blocking_tcp_client \ + timeouts/blocking_token_tcp_client \ + timeouts/blocking_udp_client \ + timeouts/server \ + timers/time_t_timer \ + tutorial/timer1/timer \ + tutorial/timer2/timer \ + tutorial/timer3/timer \ + tutorial/timer4/timer \ + tutorial/timer5/timer \ + tutorial/daytime1/client \ + tutorial/daytime2/server \ + tutorial/daytime3/server \ + tutorial/daytime4/client \ + tutorial/daytime5/server \ + tutorial/daytime6/server \ + tutorial/daytime7/server \ + type_erasure/type_erasure + +if !WINDOWS_TARGET +noinst_PROGRAMS += \ + chat/posix_chat_client \ + fork/daemon \ + fork/process_per_connection \ + local/connect_pair \ + local/iostream_client \ + local/stream_server \ + local/stream_client \ + local/fd_passing_stream_server \ + local/fd_passing_stream_client +endif + +if WINDOWS_TARGET +noinst_PROGRAMS += \ + windows/transmit_file +endif + +if HAVE_OPENSSL +noinst_PROGRAMS += \ + ssl/client \ + ssl/server +endif if HAVE_BOOST_COROUTINE noinst_PROGRAMS += \ @@ -37,7 +114,51 @@ noinst_PROGRAMS += \ endif noinst_HEADERS = \ - chat/chat_message.hpp + chat/chat_message.hpp \ + handler_tracking/custom_tracking.hpp \ + http/server/connection.hpp \ + http/server/connection_manager.hpp \ + http/server/header.hpp \ + http/server/mime_types.hpp \ + http/server/reply.hpp \ + http/server/request.hpp \ + http/server/request_handler.hpp \ + http/server/request_parser.hpp \ + http/server/server.hpp \ + http/server2/connection.hpp \ + http/server2/io_context_pool.hpp \ + http/server2/header.hpp \ + http/server2/mime_types.hpp \ + http/server2/reply.hpp \ + http/server2/request.hpp \ + http/server2/request_handler.hpp \ + http/server2/request_parser.hpp \ + http/server2/server.hpp \ + http/server3/connection.hpp \ + http/server3/header.hpp \ + http/server3/mime_types.hpp \ + http/server3/reply.hpp \ + http/server3/request.hpp \ + http/server3/request_handler.hpp \ + http/server3/request_parser.hpp \ + http/server3/server.hpp \ + http/server4/file_handler.hpp \ + http/server4/header.hpp \ + http/server4/mime_types.hpp \ + http/server4/reply.hpp \ + http/server4/request.hpp \ + http/server4/request_parser.hpp \ + http/server4/server.hpp \ + icmp/icmp_header.hpp \ + icmp/ipv4_header.hpp \ + porthopper/protocol.hpp \ + services/basic_logger.hpp \ + services/logger.hpp \ + services/logger_service.hpp \ + socks4/socks4.hpp \ + type_erasure/line_reader.hpp \ + type_erasure/stdin_line_reader.hpp \ + type_erasure/sleep.hpp AM_CXXFLAGS = -I$(srcdir)/../../../include @@ -45,6 +166,8 @@ allocation_server_SOURCES = allocation/server.cpp buffers_reference_counted_SOURCES = buffers/reference_counted.cpp chat_chat_client_SOURCES = chat/chat_client.cpp chat_chat_server_SOURCES = chat/chat_server.cpp +deferred_deferred_1_SOURCES = deferred/deferred_1.cpp +deferred_deferred_2_SOURCES = deferred/deferred_2.cpp echo_async_tcp_echo_server_SOURCES = echo/async_tcp_echo_server.cpp echo_async_udp_echo_server_SOURCES = echo/async_udp_echo_server.cpp echo_blocking_tcp_echo_client_SOURCES = echo/blocking_tcp_echo_client.cpp @@ -57,7 +180,12 @@ executors_bank_account_2_SOURCES = executors/bank_account_2.cpp executors_fork_join_SOURCES = executors/fork_join.cpp executors_pipeline_SOURCES = executors/pipeline.cpp executors_priority_scheduler_SOURCES = executors/priority_scheduler.cpp +files_blocking_file_copy_SOURCES = files/blocking_file_copy.cpp +files_async_file_copy_SOURCES = files/async_file_copy.cpp futures_daytime_client_SOURCES = futures/daytime_client.cpp +handler_tracking_async_tcp_echo_server_SOURCES = handler_tracking/async_tcp_echo_server.cpp +http_client_async_client_SOURCES = http/client/async_client.cpp +http_client_sync_client_SOURCES = http/client/sync_client.cpp http_server_http_server_SOURCES = \ http/server/connection.cpp \ http/server/connection_manager.cpp \ @@ -67,7 +195,97 @@ http_server_http_server_SOURCES = \ http/server/request_handler.cpp \ http/server/request_parser.cpp \ http/server/server.cpp +http_server2_http_server_SOURCES = \ + http/server2/connection.cpp \ + http/server2/io_context_pool.cpp \ + http/server2/main.cpp \ + http/server2/mime_types.cpp \ + http/server2/reply.cpp \ + http/server2/request_handler.cpp \ + http/server2/request_parser.cpp \ + http/server2/server.cpp +http_server3_http_server_SOURCES = \ + http/server3/connection.cpp \ + http/server3/main.cpp \ + http/server3/mime_types.cpp \ + http/server3/reply.cpp \ + http/server3/request_handler.cpp \ + http/server3/request_parser.cpp \ + http/server3/server.cpp +http_server4_http_server_SOURCES = \ + http/server4/file_handler.cpp \ + http/server4/main.cpp \ + http/server4/mime_types.cpp \ + http/server4/reply.cpp \ + http/server4/request_parser.cpp \ + http/server4/server.cpp +icmp_ping_SOURCES = icmp/ping.cpp +invocation_prioritised_handlers_SOURCES = invocation/prioritised_handlers.cpp +iostreams_daytime_client_SOURCES = iostreams/daytime_client.cpp +iostreams_daytime_server_SOURCES = iostreams/daytime_server.cpp iostreams_http_client_SOURCES = iostreams/http_client.cpp +multicast_receiver_SOURCES = multicast/receiver.cpp +multicast_sender_SOURCES = multicast/sender.cpp +nonblocking_third_party_lib_SOURCES = nonblocking/third_party_lib.cpp +operations_composed_1_SOURCES = operations/composed_1.cpp +operations_composed_2_SOURCES = operations/composed_2.cpp +operations_composed_3_SOURCES = operations/composed_3.cpp +operations_composed_4_SOURCES = operations/composed_4.cpp +operations_composed_5_SOURCES = operations/composed_5.cpp +operations_composed_6_SOURCES = operations/composed_6.cpp +operations_composed_7_SOURCES = operations/composed_7.cpp +operations_composed_8_SOURCES = operations/composed_8.cpp +parallel_group_ranged_wait_for_all_SOURCES = parallel_group/ranged_wait_for_all.cpp +parallel_group_wait_for_all_SOURCES = parallel_group/wait_for_all.cpp +parallel_group_wait_for_one_SOURCES = parallel_group/wait_for_one.cpp +parallel_group_wait_for_one_error_SOURCES = parallel_group/wait_for_one_error.cpp +parallel_group_wait_for_one_success_SOURCES = parallel_group/wait_for_one_success.cpp +porthopper_client_SOURCES = porthopper/client.cpp +porthopper_server_SOURCES = porthopper/server.cpp +services_daytime_client_SOURCES = \ + services/daytime_client.cpp \ + services/logger_service.cpp +socks4_sync_client_SOURCES = socks4/sync_client.cpp +timeouts_async_tcp_client_SOURCES = timeouts/async_tcp_client.cpp +timeouts_blocking_tcp_client_SOURCES = timeouts/blocking_tcp_client.cpp +timeouts_blocking_token_tcp_client_SOURCES = timeouts/blocking_token_tcp_client.cpp +timeouts_blocking_udp_client_SOURCES = timeouts/blocking_udp_client.cpp +timeouts_server_SOURCES = timeouts/server.cpp +timers_time_t_timer_SOURCES = timers/time_t_timer.cpp +tutorial_timer1_timer_SOURCES = tutorial/timer1/timer.cpp +tutorial_timer2_timer_SOURCES = tutorial/timer2/timer.cpp +tutorial_timer3_timer_SOURCES = tutorial/timer3/timer.cpp +tutorial_timer4_timer_SOURCES = tutorial/timer4/timer.cpp +tutorial_timer5_timer_SOURCES = tutorial/timer5/timer.cpp +tutorial_daytime1_client_SOURCES = tutorial/daytime1/client.cpp +tutorial_daytime2_server_SOURCES = tutorial/daytime2/server.cpp +tutorial_daytime3_server_SOURCES = tutorial/daytime3/server.cpp +tutorial_daytime4_client_SOURCES = tutorial/daytime4/client.cpp +tutorial_daytime5_server_SOURCES = tutorial/daytime5/server.cpp +tutorial_daytime6_server_SOURCES = tutorial/daytime6/server.cpp +tutorial_daytime7_server_SOURCES = tutorial/daytime7/server.cpp +type_erasure_type_erasure_SOURCES = type_erasure/main.cpp type_erasure/stdin_line_reader.cpp type_erasure/sleep.cpp + +if !WINDOWS_TARGET +chat_posix_chat_client_SOURCES = chat/posix_chat_client.cpp +fork_daemon_SOURCES = fork/daemon.cpp +fork_process_per_connection_SOURCES = fork/process_per_connection.cpp +local_connect_pair_SOURCES = local/connect_pair.cpp +local_iostream_client_SOURCES = local/iostream_client.cpp +local_stream_server_SOURCES = local/stream_server.cpp +local_stream_client_SOURCES = local/stream_client.cpp +local_fd_passing_stream_server_SOURCES = local/fd_passing_stream_server.cpp +local_fd_passing_stream_client_SOURCES = local/fd_passing_stream_client.cpp +endif + +if WINDOWS_TARGET +windows_transmit_file_SOURCES = windows/transmit_file.cpp +endif + +if HAVE_OPENSSL +ssl_client_SOURCES = ssl/client.cpp +ssl_server_SOURCES = ssl/server.cpp +endif if HAVE_BOOST_COROUTINE spawn_echo_server_SOURCES = spawn/echo_server.cpp @@ -77,16 +295,14 @@ spawn_parallel_grep_LDADD = $(LDADD) -lboost_coroutine -lboost_context -lboost_t endif EXTRA_DIST = \ - handler_tracking/custom_tracking.hpp \ - http/server/connection.hpp \ - http/server/connection_manager.hpp \ - http/server/header.hpp \ - http/server/mime_types.hpp \ - http/server/reply.hpp \ - http/server/request.hpp \ - http/server/request_handler.hpp \ - http/server/request_parser.hpp \ - http/server/server.hpp + serialization/client.cpp \ + serialization/server.cpp \ + serialization/connection.hpp \ + serialization/stock.hpp \ + ssl/README \ + ssl/ca.pem \ + ssl/server.pem \ + ssl/dh4096.pem MAINTAINERCLEANFILES = \ $(srcdir)/Makefile.in diff --git a/3rdparty/asio/src/examples/cpp11/Makefile.in b/3rdparty/asio/src/examples/cpp11/Makefile.in new file mode 100644 index 00000000000..0f73bb5b85a --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/Makefile.in @@ -0,0 +1,2975 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@HAVE_OPENSSL_TRUE@@SEPARATE_COMPILATION_TRUE@am__append_1 = ../../asio_ssl.cpp +noinst_PROGRAMS = allocation/server$(EXEEXT) \ + buffers/reference_counted$(EXEEXT) chat/chat_client$(EXEEXT) \ + chat/chat_server$(EXEEXT) deferred/deferred_1$(EXEEXT) \ + deferred/deferred_2$(EXEEXT) \ + echo/async_tcp_echo_server$(EXEEXT) \ + echo/async_udp_echo_server$(EXEEXT) \ + echo/blocking_tcp_echo_client$(EXEEXT) \ + echo/blocking_tcp_echo_server$(EXEEXT) \ + echo/blocking_udp_echo_client$(EXEEXT) \ + echo/blocking_udp_echo_server$(EXEEXT) \ + executors/actor$(EXEEXT) executors/bank_account_1$(EXEEXT) \ + executors/bank_account_2$(EXEEXT) executors/fork_join$(EXEEXT) \ + executors/pipeline$(EXEEXT) \ + executors/priority_scheduler$(EXEEXT) \ + files/blocking_file_copy$(EXEEXT) \ + files/async_file_copy$(EXEEXT) futures/daytime_client$(EXEEXT) \ + handler_tracking/async_tcp_echo_server$(EXEEXT) \ + http/client/async_client$(EXEEXT) \ + http/client/sync_client$(EXEEXT) \ + http/server/http_server$(EXEEXT) \ + http/server2/http_server$(EXEEXT) \ + http/server3/http_server$(EXEEXT) \ + http/server4/http_server$(EXEEXT) icmp/ping$(EXEEXT) \ + invocation/prioritised_handlers$(EXEEXT) \ + iostreams/daytime_client$(EXEEXT) \ + iostreams/daytime_server$(EXEEXT) \ + iostreams/http_client$(EXEEXT) multicast/receiver$(EXEEXT) \ + multicast/sender$(EXEEXT) nonblocking/third_party_lib$(EXEEXT) \ + operations/composed_1$(EXEEXT) operations/composed_2$(EXEEXT) \ + operations/composed_3$(EXEEXT) operations/composed_4$(EXEEXT) \ + operations/composed_5$(EXEEXT) operations/composed_6$(EXEEXT) \ + operations/composed_7$(EXEEXT) operations/composed_8$(EXEEXT) \ + parallel_group/ranged_wait_for_all$(EXEEXT) \ + parallel_group/wait_for_all$(EXEEXT) \ + parallel_group/wait_for_one$(EXEEXT) \ + parallel_group/wait_for_one_error$(EXEEXT) \ + parallel_group/wait_for_one_success$(EXEEXT) \ + porthopper/client$(EXEEXT) porthopper/server$(EXEEXT) \ + services/daytime_client$(EXEEXT) socks4/sync_client$(EXEEXT) \ + timeouts/async_tcp_client$(EXEEXT) \ + timeouts/blocking_tcp_client$(EXEEXT) \ + timeouts/blocking_token_tcp_client$(EXEEXT) \ + timeouts/blocking_udp_client$(EXEEXT) timeouts/server$(EXEEXT) \ + timers/time_t_timer$(EXEEXT) tutorial/timer1/timer$(EXEEXT) \ + tutorial/timer2/timer$(EXEEXT) tutorial/timer3/timer$(EXEEXT) \ + tutorial/timer4/timer$(EXEEXT) tutorial/timer5/timer$(EXEEXT) \ + tutorial/daytime1/client$(EXEEXT) \ + tutorial/daytime2/server$(EXEEXT) \ + tutorial/daytime3/server$(EXEEXT) \ + tutorial/daytime4/client$(EXEEXT) \ + tutorial/daytime5/server$(EXEEXT) \ + tutorial/daytime6/server$(EXEEXT) \ + tutorial/daytime7/server$(EXEEXT) \ + type_erasure/type_erasure$(EXEEXT) $(am__EXEEXT_1) \ + $(am__EXEEXT_2) $(am__EXEEXT_3) $(am__EXEEXT_4) +@WINDOWS_TARGET_FALSE@am__append_2 = \ +@WINDOWS_TARGET_FALSE@ chat/posix_chat_client \ +@WINDOWS_TARGET_FALSE@ fork/daemon \ +@WINDOWS_TARGET_FALSE@ fork/process_per_connection \ +@WINDOWS_TARGET_FALSE@ local/connect_pair \ +@WINDOWS_TARGET_FALSE@ local/iostream_client \ +@WINDOWS_TARGET_FALSE@ local/stream_server \ +@WINDOWS_TARGET_FALSE@ local/stream_client \ +@WINDOWS_TARGET_FALSE@ local/fd_passing_stream_server \ +@WINDOWS_TARGET_FALSE@ local/fd_passing_stream_client + +@WINDOWS_TARGET_TRUE@am__append_3 = \ +@WINDOWS_TARGET_TRUE@ windows/transmit_file + +@HAVE_OPENSSL_TRUE@am__append_4 = \ +@HAVE_OPENSSL_TRUE@ ssl/client \ +@HAVE_OPENSSL_TRUE@ ssl/server + +@HAVE_BOOST_COROUTINE_TRUE@am__append_5 = \ +@HAVE_BOOST_COROUTINE_TRUE@ spawn/echo_server \ +@HAVE_BOOST_COROUTINE_TRUE@ spawn/parallel_grep + +subdir = src/examples/cpp11 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ + $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +@WINDOWS_TARGET_FALSE@am__EXEEXT_1 = chat/posix_chat_client$(EXEEXT) \ +@WINDOWS_TARGET_FALSE@ fork/daemon$(EXEEXT) \ +@WINDOWS_TARGET_FALSE@ fork/process_per_connection$(EXEEXT) \ +@WINDOWS_TARGET_FALSE@ local/connect_pair$(EXEEXT) \ +@WINDOWS_TARGET_FALSE@ local/iostream_client$(EXEEXT) \ +@WINDOWS_TARGET_FALSE@ local/stream_server$(EXEEXT) \ +@WINDOWS_TARGET_FALSE@ local/stream_client$(EXEEXT) \ +@WINDOWS_TARGET_FALSE@ local/fd_passing_stream_server$(EXEEXT) \ +@WINDOWS_TARGET_FALSE@ local/fd_passing_stream_client$(EXEEXT) +@WINDOWS_TARGET_TRUE@am__EXEEXT_2 = windows/transmit_file$(EXEEXT) +@HAVE_OPENSSL_TRUE@am__EXEEXT_3 = ssl/client$(EXEEXT) \ +@HAVE_OPENSSL_TRUE@ ssl/server$(EXEEXT) +@HAVE_BOOST_COROUTINE_TRUE@am__EXEEXT_4 = spawn/echo_server$(EXEEXT) \ +@HAVE_BOOST_COROUTINE_TRUE@ spawn/parallel_grep$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +AM_V_AR = $(am__v_AR_@AM_V@) +am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) +am__v_AR_0 = @echo " AR " $@; +am__v_AR_1 = +libasio_a_AR = $(AR) $(ARFLAGS) +libasio_a_LIBADD = +am__libasio_a_SOURCES_DIST = ../../asio.cpp ../../asio_ssl.cpp +am__dirstamp = $(am__leading_dot)dirstamp +@HAVE_OPENSSL_TRUE@@SEPARATE_COMPILATION_TRUE@am__objects_1 = ../../asio_ssl.$(OBJEXT) +@SEPARATE_COMPILATION_TRUE@am_libasio_a_OBJECTS = \ +@SEPARATE_COMPILATION_TRUE@ ../../asio.$(OBJEXT) \ +@SEPARATE_COMPILATION_TRUE@ $(am__objects_1) +libasio_a_OBJECTS = $(am_libasio_a_OBJECTS) +am_allocation_server_OBJECTS = allocation/server.$(OBJEXT) +allocation_server_OBJECTS = $(am_allocation_server_OBJECTS) +allocation_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@allocation_server_DEPENDENCIES = libasio.a +am_buffers_reference_counted_OBJECTS = \ + buffers/reference_counted.$(OBJEXT) +buffers_reference_counted_OBJECTS = \ + $(am_buffers_reference_counted_OBJECTS) +buffers_reference_counted_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@buffers_reference_counted_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_chat_chat_client_OBJECTS = chat/chat_client.$(OBJEXT) +chat_chat_client_OBJECTS = $(am_chat_chat_client_OBJECTS) +chat_chat_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@chat_chat_client_DEPENDENCIES = libasio.a +am_chat_chat_server_OBJECTS = chat/chat_server.$(OBJEXT) +chat_chat_server_OBJECTS = $(am_chat_chat_server_OBJECTS) +chat_chat_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@chat_chat_server_DEPENDENCIES = libasio.a +am__chat_posix_chat_client_SOURCES_DIST = chat/posix_chat_client.cpp +@WINDOWS_TARGET_FALSE@am_chat_posix_chat_client_OBJECTS = \ +@WINDOWS_TARGET_FALSE@ chat/posix_chat_client.$(OBJEXT) +chat_posix_chat_client_OBJECTS = $(am_chat_posix_chat_client_OBJECTS) +chat_posix_chat_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@chat_posix_chat_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_deferred_deferred_1_OBJECTS = deferred/deferred_1.$(OBJEXT) +deferred_deferred_1_OBJECTS = $(am_deferred_deferred_1_OBJECTS) +deferred_deferred_1_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@deferred_deferred_1_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_deferred_deferred_2_OBJECTS = deferred/deferred_2.$(OBJEXT) +deferred_deferred_2_OBJECTS = $(am_deferred_deferred_2_OBJECTS) +deferred_deferred_2_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@deferred_deferred_2_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_async_tcp_echo_server_OBJECTS = \ + echo/async_tcp_echo_server.$(OBJEXT) +echo_async_tcp_echo_server_OBJECTS = \ + $(am_echo_async_tcp_echo_server_OBJECTS) +echo_async_tcp_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_async_tcp_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_async_udp_echo_server_OBJECTS = \ + echo/async_udp_echo_server.$(OBJEXT) +echo_async_udp_echo_server_OBJECTS = \ + $(am_echo_async_udp_echo_server_OBJECTS) +echo_async_udp_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_async_udp_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_blocking_tcp_echo_client_OBJECTS = \ + echo/blocking_tcp_echo_client.$(OBJEXT) +echo_blocking_tcp_echo_client_OBJECTS = \ + $(am_echo_blocking_tcp_echo_client_OBJECTS) +echo_blocking_tcp_echo_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_blocking_tcp_echo_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_blocking_tcp_echo_server_OBJECTS = \ + echo/blocking_tcp_echo_server.$(OBJEXT) +echo_blocking_tcp_echo_server_OBJECTS = \ + $(am_echo_blocking_tcp_echo_server_OBJECTS) +echo_blocking_tcp_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_blocking_tcp_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_blocking_udp_echo_client_OBJECTS = \ + echo/blocking_udp_echo_client.$(OBJEXT) +echo_blocking_udp_echo_client_OBJECTS = \ + $(am_echo_blocking_udp_echo_client_OBJECTS) +echo_blocking_udp_echo_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_blocking_udp_echo_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_blocking_udp_echo_server_OBJECTS = \ + echo/blocking_udp_echo_server.$(OBJEXT) +echo_blocking_udp_echo_server_OBJECTS = \ + $(am_echo_blocking_udp_echo_server_OBJECTS) +echo_blocking_udp_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_blocking_udp_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_executors_actor_OBJECTS = executors/actor.$(OBJEXT) +executors_actor_OBJECTS = $(am_executors_actor_OBJECTS) +executors_actor_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_actor_DEPENDENCIES = libasio.a +am_executors_bank_account_1_OBJECTS = \ + executors/bank_account_1.$(OBJEXT) +executors_bank_account_1_OBJECTS = \ + $(am_executors_bank_account_1_OBJECTS) +executors_bank_account_1_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_bank_account_1_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_executors_bank_account_2_OBJECTS = \ + executors/bank_account_2.$(OBJEXT) +executors_bank_account_2_OBJECTS = \ + $(am_executors_bank_account_2_OBJECTS) +executors_bank_account_2_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_bank_account_2_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_executors_fork_join_OBJECTS = executors/fork_join.$(OBJEXT) +executors_fork_join_OBJECTS = $(am_executors_fork_join_OBJECTS) +executors_fork_join_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_fork_join_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_executors_pipeline_OBJECTS = executors/pipeline.$(OBJEXT) +executors_pipeline_OBJECTS = $(am_executors_pipeline_OBJECTS) +executors_pipeline_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_pipeline_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_executors_priority_scheduler_OBJECTS = \ + executors/priority_scheduler.$(OBJEXT) +executors_priority_scheduler_OBJECTS = \ + $(am_executors_priority_scheduler_OBJECTS) +executors_priority_scheduler_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_priority_scheduler_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_files_async_file_copy_OBJECTS = files/async_file_copy.$(OBJEXT) +files_async_file_copy_OBJECTS = $(am_files_async_file_copy_OBJECTS) +files_async_file_copy_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@files_async_file_copy_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_files_blocking_file_copy_OBJECTS = \ + files/blocking_file_copy.$(OBJEXT) +files_blocking_file_copy_OBJECTS = \ + $(am_files_blocking_file_copy_OBJECTS) +files_blocking_file_copy_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@files_blocking_file_copy_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__fork_daemon_SOURCES_DIST = fork/daemon.cpp +@WINDOWS_TARGET_FALSE@am_fork_daemon_OBJECTS = fork/daemon.$(OBJEXT) +fork_daemon_OBJECTS = $(am_fork_daemon_OBJECTS) +fork_daemon_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@fork_daemon_DEPENDENCIES = libasio.a +am__fork_process_per_connection_SOURCES_DIST = \ + fork/process_per_connection.cpp +@WINDOWS_TARGET_FALSE@am_fork_process_per_connection_OBJECTS = \ +@WINDOWS_TARGET_FALSE@ fork/process_per_connection.$(OBJEXT) +fork_process_per_connection_OBJECTS = \ + $(am_fork_process_per_connection_OBJECTS) +fork_process_per_connection_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@fork_process_per_connection_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_futures_daytime_client_OBJECTS = futures/daytime_client.$(OBJEXT) +futures_daytime_client_OBJECTS = $(am_futures_daytime_client_OBJECTS) +futures_daytime_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@futures_daytime_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_handler_tracking_async_tcp_echo_server_OBJECTS = \ + handler_tracking/async_tcp_echo_server.$(OBJEXT) +handler_tracking_async_tcp_echo_server_OBJECTS = \ + $(am_handler_tracking_async_tcp_echo_server_OBJECTS) +handler_tracking_async_tcp_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@handler_tracking_async_tcp_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_http_client_async_client_OBJECTS = \ + http/client/async_client.$(OBJEXT) +http_client_async_client_OBJECTS = \ + $(am_http_client_async_client_OBJECTS) +http_client_async_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@http_client_async_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_http_client_sync_client_OBJECTS = \ + http/client/sync_client.$(OBJEXT) +http_client_sync_client_OBJECTS = \ + $(am_http_client_sync_client_OBJECTS) +http_client_sync_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@http_client_sync_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_http_server_http_server_OBJECTS = http/server/connection.$(OBJEXT) \ + http/server/connection_manager.$(OBJEXT) \ + http/server/main.$(OBJEXT) http/server/mime_types.$(OBJEXT) \ + http/server/reply.$(OBJEXT) \ + http/server/request_handler.$(OBJEXT) \ + http/server/request_parser.$(OBJEXT) \ + http/server/server.$(OBJEXT) +http_server_http_server_OBJECTS = \ + $(am_http_server_http_server_OBJECTS) +http_server_http_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@http_server_http_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_http_server2_http_server_OBJECTS = \ + http/server2/connection.$(OBJEXT) \ + http/server2/io_context_pool.$(OBJEXT) \ + http/server2/main.$(OBJEXT) http/server2/mime_types.$(OBJEXT) \ + http/server2/reply.$(OBJEXT) \ + http/server2/request_handler.$(OBJEXT) \ + http/server2/request_parser.$(OBJEXT) \ + http/server2/server.$(OBJEXT) +http_server2_http_server_OBJECTS = \ + $(am_http_server2_http_server_OBJECTS) +http_server2_http_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@http_server2_http_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_http_server3_http_server_OBJECTS = \ + http/server3/connection.$(OBJEXT) http/server3/main.$(OBJEXT) \ + http/server3/mime_types.$(OBJEXT) http/server3/reply.$(OBJEXT) \ + http/server3/request_handler.$(OBJEXT) \ + http/server3/request_parser.$(OBJEXT) \ + http/server3/server.$(OBJEXT) +http_server3_http_server_OBJECTS = \ + $(am_http_server3_http_server_OBJECTS) +http_server3_http_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@http_server3_http_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_http_server4_http_server_OBJECTS = \ + http/server4/file_handler.$(OBJEXT) \ + http/server4/main.$(OBJEXT) http/server4/mime_types.$(OBJEXT) \ + http/server4/reply.$(OBJEXT) \ + http/server4/request_parser.$(OBJEXT) \ + http/server4/server.$(OBJEXT) +http_server4_http_server_OBJECTS = \ + $(am_http_server4_http_server_OBJECTS) +http_server4_http_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@http_server4_http_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_icmp_ping_OBJECTS = icmp/ping.$(OBJEXT) +icmp_ping_OBJECTS = $(am_icmp_ping_OBJECTS) +icmp_ping_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@icmp_ping_DEPENDENCIES = libasio.a +am_invocation_prioritised_handlers_OBJECTS = \ + invocation/prioritised_handlers.$(OBJEXT) +invocation_prioritised_handlers_OBJECTS = \ + $(am_invocation_prioritised_handlers_OBJECTS) +invocation_prioritised_handlers_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@invocation_prioritised_handlers_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_iostreams_daytime_client_OBJECTS = \ + iostreams/daytime_client.$(OBJEXT) +iostreams_daytime_client_OBJECTS = \ + $(am_iostreams_daytime_client_OBJECTS) +iostreams_daytime_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@iostreams_daytime_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_iostreams_daytime_server_OBJECTS = \ + iostreams/daytime_server.$(OBJEXT) +iostreams_daytime_server_OBJECTS = \ + $(am_iostreams_daytime_server_OBJECTS) +iostreams_daytime_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@iostreams_daytime_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_iostreams_http_client_OBJECTS = iostreams/http_client.$(OBJEXT) +iostreams_http_client_OBJECTS = $(am_iostreams_http_client_OBJECTS) +iostreams_http_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@iostreams_http_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__local_connect_pair_SOURCES_DIST = local/connect_pair.cpp +@WINDOWS_TARGET_FALSE@am_local_connect_pair_OBJECTS = \ +@WINDOWS_TARGET_FALSE@ local/connect_pair.$(OBJEXT) +local_connect_pair_OBJECTS = $(am_local_connect_pair_OBJECTS) +local_connect_pair_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@local_connect_pair_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__local_fd_passing_stream_client_SOURCES_DIST = \ + local/fd_passing_stream_client.cpp +@WINDOWS_TARGET_FALSE@am_local_fd_passing_stream_client_OBJECTS = local/fd_passing_stream_client.$(OBJEXT) +local_fd_passing_stream_client_OBJECTS = \ + $(am_local_fd_passing_stream_client_OBJECTS) +local_fd_passing_stream_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@local_fd_passing_stream_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__local_fd_passing_stream_server_SOURCES_DIST = \ + local/fd_passing_stream_server.cpp +@WINDOWS_TARGET_FALSE@am_local_fd_passing_stream_server_OBJECTS = local/fd_passing_stream_server.$(OBJEXT) +local_fd_passing_stream_server_OBJECTS = \ + $(am_local_fd_passing_stream_server_OBJECTS) +local_fd_passing_stream_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@local_fd_passing_stream_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__local_iostream_client_SOURCES_DIST = local/iostream_client.cpp +@WINDOWS_TARGET_FALSE@am_local_iostream_client_OBJECTS = \ +@WINDOWS_TARGET_FALSE@ local/iostream_client.$(OBJEXT) +local_iostream_client_OBJECTS = $(am_local_iostream_client_OBJECTS) +local_iostream_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@local_iostream_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__local_stream_client_SOURCES_DIST = local/stream_client.cpp +@WINDOWS_TARGET_FALSE@am_local_stream_client_OBJECTS = \ +@WINDOWS_TARGET_FALSE@ local/stream_client.$(OBJEXT) +local_stream_client_OBJECTS = $(am_local_stream_client_OBJECTS) +local_stream_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@local_stream_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__local_stream_server_SOURCES_DIST = local/stream_server.cpp +@WINDOWS_TARGET_FALSE@am_local_stream_server_OBJECTS = \ +@WINDOWS_TARGET_FALSE@ local/stream_server.$(OBJEXT) +local_stream_server_OBJECTS = $(am_local_stream_server_OBJECTS) +local_stream_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@local_stream_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_multicast_receiver_OBJECTS = multicast/receiver.$(OBJEXT) +multicast_receiver_OBJECTS = $(am_multicast_receiver_OBJECTS) +multicast_receiver_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@multicast_receiver_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_multicast_sender_OBJECTS = multicast/sender.$(OBJEXT) +multicast_sender_OBJECTS = $(am_multicast_sender_OBJECTS) +multicast_sender_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@multicast_sender_DEPENDENCIES = libasio.a +am_nonblocking_third_party_lib_OBJECTS = \ + nonblocking/third_party_lib.$(OBJEXT) +nonblocking_third_party_lib_OBJECTS = \ + $(am_nonblocking_third_party_lib_OBJECTS) +nonblocking_third_party_lib_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@nonblocking_third_party_lib_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_1_OBJECTS = operations/composed_1.$(OBJEXT) +operations_composed_1_OBJECTS = $(am_operations_composed_1_OBJECTS) +operations_composed_1_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_1_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_2_OBJECTS = operations/composed_2.$(OBJEXT) +operations_composed_2_OBJECTS = $(am_operations_composed_2_OBJECTS) +operations_composed_2_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_2_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_3_OBJECTS = operations/composed_3.$(OBJEXT) +operations_composed_3_OBJECTS = $(am_operations_composed_3_OBJECTS) +operations_composed_3_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_3_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_4_OBJECTS = operations/composed_4.$(OBJEXT) +operations_composed_4_OBJECTS = $(am_operations_composed_4_OBJECTS) +operations_composed_4_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_4_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_5_OBJECTS = operations/composed_5.$(OBJEXT) +operations_composed_5_OBJECTS = $(am_operations_composed_5_OBJECTS) +operations_composed_5_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_5_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_6_OBJECTS = operations/composed_6.$(OBJEXT) +operations_composed_6_OBJECTS = $(am_operations_composed_6_OBJECTS) +operations_composed_6_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_6_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_7_OBJECTS = operations/composed_7.$(OBJEXT) +operations_composed_7_OBJECTS = $(am_operations_composed_7_OBJECTS) +operations_composed_7_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_7_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_8_OBJECTS = operations/composed_8.$(OBJEXT) +operations_composed_8_OBJECTS = $(am_operations_composed_8_OBJECTS) +operations_composed_8_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_8_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_parallel_group_ranged_wait_for_all_OBJECTS = \ + parallel_group/ranged_wait_for_all.$(OBJEXT) +parallel_group_ranged_wait_for_all_OBJECTS = \ + $(am_parallel_group_ranged_wait_for_all_OBJECTS) +parallel_group_ranged_wait_for_all_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@parallel_group_ranged_wait_for_all_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_parallel_group_wait_for_all_OBJECTS = \ + parallel_group/wait_for_all.$(OBJEXT) +parallel_group_wait_for_all_OBJECTS = \ + $(am_parallel_group_wait_for_all_OBJECTS) +parallel_group_wait_for_all_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@parallel_group_wait_for_all_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_parallel_group_wait_for_one_OBJECTS = \ + parallel_group/wait_for_one.$(OBJEXT) +parallel_group_wait_for_one_OBJECTS = \ + $(am_parallel_group_wait_for_one_OBJECTS) +parallel_group_wait_for_one_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@parallel_group_wait_for_one_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_parallel_group_wait_for_one_error_OBJECTS = \ + parallel_group/wait_for_one_error.$(OBJEXT) +parallel_group_wait_for_one_error_OBJECTS = \ + $(am_parallel_group_wait_for_one_error_OBJECTS) +parallel_group_wait_for_one_error_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@parallel_group_wait_for_one_error_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_parallel_group_wait_for_one_success_OBJECTS = \ + parallel_group/wait_for_one_success.$(OBJEXT) +parallel_group_wait_for_one_success_OBJECTS = \ + $(am_parallel_group_wait_for_one_success_OBJECTS) +parallel_group_wait_for_one_success_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@parallel_group_wait_for_one_success_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_porthopper_client_OBJECTS = porthopper/client.$(OBJEXT) +porthopper_client_OBJECTS = $(am_porthopper_client_OBJECTS) +porthopper_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@porthopper_client_DEPENDENCIES = libasio.a +am_porthopper_server_OBJECTS = porthopper/server.$(OBJEXT) +porthopper_server_OBJECTS = $(am_porthopper_server_OBJECTS) +porthopper_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@porthopper_server_DEPENDENCIES = libasio.a +am_services_daytime_client_OBJECTS = \ + services/daytime_client.$(OBJEXT) \ + services/logger_service.$(OBJEXT) +services_daytime_client_OBJECTS = \ + $(am_services_daytime_client_OBJECTS) +services_daytime_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@services_daytime_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_socks4_sync_client_OBJECTS = socks4/sync_client.$(OBJEXT) +socks4_sync_client_OBJECTS = $(am_socks4_sync_client_OBJECTS) +socks4_sync_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@socks4_sync_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__spawn_echo_server_SOURCES_DIST = spawn/echo_server.cpp +@HAVE_BOOST_COROUTINE_TRUE@am_spawn_echo_server_OBJECTS = \ +@HAVE_BOOST_COROUTINE_TRUE@ spawn/echo_server.$(OBJEXT) +spawn_echo_server_OBJECTS = $(am_spawn_echo_server_OBJECTS) +@HAVE_BOOST_COROUTINE_TRUE@spawn_echo_server_DEPENDENCIES = $(LDADD) +am__spawn_parallel_grep_SOURCES_DIST = spawn/parallel_grep.cpp +@HAVE_BOOST_COROUTINE_TRUE@am_spawn_parallel_grep_OBJECTS = \ +@HAVE_BOOST_COROUTINE_TRUE@ spawn/parallel_grep.$(OBJEXT) +spawn_parallel_grep_OBJECTS = $(am_spawn_parallel_grep_OBJECTS) +@HAVE_BOOST_COROUTINE_TRUE@spawn_parallel_grep_DEPENDENCIES = \ +@HAVE_BOOST_COROUTINE_TRUE@ $(LDADD) +am__ssl_client_SOURCES_DIST = ssl/client.cpp +@HAVE_OPENSSL_TRUE@am_ssl_client_OBJECTS = ssl/client.$(OBJEXT) +ssl_client_OBJECTS = $(am_ssl_client_OBJECTS) +ssl_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@ssl_client_DEPENDENCIES = libasio.a +am__ssl_server_SOURCES_DIST = ssl/server.cpp +@HAVE_OPENSSL_TRUE@am_ssl_server_OBJECTS = ssl/server.$(OBJEXT) +ssl_server_OBJECTS = $(am_ssl_server_OBJECTS) +ssl_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@ssl_server_DEPENDENCIES = libasio.a +am_timeouts_async_tcp_client_OBJECTS = \ + timeouts/async_tcp_client.$(OBJEXT) +timeouts_async_tcp_client_OBJECTS = \ + $(am_timeouts_async_tcp_client_OBJECTS) +timeouts_async_tcp_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@timeouts_async_tcp_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_timeouts_blocking_tcp_client_OBJECTS = \ + timeouts/blocking_tcp_client.$(OBJEXT) +timeouts_blocking_tcp_client_OBJECTS = \ + $(am_timeouts_blocking_tcp_client_OBJECTS) +timeouts_blocking_tcp_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@timeouts_blocking_tcp_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_timeouts_blocking_token_tcp_client_OBJECTS = \ + timeouts/blocking_token_tcp_client.$(OBJEXT) +timeouts_blocking_token_tcp_client_OBJECTS = \ + $(am_timeouts_blocking_token_tcp_client_OBJECTS) +timeouts_blocking_token_tcp_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@timeouts_blocking_token_tcp_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_timeouts_blocking_udp_client_OBJECTS = \ + timeouts/blocking_udp_client.$(OBJEXT) +timeouts_blocking_udp_client_OBJECTS = \ + $(am_timeouts_blocking_udp_client_OBJECTS) +timeouts_blocking_udp_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@timeouts_blocking_udp_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_timeouts_server_OBJECTS = timeouts/server.$(OBJEXT) +timeouts_server_OBJECTS = $(am_timeouts_server_OBJECTS) +timeouts_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@timeouts_server_DEPENDENCIES = libasio.a +am_timers_time_t_timer_OBJECTS = timers/time_t_timer.$(OBJEXT) +timers_time_t_timer_OBJECTS = $(am_timers_time_t_timer_OBJECTS) +timers_time_t_timer_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@timers_time_t_timer_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_daytime1_client_OBJECTS = \ + tutorial/daytime1/client.$(OBJEXT) +tutorial_daytime1_client_OBJECTS = \ + $(am_tutorial_daytime1_client_OBJECTS) +tutorial_daytime1_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_daytime1_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_daytime2_server_OBJECTS = \ + tutorial/daytime2/server.$(OBJEXT) +tutorial_daytime2_server_OBJECTS = \ + $(am_tutorial_daytime2_server_OBJECTS) +tutorial_daytime2_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_daytime2_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_daytime3_server_OBJECTS = \ + tutorial/daytime3/server.$(OBJEXT) +tutorial_daytime3_server_OBJECTS = \ + $(am_tutorial_daytime3_server_OBJECTS) +tutorial_daytime3_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_daytime3_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_daytime4_client_OBJECTS = \ + tutorial/daytime4/client.$(OBJEXT) +tutorial_daytime4_client_OBJECTS = \ + $(am_tutorial_daytime4_client_OBJECTS) +tutorial_daytime4_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_daytime4_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_daytime5_server_OBJECTS = \ + tutorial/daytime5/server.$(OBJEXT) +tutorial_daytime5_server_OBJECTS = \ + $(am_tutorial_daytime5_server_OBJECTS) +tutorial_daytime5_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_daytime5_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_daytime6_server_OBJECTS = \ + tutorial/daytime6/server.$(OBJEXT) +tutorial_daytime6_server_OBJECTS = \ + $(am_tutorial_daytime6_server_OBJECTS) +tutorial_daytime6_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_daytime6_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_daytime7_server_OBJECTS = \ + tutorial/daytime7/server.$(OBJEXT) +tutorial_daytime7_server_OBJECTS = \ + $(am_tutorial_daytime7_server_OBJECTS) +tutorial_daytime7_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_daytime7_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_timer1_timer_OBJECTS = tutorial/timer1/timer.$(OBJEXT) +tutorial_timer1_timer_OBJECTS = $(am_tutorial_timer1_timer_OBJECTS) +tutorial_timer1_timer_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_timer1_timer_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_timer2_timer_OBJECTS = tutorial/timer2/timer.$(OBJEXT) +tutorial_timer2_timer_OBJECTS = $(am_tutorial_timer2_timer_OBJECTS) +tutorial_timer2_timer_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_timer2_timer_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_timer3_timer_OBJECTS = tutorial/timer3/timer.$(OBJEXT) +tutorial_timer3_timer_OBJECTS = $(am_tutorial_timer3_timer_OBJECTS) +tutorial_timer3_timer_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_timer3_timer_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_timer4_timer_OBJECTS = tutorial/timer4/timer.$(OBJEXT) +tutorial_timer4_timer_OBJECTS = $(am_tutorial_timer4_timer_OBJECTS) +tutorial_timer4_timer_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_timer4_timer_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_tutorial_timer5_timer_OBJECTS = tutorial/timer5/timer.$(OBJEXT) +tutorial_timer5_timer_OBJECTS = $(am_tutorial_timer5_timer_OBJECTS) +tutorial_timer5_timer_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@tutorial_timer5_timer_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_type_erasure_type_erasure_OBJECTS = type_erasure/main.$(OBJEXT) \ + type_erasure/stdin_line_reader.$(OBJEXT) \ + type_erasure/sleep.$(OBJEXT) +type_erasure_type_erasure_OBJECTS = \ + $(am_type_erasure_type_erasure_OBJECTS) +type_erasure_type_erasure_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@type_erasure_type_erasure_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__windows_transmit_file_SOURCES_DIST = windows/transmit_file.cpp +@WINDOWS_TARGET_TRUE@am_windows_transmit_file_OBJECTS = \ +@WINDOWS_TARGET_TRUE@ windows/transmit_file.$(OBJEXT) +windows_transmit_file_OBJECTS = $(am_windows_transmit_file_OBJECTS) +windows_transmit_file_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@windows_transmit_file_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ../../$(DEPDIR)/asio.Po \ + ../../$(DEPDIR)/asio_ssl.Po allocation/$(DEPDIR)/server.Po \ + buffers/$(DEPDIR)/reference_counted.Po \ + chat/$(DEPDIR)/chat_client.Po chat/$(DEPDIR)/chat_server.Po \ + chat/$(DEPDIR)/posix_chat_client.Po \ + deferred/$(DEPDIR)/deferred_1.Po \ + deferred/$(DEPDIR)/deferred_2.Po \ + echo/$(DEPDIR)/async_tcp_echo_server.Po \ + echo/$(DEPDIR)/async_udp_echo_server.Po \ + echo/$(DEPDIR)/blocking_tcp_echo_client.Po \ + echo/$(DEPDIR)/blocking_tcp_echo_server.Po \ + echo/$(DEPDIR)/blocking_udp_echo_client.Po \ + echo/$(DEPDIR)/blocking_udp_echo_server.Po \ + executors/$(DEPDIR)/actor.Po \ + executors/$(DEPDIR)/bank_account_1.Po \ + executors/$(DEPDIR)/bank_account_2.Po \ + executors/$(DEPDIR)/fork_join.Po \ + executors/$(DEPDIR)/pipeline.Po \ + executors/$(DEPDIR)/priority_scheduler.Po \ + files/$(DEPDIR)/async_file_copy.Po \ + files/$(DEPDIR)/blocking_file_copy.Po fork/$(DEPDIR)/daemon.Po \ + fork/$(DEPDIR)/process_per_connection.Po \ + futures/$(DEPDIR)/daytime_client.Po \ + handler_tracking/$(DEPDIR)/async_tcp_echo_server.Po \ + http/client/$(DEPDIR)/async_client.Po \ + http/client/$(DEPDIR)/sync_client.Po \ + http/server/$(DEPDIR)/connection.Po \ + http/server/$(DEPDIR)/connection_manager.Po \ + http/server/$(DEPDIR)/main.Po \ + http/server/$(DEPDIR)/mime_types.Po \ + http/server/$(DEPDIR)/reply.Po \ + http/server/$(DEPDIR)/request_handler.Po \ + http/server/$(DEPDIR)/request_parser.Po \ + http/server/$(DEPDIR)/server.Po \ + http/server2/$(DEPDIR)/connection.Po \ + http/server2/$(DEPDIR)/io_context_pool.Po \ + http/server2/$(DEPDIR)/main.Po \ + http/server2/$(DEPDIR)/mime_types.Po \ + http/server2/$(DEPDIR)/reply.Po \ + http/server2/$(DEPDIR)/request_handler.Po \ + http/server2/$(DEPDIR)/request_parser.Po \ + http/server2/$(DEPDIR)/server.Po \ + http/server3/$(DEPDIR)/connection.Po \ + http/server3/$(DEPDIR)/main.Po \ + http/server3/$(DEPDIR)/mime_types.Po \ + http/server3/$(DEPDIR)/reply.Po \ + http/server3/$(DEPDIR)/request_handler.Po \ + http/server3/$(DEPDIR)/request_parser.Po \ + http/server3/$(DEPDIR)/server.Po \ + http/server4/$(DEPDIR)/file_handler.Po \ + http/server4/$(DEPDIR)/main.Po \ + http/server4/$(DEPDIR)/mime_types.Po \ + http/server4/$(DEPDIR)/reply.Po \ + http/server4/$(DEPDIR)/request_parser.Po \ + http/server4/$(DEPDIR)/server.Po icmp/$(DEPDIR)/ping.Po \ + invocation/$(DEPDIR)/prioritised_handlers.Po \ + iostreams/$(DEPDIR)/daytime_client.Po \ + iostreams/$(DEPDIR)/daytime_server.Po \ + iostreams/$(DEPDIR)/http_client.Po \ + local/$(DEPDIR)/connect_pair.Po \ + local/$(DEPDIR)/fd_passing_stream_client.Po \ + local/$(DEPDIR)/fd_passing_stream_server.Po \ + local/$(DEPDIR)/iostream_client.Po \ + local/$(DEPDIR)/stream_client.Po \ + local/$(DEPDIR)/stream_server.Po \ + multicast/$(DEPDIR)/receiver.Po multicast/$(DEPDIR)/sender.Po \ + nonblocking/$(DEPDIR)/third_party_lib.Po \ + operations/$(DEPDIR)/composed_1.Po \ + operations/$(DEPDIR)/composed_2.Po \ + operations/$(DEPDIR)/composed_3.Po \ + operations/$(DEPDIR)/composed_4.Po \ + operations/$(DEPDIR)/composed_5.Po \ + operations/$(DEPDIR)/composed_6.Po \ + operations/$(DEPDIR)/composed_7.Po \ + operations/$(DEPDIR)/composed_8.Po \ + parallel_group/$(DEPDIR)/ranged_wait_for_all.Po \ + parallel_group/$(DEPDIR)/wait_for_all.Po \ + parallel_group/$(DEPDIR)/wait_for_one.Po \ + parallel_group/$(DEPDIR)/wait_for_one_error.Po \ + parallel_group/$(DEPDIR)/wait_for_one_success.Po \ + porthopper/$(DEPDIR)/client.Po porthopper/$(DEPDIR)/server.Po \ + services/$(DEPDIR)/daytime_client.Po \ + services/$(DEPDIR)/logger_service.Po \ + socks4/$(DEPDIR)/sync_client.Po spawn/$(DEPDIR)/echo_server.Po \ + spawn/$(DEPDIR)/parallel_grep.Po ssl/$(DEPDIR)/client.Po \ + ssl/$(DEPDIR)/server.Po timeouts/$(DEPDIR)/async_tcp_client.Po \ + timeouts/$(DEPDIR)/blocking_tcp_client.Po \ + timeouts/$(DEPDIR)/blocking_token_tcp_client.Po \ + timeouts/$(DEPDIR)/blocking_udp_client.Po \ + timeouts/$(DEPDIR)/server.Po timers/$(DEPDIR)/time_t_timer.Po \ + tutorial/daytime1/$(DEPDIR)/client.Po \ + tutorial/daytime2/$(DEPDIR)/server.Po \ + tutorial/daytime3/$(DEPDIR)/server.Po \ + tutorial/daytime4/$(DEPDIR)/client.Po \ + tutorial/daytime5/$(DEPDIR)/server.Po \ + tutorial/daytime6/$(DEPDIR)/server.Po \ + tutorial/daytime7/$(DEPDIR)/server.Po \ + tutorial/timer1/$(DEPDIR)/timer.Po \ + tutorial/timer2/$(DEPDIR)/timer.Po \ + tutorial/timer3/$(DEPDIR)/timer.Po \ + tutorial/timer4/$(DEPDIR)/timer.Po \ + tutorial/timer5/$(DEPDIR)/timer.Po \ + type_erasure/$(DEPDIR)/main.Po type_erasure/$(DEPDIR)/sleep.Po \ + type_erasure/$(DEPDIR)/stdin_line_reader.Po \ + windows/$(DEPDIR)/transmit_file.Po +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(libasio_a_SOURCES) $(allocation_server_SOURCES) \ + $(buffers_reference_counted_SOURCES) \ + $(chat_chat_client_SOURCES) $(chat_chat_server_SOURCES) \ + $(chat_posix_chat_client_SOURCES) \ + $(deferred_deferred_1_SOURCES) $(deferred_deferred_2_SOURCES) \ + $(echo_async_tcp_echo_server_SOURCES) \ + $(echo_async_udp_echo_server_SOURCES) \ + $(echo_blocking_tcp_echo_client_SOURCES) \ + $(echo_blocking_tcp_echo_server_SOURCES) \ + $(echo_blocking_udp_echo_client_SOURCES) \ + $(echo_blocking_udp_echo_server_SOURCES) \ + $(executors_actor_SOURCES) $(executors_bank_account_1_SOURCES) \ + $(executors_bank_account_2_SOURCES) \ + $(executors_fork_join_SOURCES) $(executors_pipeline_SOURCES) \ + $(executors_priority_scheduler_SOURCES) \ + $(files_async_file_copy_SOURCES) \ + $(files_blocking_file_copy_SOURCES) $(fork_daemon_SOURCES) \ + $(fork_process_per_connection_SOURCES) \ + $(futures_daytime_client_SOURCES) \ + $(handler_tracking_async_tcp_echo_server_SOURCES) \ + $(http_client_async_client_SOURCES) \ + $(http_client_sync_client_SOURCES) \ + $(http_server_http_server_SOURCES) \ + $(http_server2_http_server_SOURCES) \ + $(http_server3_http_server_SOURCES) \ + $(http_server4_http_server_SOURCES) $(icmp_ping_SOURCES) \ + $(invocation_prioritised_handlers_SOURCES) \ + $(iostreams_daytime_client_SOURCES) \ + $(iostreams_daytime_server_SOURCES) \ + $(iostreams_http_client_SOURCES) $(local_connect_pair_SOURCES) \ + $(local_fd_passing_stream_client_SOURCES) \ + $(local_fd_passing_stream_server_SOURCES) \ + $(local_iostream_client_SOURCES) \ + $(local_stream_client_SOURCES) $(local_stream_server_SOURCES) \ + $(multicast_receiver_SOURCES) $(multicast_sender_SOURCES) \ + $(nonblocking_third_party_lib_SOURCES) \ + $(operations_composed_1_SOURCES) \ + $(operations_composed_2_SOURCES) \ + $(operations_composed_3_SOURCES) \ + $(operations_composed_4_SOURCES) \ + $(operations_composed_5_SOURCES) \ + $(operations_composed_6_SOURCES) \ + $(operations_composed_7_SOURCES) \ + $(operations_composed_8_SOURCES) \ + $(parallel_group_ranged_wait_for_all_SOURCES) \ + $(parallel_group_wait_for_all_SOURCES) \ + $(parallel_group_wait_for_one_SOURCES) \ + $(parallel_group_wait_for_one_error_SOURCES) \ + $(parallel_group_wait_for_one_success_SOURCES) \ + $(porthopper_client_SOURCES) $(porthopper_server_SOURCES) \ + $(services_daytime_client_SOURCES) \ + $(socks4_sync_client_SOURCES) $(spawn_echo_server_SOURCES) \ + $(spawn_parallel_grep_SOURCES) $(ssl_client_SOURCES) \ + $(ssl_server_SOURCES) $(timeouts_async_tcp_client_SOURCES) \ + $(timeouts_blocking_tcp_client_SOURCES) \ + $(timeouts_blocking_token_tcp_client_SOURCES) \ + $(timeouts_blocking_udp_client_SOURCES) \ + $(timeouts_server_SOURCES) $(timers_time_t_timer_SOURCES) \ + $(tutorial_daytime1_client_SOURCES) \ + $(tutorial_daytime2_server_SOURCES) \ + $(tutorial_daytime3_server_SOURCES) \ + $(tutorial_daytime4_client_SOURCES) \ + $(tutorial_daytime5_server_SOURCES) \ + $(tutorial_daytime6_server_SOURCES) \ + $(tutorial_daytime7_server_SOURCES) \ + $(tutorial_timer1_timer_SOURCES) \ + $(tutorial_timer2_timer_SOURCES) \ + $(tutorial_timer3_timer_SOURCES) \ + $(tutorial_timer4_timer_SOURCES) \ + $(tutorial_timer5_timer_SOURCES) \ + $(type_erasure_type_erasure_SOURCES) \ + $(windows_transmit_file_SOURCES) +DIST_SOURCES = $(am__libasio_a_SOURCES_DIST) \ + $(allocation_server_SOURCES) \ + $(buffers_reference_counted_SOURCES) \ + $(chat_chat_client_SOURCES) $(chat_chat_server_SOURCES) \ + $(am__chat_posix_chat_client_SOURCES_DIST) \ + $(deferred_deferred_1_SOURCES) $(deferred_deferred_2_SOURCES) \ + $(echo_async_tcp_echo_server_SOURCES) \ + $(echo_async_udp_echo_server_SOURCES) \ + $(echo_blocking_tcp_echo_client_SOURCES) \ + $(echo_blocking_tcp_echo_server_SOURCES) \ + $(echo_blocking_udp_echo_client_SOURCES) \ + $(echo_blocking_udp_echo_server_SOURCES) \ + $(executors_actor_SOURCES) $(executors_bank_account_1_SOURCES) \ + $(executors_bank_account_2_SOURCES) \ + $(executors_fork_join_SOURCES) $(executors_pipeline_SOURCES) \ + $(executors_priority_scheduler_SOURCES) \ + $(files_async_file_copy_SOURCES) \ + $(files_blocking_file_copy_SOURCES) \ + $(am__fork_daemon_SOURCES_DIST) \ + $(am__fork_process_per_connection_SOURCES_DIST) \ + $(futures_daytime_client_SOURCES) \ + $(handler_tracking_async_tcp_echo_server_SOURCES) \ + $(http_client_async_client_SOURCES) \ + $(http_client_sync_client_SOURCES) \ + $(http_server_http_server_SOURCES) \ + $(http_server2_http_server_SOURCES) \ + $(http_server3_http_server_SOURCES) \ + $(http_server4_http_server_SOURCES) $(icmp_ping_SOURCES) \ + $(invocation_prioritised_handlers_SOURCES) \ + $(iostreams_daytime_client_SOURCES) \ + $(iostreams_daytime_server_SOURCES) \ + $(iostreams_http_client_SOURCES) \ + $(am__local_connect_pair_SOURCES_DIST) \ + $(am__local_fd_passing_stream_client_SOURCES_DIST) \ + $(am__local_fd_passing_stream_server_SOURCES_DIST) \ + $(am__local_iostream_client_SOURCES_DIST) \ + $(am__local_stream_client_SOURCES_DIST) \ + $(am__local_stream_server_SOURCES_DIST) \ + $(multicast_receiver_SOURCES) $(multicast_sender_SOURCES) \ + $(nonblocking_third_party_lib_SOURCES) \ + $(operations_composed_1_SOURCES) \ + $(operations_composed_2_SOURCES) \ + $(operations_composed_3_SOURCES) \ + $(operations_composed_4_SOURCES) \ + $(operations_composed_5_SOURCES) \ + $(operations_composed_6_SOURCES) \ + $(operations_composed_7_SOURCES) \ + $(operations_composed_8_SOURCES) \ + $(parallel_group_ranged_wait_for_all_SOURCES) \ + $(parallel_group_wait_for_all_SOURCES) \ + $(parallel_group_wait_for_one_SOURCES) \ + $(parallel_group_wait_for_one_error_SOURCES) \ + $(parallel_group_wait_for_one_success_SOURCES) \ + $(porthopper_client_SOURCES) $(porthopper_server_SOURCES) \ + $(services_daytime_client_SOURCES) \ + $(socks4_sync_client_SOURCES) \ + $(am__spawn_echo_server_SOURCES_DIST) \ + $(am__spawn_parallel_grep_SOURCES_DIST) \ + $(am__ssl_client_SOURCES_DIST) $(am__ssl_server_SOURCES_DIST) \ + $(timeouts_async_tcp_client_SOURCES) \ + $(timeouts_blocking_tcp_client_SOURCES) \ + $(timeouts_blocking_token_tcp_client_SOURCES) \ + $(timeouts_blocking_udp_client_SOURCES) \ + $(timeouts_server_SOURCES) $(timers_time_t_timer_SOURCES) \ + $(tutorial_daytime1_client_SOURCES) \ + $(tutorial_daytime2_server_SOURCES) \ + $(tutorial_daytime3_server_SOURCES) \ + $(tutorial_daytime4_client_SOURCES) \ + $(tutorial_daytime5_server_SOURCES) \ + $(tutorial_daytime6_server_SOURCES) \ + $(tutorial_daytime7_server_SOURCES) \ + $(tutorial_timer1_timer_SOURCES) \ + $(tutorial_timer2_timer_SOURCES) \ + $(tutorial_timer3_timer_SOURCES) \ + $(tutorial_timer4_timer_SOURCES) \ + $(tutorial_timer5_timer_SOURCES) \ + $(type_erasure_type_erasure_SOURCES) \ + $(am__windows_transmit_file_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +ETAGS = @ETAGS@ +EXEEXT = @EXEEXT@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfigdir = @pkgconfigdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = subdir-objects +@SEPARATE_COMPILATION_TRUE@noinst_LIBRARIES = libasio.a +@SEPARATE_COMPILATION_TRUE@libasio_a_SOURCES = ../../asio.cpp \ +@SEPARATE_COMPILATION_TRUE@ $(am__append_1) +@SEPARATE_COMPILATION_TRUE@LDADD = libasio.a +noinst_HEADERS = \ + chat/chat_message.hpp \ + handler_tracking/custom_tracking.hpp \ + http/server/connection.hpp \ + http/server/connection_manager.hpp \ + http/server/header.hpp \ + http/server/mime_types.hpp \ + http/server/reply.hpp \ + http/server/request.hpp \ + http/server/request_handler.hpp \ + http/server/request_parser.hpp \ + http/server/server.hpp \ + http/server2/connection.hpp \ + http/server2/io_context_pool.hpp \ + http/server2/header.hpp \ + http/server2/mime_types.hpp \ + http/server2/reply.hpp \ + http/server2/request.hpp \ + http/server2/request_handler.hpp \ + http/server2/request_parser.hpp \ + http/server2/server.hpp \ + http/server3/connection.hpp \ + http/server3/header.hpp \ + http/server3/mime_types.hpp \ + http/server3/reply.hpp \ + http/server3/request.hpp \ + http/server3/request_handler.hpp \ + http/server3/request_parser.hpp \ + http/server3/server.hpp \ + http/server4/file_handler.hpp \ + http/server4/header.hpp \ + http/server4/mime_types.hpp \ + http/server4/reply.hpp \ + http/server4/request.hpp \ + http/server4/request_parser.hpp \ + http/server4/server.hpp \ + icmp/icmp_header.hpp \ + icmp/ipv4_header.hpp \ + porthopper/protocol.hpp \ + services/basic_logger.hpp \ + services/logger.hpp \ + services/logger_service.hpp \ + socks4/socks4.hpp \ + type_erasure/line_reader.hpp \ + type_erasure/stdin_line_reader.hpp \ + type_erasure/sleep.hpp + +AM_CXXFLAGS = -I$(srcdir)/../../../include +allocation_server_SOURCES = allocation/server.cpp +buffers_reference_counted_SOURCES = buffers/reference_counted.cpp +chat_chat_client_SOURCES = chat/chat_client.cpp +chat_chat_server_SOURCES = chat/chat_server.cpp +deferred_deferred_1_SOURCES = deferred/deferred_1.cpp +deferred_deferred_2_SOURCES = deferred/deferred_2.cpp +echo_async_tcp_echo_server_SOURCES = echo/async_tcp_echo_server.cpp +echo_async_udp_echo_server_SOURCES = echo/async_udp_echo_server.cpp +echo_blocking_tcp_echo_client_SOURCES = echo/blocking_tcp_echo_client.cpp +echo_blocking_tcp_echo_server_SOURCES = echo/blocking_tcp_echo_server.cpp +echo_blocking_udp_echo_client_SOURCES = echo/blocking_udp_echo_client.cpp +echo_blocking_udp_echo_server_SOURCES = echo/blocking_udp_echo_server.cpp +executors_actor_SOURCES = executors/actor.cpp +executors_bank_account_1_SOURCES = executors/bank_account_1.cpp +executors_bank_account_2_SOURCES = executors/bank_account_2.cpp +executors_fork_join_SOURCES = executors/fork_join.cpp +executors_pipeline_SOURCES = executors/pipeline.cpp +executors_priority_scheduler_SOURCES = executors/priority_scheduler.cpp +files_blocking_file_copy_SOURCES = files/blocking_file_copy.cpp +files_async_file_copy_SOURCES = files/async_file_copy.cpp +futures_daytime_client_SOURCES = futures/daytime_client.cpp +handler_tracking_async_tcp_echo_server_SOURCES = handler_tracking/async_tcp_echo_server.cpp +http_client_async_client_SOURCES = http/client/async_client.cpp +http_client_sync_client_SOURCES = http/client/sync_client.cpp +http_server_http_server_SOURCES = \ + http/server/connection.cpp \ + http/server/connection_manager.cpp \ + http/server/main.cpp \ + http/server/mime_types.cpp \ + http/server/reply.cpp \ + http/server/request_handler.cpp \ + http/server/request_parser.cpp \ + http/server/server.cpp + +http_server2_http_server_SOURCES = \ + http/server2/connection.cpp \ + http/server2/io_context_pool.cpp \ + http/server2/main.cpp \ + http/server2/mime_types.cpp \ + http/server2/reply.cpp \ + http/server2/request_handler.cpp \ + http/server2/request_parser.cpp \ + http/server2/server.cpp + +http_server3_http_server_SOURCES = \ + http/server3/connection.cpp \ + http/server3/main.cpp \ + http/server3/mime_types.cpp \ + http/server3/reply.cpp \ + http/server3/request_handler.cpp \ + http/server3/request_parser.cpp \ + http/server3/server.cpp + +http_server4_http_server_SOURCES = \ + http/server4/file_handler.cpp \ + http/server4/main.cpp \ + http/server4/mime_types.cpp \ + http/server4/reply.cpp \ + http/server4/request_parser.cpp \ + http/server4/server.cpp + +icmp_ping_SOURCES = icmp/ping.cpp +invocation_prioritised_handlers_SOURCES = invocation/prioritised_handlers.cpp +iostreams_daytime_client_SOURCES = iostreams/daytime_client.cpp +iostreams_daytime_server_SOURCES = iostreams/daytime_server.cpp +iostreams_http_client_SOURCES = iostreams/http_client.cpp +multicast_receiver_SOURCES = multicast/receiver.cpp +multicast_sender_SOURCES = multicast/sender.cpp +nonblocking_third_party_lib_SOURCES = nonblocking/third_party_lib.cpp +operations_composed_1_SOURCES = operations/composed_1.cpp +operations_composed_2_SOURCES = operations/composed_2.cpp +operations_composed_3_SOURCES = operations/composed_3.cpp +operations_composed_4_SOURCES = operations/composed_4.cpp +operations_composed_5_SOURCES = operations/composed_5.cpp +operations_composed_6_SOURCES = operations/composed_6.cpp +operations_composed_7_SOURCES = operations/composed_7.cpp +operations_composed_8_SOURCES = operations/composed_8.cpp +parallel_group_ranged_wait_for_all_SOURCES = parallel_group/ranged_wait_for_all.cpp +parallel_group_wait_for_all_SOURCES = parallel_group/wait_for_all.cpp +parallel_group_wait_for_one_SOURCES = parallel_group/wait_for_one.cpp +parallel_group_wait_for_one_error_SOURCES = parallel_group/wait_for_one_error.cpp +parallel_group_wait_for_one_success_SOURCES = parallel_group/wait_for_one_success.cpp +porthopper_client_SOURCES = porthopper/client.cpp +porthopper_server_SOURCES = porthopper/server.cpp +services_daytime_client_SOURCES = \ + services/daytime_client.cpp \ + services/logger_service.cpp + +socks4_sync_client_SOURCES = socks4/sync_client.cpp +timeouts_async_tcp_client_SOURCES = timeouts/async_tcp_client.cpp +timeouts_blocking_tcp_client_SOURCES = timeouts/blocking_tcp_client.cpp +timeouts_blocking_token_tcp_client_SOURCES = timeouts/blocking_token_tcp_client.cpp +timeouts_blocking_udp_client_SOURCES = timeouts/blocking_udp_client.cpp +timeouts_server_SOURCES = timeouts/server.cpp +timers_time_t_timer_SOURCES = timers/time_t_timer.cpp +tutorial_timer1_timer_SOURCES = tutorial/timer1/timer.cpp +tutorial_timer2_timer_SOURCES = tutorial/timer2/timer.cpp +tutorial_timer3_timer_SOURCES = tutorial/timer3/timer.cpp +tutorial_timer4_timer_SOURCES = tutorial/timer4/timer.cpp +tutorial_timer5_timer_SOURCES = tutorial/timer5/timer.cpp +tutorial_daytime1_client_SOURCES = tutorial/daytime1/client.cpp +tutorial_daytime2_server_SOURCES = tutorial/daytime2/server.cpp +tutorial_daytime3_server_SOURCES = tutorial/daytime3/server.cpp +tutorial_daytime4_client_SOURCES = tutorial/daytime4/client.cpp +tutorial_daytime5_server_SOURCES = tutorial/daytime5/server.cpp +tutorial_daytime6_server_SOURCES = tutorial/daytime6/server.cpp +tutorial_daytime7_server_SOURCES = tutorial/daytime7/server.cpp +type_erasure_type_erasure_SOURCES = type_erasure/main.cpp type_erasure/stdin_line_reader.cpp type_erasure/sleep.cpp +@WINDOWS_TARGET_FALSE@chat_posix_chat_client_SOURCES = chat/posix_chat_client.cpp +@WINDOWS_TARGET_FALSE@fork_daemon_SOURCES = fork/daemon.cpp +@WINDOWS_TARGET_FALSE@fork_process_per_connection_SOURCES = fork/process_per_connection.cpp +@WINDOWS_TARGET_FALSE@local_connect_pair_SOURCES = local/connect_pair.cpp +@WINDOWS_TARGET_FALSE@local_iostream_client_SOURCES = local/iostream_client.cpp +@WINDOWS_TARGET_FALSE@local_stream_server_SOURCES = local/stream_server.cpp +@WINDOWS_TARGET_FALSE@local_stream_client_SOURCES = local/stream_client.cpp +@WINDOWS_TARGET_FALSE@local_fd_passing_stream_server_SOURCES = local/fd_passing_stream_server.cpp +@WINDOWS_TARGET_FALSE@local_fd_passing_stream_client_SOURCES = local/fd_passing_stream_client.cpp +@WINDOWS_TARGET_TRUE@windows_transmit_file_SOURCES = windows/transmit_file.cpp +@HAVE_OPENSSL_TRUE@ssl_client_SOURCES = ssl/client.cpp +@HAVE_OPENSSL_TRUE@ssl_server_SOURCES = ssl/server.cpp +@HAVE_BOOST_COROUTINE_TRUE@spawn_echo_server_SOURCES = spawn/echo_server.cpp +@HAVE_BOOST_COROUTINE_TRUE@spawn_echo_server_LDADD = $(LDADD) -lboost_coroutine -lboost_context -lboost_thread -lboost_chrono -lboost_system +@HAVE_BOOST_COROUTINE_TRUE@spawn_parallel_grep_SOURCES = spawn/parallel_grep.cpp +@HAVE_BOOST_COROUTINE_TRUE@spawn_parallel_grep_LDADD = $(LDADD) -lboost_coroutine -lboost_context -lboost_thread -lboost_chrono -lboost_system +EXTRA_DIST = \ + serialization/client.cpp \ + serialization/server.cpp \ + serialization/connection.hpp \ + serialization/stock.hpp \ + ssl/README \ + ssl/ca.pem \ + ssl/server.pem \ + ssl/dh4096.pem + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/examples/cpp11/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/examples/cpp11/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +../../$(am__dirstamp): + @$(MKDIR_P) ../.. + @: > ../../$(am__dirstamp) +../../$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) ../../$(DEPDIR) + @: > ../../$(DEPDIR)/$(am__dirstamp) +../../asio.$(OBJEXT): ../../$(am__dirstamp) \ + ../../$(DEPDIR)/$(am__dirstamp) +../../asio_ssl.$(OBJEXT): ../../$(am__dirstamp) \ + ../../$(DEPDIR)/$(am__dirstamp) + +libasio.a: $(libasio_a_OBJECTS) $(libasio_a_DEPENDENCIES) $(EXTRA_libasio_a_DEPENDENCIES) + $(AM_V_at)-rm -f libasio.a + $(AM_V_AR)$(libasio_a_AR) libasio.a $(libasio_a_OBJECTS) $(libasio_a_LIBADD) + $(AM_V_at)$(RANLIB) libasio.a +allocation/$(am__dirstamp): + @$(MKDIR_P) allocation + @: > allocation/$(am__dirstamp) +allocation/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) allocation/$(DEPDIR) + @: > allocation/$(DEPDIR)/$(am__dirstamp) +allocation/server.$(OBJEXT): allocation/$(am__dirstamp) \ + allocation/$(DEPDIR)/$(am__dirstamp) + +allocation/server$(EXEEXT): $(allocation_server_OBJECTS) $(allocation_server_DEPENDENCIES) $(EXTRA_allocation_server_DEPENDENCIES) allocation/$(am__dirstamp) + @rm -f allocation/server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(allocation_server_OBJECTS) $(allocation_server_LDADD) $(LIBS) +buffers/$(am__dirstamp): + @$(MKDIR_P) buffers + @: > buffers/$(am__dirstamp) +buffers/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) buffers/$(DEPDIR) + @: > buffers/$(DEPDIR)/$(am__dirstamp) +buffers/reference_counted.$(OBJEXT): buffers/$(am__dirstamp) \ + buffers/$(DEPDIR)/$(am__dirstamp) + +buffers/reference_counted$(EXEEXT): $(buffers_reference_counted_OBJECTS) $(buffers_reference_counted_DEPENDENCIES) $(EXTRA_buffers_reference_counted_DEPENDENCIES) buffers/$(am__dirstamp) + @rm -f buffers/reference_counted$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(buffers_reference_counted_OBJECTS) $(buffers_reference_counted_LDADD) $(LIBS) +chat/$(am__dirstamp): + @$(MKDIR_P) chat + @: > chat/$(am__dirstamp) +chat/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) chat/$(DEPDIR) + @: > chat/$(DEPDIR)/$(am__dirstamp) +chat/chat_client.$(OBJEXT): chat/$(am__dirstamp) \ + chat/$(DEPDIR)/$(am__dirstamp) + +chat/chat_client$(EXEEXT): $(chat_chat_client_OBJECTS) $(chat_chat_client_DEPENDENCIES) $(EXTRA_chat_chat_client_DEPENDENCIES) chat/$(am__dirstamp) + @rm -f chat/chat_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(chat_chat_client_OBJECTS) $(chat_chat_client_LDADD) $(LIBS) +chat/chat_server.$(OBJEXT): chat/$(am__dirstamp) \ + chat/$(DEPDIR)/$(am__dirstamp) + +chat/chat_server$(EXEEXT): $(chat_chat_server_OBJECTS) $(chat_chat_server_DEPENDENCIES) $(EXTRA_chat_chat_server_DEPENDENCIES) chat/$(am__dirstamp) + @rm -f chat/chat_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(chat_chat_server_OBJECTS) $(chat_chat_server_LDADD) $(LIBS) +chat/posix_chat_client.$(OBJEXT): chat/$(am__dirstamp) \ + chat/$(DEPDIR)/$(am__dirstamp) + +chat/posix_chat_client$(EXEEXT): $(chat_posix_chat_client_OBJECTS) $(chat_posix_chat_client_DEPENDENCIES) $(EXTRA_chat_posix_chat_client_DEPENDENCIES) chat/$(am__dirstamp) + @rm -f chat/posix_chat_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(chat_posix_chat_client_OBJECTS) $(chat_posix_chat_client_LDADD) $(LIBS) +deferred/$(am__dirstamp): + @$(MKDIR_P) deferred + @: > deferred/$(am__dirstamp) +deferred/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) deferred/$(DEPDIR) + @: > deferred/$(DEPDIR)/$(am__dirstamp) +deferred/deferred_1.$(OBJEXT): deferred/$(am__dirstamp) \ + deferred/$(DEPDIR)/$(am__dirstamp) + +deferred/deferred_1$(EXEEXT): $(deferred_deferred_1_OBJECTS) $(deferred_deferred_1_DEPENDENCIES) $(EXTRA_deferred_deferred_1_DEPENDENCIES) deferred/$(am__dirstamp) + @rm -f deferred/deferred_1$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(deferred_deferred_1_OBJECTS) $(deferred_deferred_1_LDADD) $(LIBS) +deferred/deferred_2.$(OBJEXT): deferred/$(am__dirstamp) \ + deferred/$(DEPDIR)/$(am__dirstamp) + +deferred/deferred_2$(EXEEXT): $(deferred_deferred_2_OBJECTS) $(deferred_deferred_2_DEPENDENCIES) $(EXTRA_deferred_deferred_2_DEPENDENCIES) deferred/$(am__dirstamp) + @rm -f deferred/deferred_2$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(deferred_deferred_2_OBJECTS) $(deferred_deferred_2_LDADD) $(LIBS) +echo/$(am__dirstamp): + @$(MKDIR_P) echo + @: > echo/$(am__dirstamp) +echo/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) echo/$(DEPDIR) + @: > echo/$(DEPDIR)/$(am__dirstamp) +echo/async_tcp_echo_server.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/async_tcp_echo_server$(EXEEXT): $(echo_async_tcp_echo_server_OBJECTS) $(echo_async_tcp_echo_server_DEPENDENCIES) $(EXTRA_echo_async_tcp_echo_server_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/async_tcp_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_async_tcp_echo_server_OBJECTS) $(echo_async_tcp_echo_server_LDADD) $(LIBS) +echo/async_udp_echo_server.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/async_udp_echo_server$(EXEEXT): $(echo_async_udp_echo_server_OBJECTS) $(echo_async_udp_echo_server_DEPENDENCIES) $(EXTRA_echo_async_udp_echo_server_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/async_udp_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_async_udp_echo_server_OBJECTS) $(echo_async_udp_echo_server_LDADD) $(LIBS) +echo/blocking_tcp_echo_client.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/blocking_tcp_echo_client$(EXEEXT): $(echo_blocking_tcp_echo_client_OBJECTS) $(echo_blocking_tcp_echo_client_DEPENDENCIES) $(EXTRA_echo_blocking_tcp_echo_client_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/blocking_tcp_echo_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_blocking_tcp_echo_client_OBJECTS) $(echo_blocking_tcp_echo_client_LDADD) $(LIBS) +echo/blocking_tcp_echo_server.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/blocking_tcp_echo_server$(EXEEXT): $(echo_blocking_tcp_echo_server_OBJECTS) $(echo_blocking_tcp_echo_server_DEPENDENCIES) $(EXTRA_echo_blocking_tcp_echo_server_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/blocking_tcp_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_blocking_tcp_echo_server_OBJECTS) $(echo_blocking_tcp_echo_server_LDADD) $(LIBS) +echo/blocking_udp_echo_client.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/blocking_udp_echo_client$(EXEEXT): $(echo_blocking_udp_echo_client_OBJECTS) $(echo_blocking_udp_echo_client_DEPENDENCIES) $(EXTRA_echo_blocking_udp_echo_client_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/blocking_udp_echo_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_blocking_udp_echo_client_OBJECTS) $(echo_blocking_udp_echo_client_LDADD) $(LIBS) +echo/blocking_udp_echo_server.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/blocking_udp_echo_server$(EXEEXT): $(echo_blocking_udp_echo_server_OBJECTS) $(echo_blocking_udp_echo_server_DEPENDENCIES) $(EXTRA_echo_blocking_udp_echo_server_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/blocking_udp_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_blocking_udp_echo_server_OBJECTS) $(echo_blocking_udp_echo_server_LDADD) $(LIBS) +executors/$(am__dirstamp): + @$(MKDIR_P) executors + @: > executors/$(am__dirstamp) +executors/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) executors/$(DEPDIR) + @: > executors/$(DEPDIR)/$(am__dirstamp) +executors/actor.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/actor$(EXEEXT): $(executors_actor_OBJECTS) $(executors_actor_DEPENDENCIES) $(EXTRA_executors_actor_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/actor$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_actor_OBJECTS) $(executors_actor_LDADD) $(LIBS) +executors/bank_account_1.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/bank_account_1$(EXEEXT): $(executors_bank_account_1_OBJECTS) $(executors_bank_account_1_DEPENDENCIES) $(EXTRA_executors_bank_account_1_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/bank_account_1$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_bank_account_1_OBJECTS) $(executors_bank_account_1_LDADD) $(LIBS) +executors/bank_account_2.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/bank_account_2$(EXEEXT): $(executors_bank_account_2_OBJECTS) $(executors_bank_account_2_DEPENDENCIES) $(EXTRA_executors_bank_account_2_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/bank_account_2$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_bank_account_2_OBJECTS) $(executors_bank_account_2_LDADD) $(LIBS) +executors/fork_join.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/fork_join$(EXEEXT): $(executors_fork_join_OBJECTS) $(executors_fork_join_DEPENDENCIES) $(EXTRA_executors_fork_join_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/fork_join$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_fork_join_OBJECTS) $(executors_fork_join_LDADD) $(LIBS) +executors/pipeline.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/pipeline$(EXEEXT): $(executors_pipeline_OBJECTS) $(executors_pipeline_DEPENDENCIES) $(EXTRA_executors_pipeline_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/pipeline$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_pipeline_OBJECTS) $(executors_pipeline_LDADD) $(LIBS) +executors/priority_scheduler.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/priority_scheduler$(EXEEXT): $(executors_priority_scheduler_OBJECTS) $(executors_priority_scheduler_DEPENDENCIES) $(EXTRA_executors_priority_scheduler_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/priority_scheduler$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_priority_scheduler_OBJECTS) $(executors_priority_scheduler_LDADD) $(LIBS) +files/$(am__dirstamp): + @$(MKDIR_P) files + @: > files/$(am__dirstamp) +files/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) files/$(DEPDIR) + @: > files/$(DEPDIR)/$(am__dirstamp) +files/async_file_copy.$(OBJEXT): files/$(am__dirstamp) \ + files/$(DEPDIR)/$(am__dirstamp) + +files/async_file_copy$(EXEEXT): $(files_async_file_copy_OBJECTS) $(files_async_file_copy_DEPENDENCIES) $(EXTRA_files_async_file_copy_DEPENDENCIES) files/$(am__dirstamp) + @rm -f files/async_file_copy$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(files_async_file_copy_OBJECTS) $(files_async_file_copy_LDADD) $(LIBS) +files/blocking_file_copy.$(OBJEXT): files/$(am__dirstamp) \ + files/$(DEPDIR)/$(am__dirstamp) + +files/blocking_file_copy$(EXEEXT): $(files_blocking_file_copy_OBJECTS) $(files_blocking_file_copy_DEPENDENCIES) $(EXTRA_files_blocking_file_copy_DEPENDENCIES) files/$(am__dirstamp) + @rm -f files/blocking_file_copy$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(files_blocking_file_copy_OBJECTS) $(files_blocking_file_copy_LDADD) $(LIBS) +fork/$(am__dirstamp): + @$(MKDIR_P) fork + @: > fork/$(am__dirstamp) +fork/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) fork/$(DEPDIR) + @: > fork/$(DEPDIR)/$(am__dirstamp) +fork/daemon.$(OBJEXT): fork/$(am__dirstamp) \ + fork/$(DEPDIR)/$(am__dirstamp) + +fork/daemon$(EXEEXT): $(fork_daemon_OBJECTS) $(fork_daemon_DEPENDENCIES) $(EXTRA_fork_daemon_DEPENDENCIES) fork/$(am__dirstamp) + @rm -f fork/daemon$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(fork_daemon_OBJECTS) $(fork_daemon_LDADD) $(LIBS) +fork/process_per_connection.$(OBJEXT): fork/$(am__dirstamp) \ + fork/$(DEPDIR)/$(am__dirstamp) + +fork/process_per_connection$(EXEEXT): $(fork_process_per_connection_OBJECTS) $(fork_process_per_connection_DEPENDENCIES) $(EXTRA_fork_process_per_connection_DEPENDENCIES) fork/$(am__dirstamp) + @rm -f fork/process_per_connection$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(fork_process_per_connection_OBJECTS) $(fork_process_per_connection_LDADD) $(LIBS) +futures/$(am__dirstamp): + @$(MKDIR_P) futures + @: > futures/$(am__dirstamp) +futures/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) futures/$(DEPDIR) + @: > futures/$(DEPDIR)/$(am__dirstamp) +futures/daytime_client.$(OBJEXT): futures/$(am__dirstamp) \ + futures/$(DEPDIR)/$(am__dirstamp) + +futures/daytime_client$(EXEEXT): $(futures_daytime_client_OBJECTS) $(futures_daytime_client_DEPENDENCIES) $(EXTRA_futures_daytime_client_DEPENDENCIES) futures/$(am__dirstamp) + @rm -f futures/daytime_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(futures_daytime_client_OBJECTS) $(futures_daytime_client_LDADD) $(LIBS) +handler_tracking/$(am__dirstamp): + @$(MKDIR_P) handler_tracking + @: > handler_tracking/$(am__dirstamp) +handler_tracking/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) handler_tracking/$(DEPDIR) + @: > handler_tracking/$(DEPDIR)/$(am__dirstamp) +handler_tracking/async_tcp_echo_server.$(OBJEXT): \ + handler_tracking/$(am__dirstamp) \ + handler_tracking/$(DEPDIR)/$(am__dirstamp) + +handler_tracking/async_tcp_echo_server$(EXEEXT): $(handler_tracking_async_tcp_echo_server_OBJECTS) $(handler_tracking_async_tcp_echo_server_DEPENDENCIES) $(EXTRA_handler_tracking_async_tcp_echo_server_DEPENDENCIES) handler_tracking/$(am__dirstamp) + @rm -f handler_tracking/async_tcp_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(handler_tracking_async_tcp_echo_server_OBJECTS) $(handler_tracking_async_tcp_echo_server_LDADD) $(LIBS) +http/client/$(am__dirstamp): + @$(MKDIR_P) http/client + @: > http/client/$(am__dirstamp) +http/client/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) http/client/$(DEPDIR) + @: > http/client/$(DEPDIR)/$(am__dirstamp) +http/client/async_client.$(OBJEXT): http/client/$(am__dirstamp) \ + http/client/$(DEPDIR)/$(am__dirstamp) + +http/client/async_client$(EXEEXT): $(http_client_async_client_OBJECTS) $(http_client_async_client_DEPENDENCIES) $(EXTRA_http_client_async_client_DEPENDENCIES) http/client/$(am__dirstamp) + @rm -f http/client/async_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(http_client_async_client_OBJECTS) $(http_client_async_client_LDADD) $(LIBS) +http/client/sync_client.$(OBJEXT): http/client/$(am__dirstamp) \ + http/client/$(DEPDIR)/$(am__dirstamp) + +http/client/sync_client$(EXEEXT): $(http_client_sync_client_OBJECTS) $(http_client_sync_client_DEPENDENCIES) $(EXTRA_http_client_sync_client_DEPENDENCIES) http/client/$(am__dirstamp) + @rm -f http/client/sync_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(http_client_sync_client_OBJECTS) $(http_client_sync_client_LDADD) $(LIBS) +http/server/$(am__dirstamp): + @$(MKDIR_P) http/server + @: > http/server/$(am__dirstamp) +http/server/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) http/server/$(DEPDIR) + @: > http/server/$(DEPDIR)/$(am__dirstamp) +http/server/connection.$(OBJEXT): http/server/$(am__dirstamp) \ + http/server/$(DEPDIR)/$(am__dirstamp) +http/server/connection_manager.$(OBJEXT): http/server/$(am__dirstamp) \ + http/server/$(DEPDIR)/$(am__dirstamp) +http/server/main.$(OBJEXT): http/server/$(am__dirstamp) \ + http/server/$(DEPDIR)/$(am__dirstamp) +http/server/mime_types.$(OBJEXT): http/server/$(am__dirstamp) \ + http/server/$(DEPDIR)/$(am__dirstamp) +http/server/reply.$(OBJEXT): http/server/$(am__dirstamp) \ + http/server/$(DEPDIR)/$(am__dirstamp) +http/server/request_handler.$(OBJEXT): http/server/$(am__dirstamp) \ + http/server/$(DEPDIR)/$(am__dirstamp) +http/server/request_parser.$(OBJEXT): http/server/$(am__dirstamp) \ + http/server/$(DEPDIR)/$(am__dirstamp) +http/server/server.$(OBJEXT): http/server/$(am__dirstamp) \ + http/server/$(DEPDIR)/$(am__dirstamp) + +http/server/http_server$(EXEEXT): $(http_server_http_server_OBJECTS) $(http_server_http_server_DEPENDENCIES) $(EXTRA_http_server_http_server_DEPENDENCIES) http/server/$(am__dirstamp) + @rm -f http/server/http_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(http_server_http_server_OBJECTS) $(http_server_http_server_LDADD) $(LIBS) +http/server2/$(am__dirstamp): + @$(MKDIR_P) http/server2 + @: > http/server2/$(am__dirstamp) +http/server2/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) http/server2/$(DEPDIR) + @: > http/server2/$(DEPDIR)/$(am__dirstamp) +http/server2/connection.$(OBJEXT): http/server2/$(am__dirstamp) \ + http/server2/$(DEPDIR)/$(am__dirstamp) +http/server2/io_context_pool.$(OBJEXT): http/server2/$(am__dirstamp) \ + http/server2/$(DEPDIR)/$(am__dirstamp) +http/server2/main.$(OBJEXT): http/server2/$(am__dirstamp) \ + http/server2/$(DEPDIR)/$(am__dirstamp) +http/server2/mime_types.$(OBJEXT): http/server2/$(am__dirstamp) \ + http/server2/$(DEPDIR)/$(am__dirstamp) +http/server2/reply.$(OBJEXT): http/server2/$(am__dirstamp) \ + http/server2/$(DEPDIR)/$(am__dirstamp) +http/server2/request_handler.$(OBJEXT): http/server2/$(am__dirstamp) \ + http/server2/$(DEPDIR)/$(am__dirstamp) +http/server2/request_parser.$(OBJEXT): http/server2/$(am__dirstamp) \ + http/server2/$(DEPDIR)/$(am__dirstamp) +http/server2/server.$(OBJEXT): http/server2/$(am__dirstamp) \ + http/server2/$(DEPDIR)/$(am__dirstamp) + +http/server2/http_server$(EXEEXT): $(http_server2_http_server_OBJECTS) $(http_server2_http_server_DEPENDENCIES) $(EXTRA_http_server2_http_server_DEPENDENCIES) http/server2/$(am__dirstamp) + @rm -f http/server2/http_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(http_server2_http_server_OBJECTS) $(http_server2_http_server_LDADD) $(LIBS) +http/server3/$(am__dirstamp): + @$(MKDIR_P) http/server3 + @: > http/server3/$(am__dirstamp) +http/server3/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) http/server3/$(DEPDIR) + @: > http/server3/$(DEPDIR)/$(am__dirstamp) +http/server3/connection.$(OBJEXT): http/server3/$(am__dirstamp) \ + http/server3/$(DEPDIR)/$(am__dirstamp) +http/server3/main.$(OBJEXT): http/server3/$(am__dirstamp) \ + http/server3/$(DEPDIR)/$(am__dirstamp) +http/server3/mime_types.$(OBJEXT): http/server3/$(am__dirstamp) \ + http/server3/$(DEPDIR)/$(am__dirstamp) +http/server3/reply.$(OBJEXT): http/server3/$(am__dirstamp) \ + http/server3/$(DEPDIR)/$(am__dirstamp) +http/server3/request_handler.$(OBJEXT): http/server3/$(am__dirstamp) \ + http/server3/$(DEPDIR)/$(am__dirstamp) +http/server3/request_parser.$(OBJEXT): http/server3/$(am__dirstamp) \ + http/server3/$(DEPDIR)/$(am__dirstamp) +http/server3/server.$(OBJEXT): http/server3/$(am__dirstamp) \ + http/server3/$(DEPDIR)/$(am__dirstamp) + +http/server3/http_server$(EXEEXT): $(http_server3_http_server_OBJECTS) $(http_server3_http_server_DEPENDENCIES) $(EXTRA_http_server3_http_server_DEPENDENCIES) http/server3/$(am__dirstamp) + @rm -f http/server3/http_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(http_server3_http_server_OBJECTS) $(http_server3_http_server_LDADD) $(LIBS) +http/server4/$(am__dirstamp): + @$(MKDIR_P) http/server4 + @: > http/server4/$(am__dirstamp) +http/server4/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) http/server4/$(DEPDIR) + @: > http/server4/$(DEPDIR)/$(am__dirstamp) +http/server4/file_handler.$(OBJEXT): http/server4/$(am__dirstamp) \ + http/server4/$(DEPDIR)/$(am__dirstamp) +http/server4/main.$(OBJEXT): http/server4/$(am__dirstamp) \ + http/server4/$(DEPDIR)/$(am__dirstamp) +http/server4/mime_types.$(OBJEXT): http/server4/$(am__dirstamp) \ + http/server4/$(DEPDIR)/$(am__dirstamp) +http/server4/reply.$(OBJEXT): http/server4/$(am__dirstamp) \ + http/server4/$(DEPDIR)/$(am__dirstamp) +http/server4/request_parser.$(OBJEXT): http/server4/$(am__dirstamp) \ + http/server4/$(DEPDIR)/$(am__dirstamp) +http/server4/server.$(OBJEXT): http/server4/$(am__dirstamp) \ + http/server4/$(DEPDIR)/$(am__dirstamp) + +http/server4/http_server$(EXEEXT): $(http_server4_http_server_OBJECTS) $(http_server4_http_server_DEPENDENCIES) $(EXTRA_http_server4_http_server_DEPENDENCIES) http/server4/$(am__dirstamp) + @rm -f http/server4/http_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(http_server4_http_server_OBJECTS) $(http_server4_http_server_LDADD) $(LIBS) +icmp/$(am__dirstamp): + @$(MKDIR_P) icmp + @: > icmp/$(am__dirstamp) +icmp/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) icmp/$(DEPDIR) + @: > icmp/$(DEPDIR)/$(am__dirstamp) +icmp/ping.$(OBJEXT): icmp/$(am__dirstamp) \ + icmp/$(DEPDIR)/$(am__dirstamp) + +icmp/ping$(EXEEXT): $(icmp_ping_OBJECTS) $(icmp_ping_DEPENDENCIES) $(EXTRA_icmp_ping_DEPENDENCIES) icmp/$(am__dirstamp) + @rm -f icmp/ping$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(icmp_ping_OBJECTS) $(icmp_ping_LDADD) $(LIBS) +invocation/$(am__dirstamp): + @$(MKDIR_P) invocation + @: > invocation/$(am__dirstamp) +invocation/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) invocation/$(DEPDIR) + @: > invocation/$(DEPDIR)/$(am__dirstamp) +invocation/prioritised_handlers.$(OBJEXT): invocation/$(am__dirstamp) \ + invocation/$(DEPDIR)/$(am__dirstamp) + +invocation/prioritised_handlers$(EXEEXT): $(invocation_prioritised_handlers_OBJECTS) $(invocation_prioritised_handlers_DEPENDENCIES) $(EXTRA_invocation_prioritised_handlers_DEPENDENCIES) invocation/$(am__dirstamp) + @rm -f invocation/prioritised_handlers$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(invocation_prioritised_handlers_OBJECTS) $(invocation_prioritised_handlers_LDADD) $(LIBS) +iostreams/$(am__dirstamp): + @$(MKDIR_P) iostreams + @: > iostreams/$(am__dirstamp) +iostreams/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) iostreams/$(DEPDIR) + @: > iostreams/$(DEPDIR)/$(am__dirstamp) +iostreams/daytime_client.$(OBJEXT): iostreams/$(am__dirstamp) \ + iostreams/$(DEPDIR)/$(am__dirstamp) + +iostreams/daytime_client$(EXEEXT): $(iostreams_daytime_client_OBJECTS) $(iostreams_daytime_client_DEPENDENCIES) $(EXTRA_iostreams_daytime_client_DEPENDENCIES) iostreams/$(am__dirstamp) + @rm -f iostreams/daytime_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(iostreams_daytime_client_OBJECTS) $(iostreams_daytime_client_LDADD) $(LIBS) +iostreams/daytime_server.$(OBJEXT): iostreams/$(am__dirstamp) \ + iostreams/$(DEPDIR)/$(am__dirstamp) + +iostreams/daytime_server$(EXEEXT): $(iostreams_daytime_server_OBJECTS) $(iostreams_daytime_server_DEPENDENCIES) $(EXTRA_iostreams_daytime_server_DEPENDENCIES) iostreams/$(am__dirstamp) + @rm -f iostreams/daytime_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(iostreams_daytime_server_OBJECTS) $(iostreams_daytime_server_LDADD) $(LIBS) +iostreams/http_client.$(OBJEXT): iostreams/$(am__dirstamp) \ + iostreams/$(DEPDIR)/$(am__dirstamp) + +iostreams/http_client$(EXEEXT): $(iostreams_http_client_OBJECTS) $(iostreams_http_client_DEPENDENCIES) $(EXTRA_iostreams_http_client_DEPENDENCIES) iostreams/$(am__dirstamp) + @rm -f iostreams/http_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(iostreams_http_client_OBJECTS) $(iostreams_http_client_LDADD) $(LIBS) +local/$(am__dirstamp): + @$(MKDIR_P) local + @: > local/$(am__dirstamp) +local/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) local/$(DEPDIR) + @: > local/$(DEPDIR)/$(am__dirstamp) +local/connect_pair.$(OBJEXT): local/$(am__dirstamp) \ + local/$(DEPDIR)/$(am__dirstamp) + +local/connect_pair$(EXEEXT): $(local_connect_pair_OBJECTS) $(local_connect_pair_DEPENDENCIES) $(EXTRA_local_connect_pair_DEPENDENCIES) local/$(am__dirstamp) + @rm -f local/connect_pair$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(local_connect_pair_OBJECTS) $(local_connect_pair_LDADD) $(LIBS) +local/fd_passing_stream_client.$(OBJEXT): local/$(am__dirstamp) \ + local/$(DEPDIR)/$(am__dirstamp) + +local/fd_passing_stream_client$(EXEEXT): $(local_fd_passing_stream_client_OBJECTS) $(local_fd_passing_stream_client_DEPENDENCIES) $(EXTRA_local_fd_passing_stream_client_DEPENDENCIES) local/$(am__dirstamp) + @rm -f local/fd_passing_stream_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(local_fd_passing_stream_client_OBJECTS) $(local_fd_passing_stream_client_LDADD) $(LIBS) +local/fd_passing_stream_server.$(OBJEXT): local/$(am__dirstamp) \ + local/$(DEPDIR)/$(am__dirstamp) + +local/fd_passing_stream_server$(EXEEXT): $(local_fd_passing_stream_server_OBJECTS) $(local_fd_passing_stream_server_DEPENDENCIES) $(EXTRA_local_fd_passing_stream_server_DEPENDENCIES) local/$(am__dirstamp) + @rm -f local/fd_passing_stream_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(local_fd_passing_stream_server_OBJECTS) $(local_fd_passing_stream_server_LDADD) $(LIBS) +local/iostream_client.$(OBJEXT): local/$(am__dirstamp) \ + local/$(DEPDIR)/$(am__dirstamp) + +local/iostream_client$(EXEEXT): $(local_iostream_client_OBJECTS) $(local_iostream_client_DEPENDENCIES) $(EXTRA_local_iostream_client_DEPENDENCIES) local/$(am__dirstamp) + @rm -f local/iostream_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(local_iostream_client_OBJECTS) $(local_iostream_client_LDADD) $(LIBS) +local/stream_client.$(OBJEXT): local/$(am__dirstamp) \ + local/$(DEPDIR)/$(am__dirstamp) + +local/stream_client$(EXEEXT): $(local_stream_client_OBJECTS) $(local_stream_client_DEPENDENCIES) $(EXTRA_local_stream_client_DEPENDENCIES) local/$(am__dirstamp) + @rm -f local/stream_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(local_stream_client_OBJECTS) $(local_stream_client_LDADD) $(LIBS) +local/stream_server.$(OBJEXT): local/$(am__dirstamp) \ + local/$(DEPDIR)/$(am__dirstamp) + +local/stream_server$(EXEEXT): $(local_stream_server_OBJECTS) $(local_stream_server_DEPENDENCIES) $(EXTRA_local_stream_server_DEPENDENCIES) local/$(am__dirstamp) + @rm -f local/stream_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(local_stream_server_OBJECTS) $(local_stream_server_LDADD) $(LIBS) +multicast/$(am__dirstamp): + @$(MKDIR_P) multicast + @: > multicast/$(am__dirstamp) +multicast/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) multicast/$(DEPDIR) + @: > multicast/$(DEPDIR)/$(am__dirstamp) +multicast/receiver.$(OBJEXT): multicast/$(am__dirstamp) \ + multicast/$(DEPDIR)/$(am__dirstamp) + +multicast/receiver$(EXEEXT): $(multicast_receiver_OBJECTS) $(multicast_receiver_DEPENDENCIES) $(EXTRA_multicast_receiver_DEPENDENCIES) multicast/$(am__dirstamp) + @rm -f multicast/receiver$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(multicast_receiver_OBJECTS) $(multicast_receiver_LDADD) $(LIBS) +multicast/sender.$(OBJEXT): multicast/$(am__dirstamp) \ + multicast/$(DEPDIR)/$(am__dirstamp) + +multicast/sender$(EXEEXT): $(multicast_sender_OBJECTS) $(multicast_sender_DEPENDENCIES) $(EXTRA_multicast_sender_DEPENDENCIES) multicast/$(am__dirstamp) + @rm -f multicast/sender$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(multicast_sender_OBJECTS) $(multicast_sender_LDADD) $(LIBS) +nonblocking/$(am__dirstamp): + @$(MKDIR_P) nonblocking + @: > nonblocking/$(am__dirstamp) +nonblocking/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) nonblocking/$(DEPDIR) + @: > nonblocking/$(DEPDIR)/$(am__dirstamp) +nonblocking/third_party_lib.$(OBJEXT): nonblocking/$(am__dirstamp) \ + nonblocking/$(DEPDIR)/$(am__dirstamp) + +nonblocking/third_party_lib$(EXEEXT): $(nonblocking_third_party_lib_OBJECTS) $(nonblocking_third_party_lib_DEPENDENCIES) $(EXTRA_nonblocking_third_party_lib_DEPENDENCIES) nonblocking/$(am__dirstamp) + @rm -f nonblocking/third_party_lib$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(nonblocking_third_party_lib_OBJECTS) $(nonblocking_third_party_lib_LDADD) $(LIBS) +operations/$(am__dirstamp): + @$(MKDIR_P) operations + @: > operations/$(am__dirstamp) +operations/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) operations/$(DEPDIR) + @: > operations/$(DEPDIR)/$(am__dirstamp) +operations/composed_1.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_1$(EXEEXT): $(operations_composed_1_OBJECTS) $(operations_composed_1_DEPENDENCIES) $(EXTRA_operations_composed_1_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_1$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_1_OBJECTS) $(operations_composed_1_LDADD) $(LIBS) +operations/composed_2.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_2$(EXEEXT): $(operations_composed_2_OBJECTS) $(operations_composed_2_DEPENDENCIES) $(EXTRA_operations_composed_2_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_2$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_2_OBJECTS) $(operations_composed_2_LDADD) $(LIBS) +operations/composed_3.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_3$(EXEEXT): $(operations_composed_3_OBJECTS) $(operations_composed_3_DEPENDENCIES) $(EXTRA_operations_composed_3_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_3$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_3_OBJECTS) $(operations_composed_3_LDADD) $(LIBS) +operations/composed_4.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_4$(EXEEXT): $(operations_composed_4_OBJECTS) $(operations_composed_4_DEPENDENCIES) $(EXTRA_operations_composed_4_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_4$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_4_OBJECTS) $(operations_composed_4_LDADD) $(LIBS) +operations/composed_5.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_5$(EXEEXT): $(operations_composed_5_OBJECTS) $(operations_composed_5_DEPENDENCIES) $(EXTRA_operations_composed_5_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_5$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_5_OBJECTS) $(operations_composed_5_LDADD) $(LIBS) +operations/composed_6.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_6$(EXEEXT): $(operations_composed_6_OBJECTS) $(operations_composed_6_DEPENDENCIES) $(EXTRA_operations_composed_6_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_6$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_6_OBJECTS) $(operations_composed_6_LDADD) $(LIBS) +operations/composed_7.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_7$(EXEEXT): $(operations_composed_7_OBJECTS) $(operations_composed_7_DEPENDENCIES) $(EXTRA_operations_composed_7_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_7$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_7_OBJECTS) $(operations_composed_7_LDADD) $(LIBS) +operations/composed_8.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_8$(EXEEXT): $(operations_composed_8_OBJECTS) $(operations_composed_8_DEPENDENCIES) $(EXTRA_operations_composed_8_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_8$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_8_OBJECTS) $(operations_composed_8_LDADD) $(LIBS) +parallel_group/$(am__dirstamp): + @$(MKDIR_P) parallel_group + @: > parallel_group/$(am__dirstamp) +parallel_group/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) parallel_group/$(DEPDIR) + @: > parallel_group/$(DEPDIR)/$(am__dirstamp) +parallel_group/ranged_wait_for_all.$(OBJEXT): \ + parallel_group/$(am__dirstamp) \ + parallel_group/$(DEPDIR)/$(am__dirstamp) + +parallel_group/ranged_wait_for_all$(EXEEXT): $(parallel_group_ranged_wait_for_all_OBJECTS) $(parallel_group_ranged_wait_for_all_DEPENDENCIES) $(EXTRA_parallel_group_ranged_wait_for_all_DEPENDENCIES) parallel_group/$(am__dirstamp) + @rm -f parallel_group/ranged_wait_for_all$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(parallel_group_ranged_wait_for_all_OBJECTS) $(parallel_group_ranged_wait_for_all_LDADD) $(LIBS) +parallel_group/wait_for_all.$(OBJEXT): parallel_group/$(am__dirstamp) \ + parallel_group/$(DEPDIR)/$(am__dirstamp) + +parallel_group/wait_for_all$(EXEEXT): $(parallel_group_wait_for_all_OBJECTS) $(parallel_group_wait_for_all_DEPENDENCIES) $(EXTRA_parallel_group_wait_for_all_DEPENDENCIES) parallel_group/$(am__dirstamp) + @rm -f parallel_group/wait_for_all$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(parallel_group_wait_for_all_OBJECTS) $(parallel_group_wait_for_all_LDADD) $(LIBS) +parallel_group/wait_for_one.$(OBJEXT): parallel_group/$(am__dirstamp) \ + parallel_group/$(DEPDIR)/$(am__dirstamp) + +parallel_group/wait_for_one$(EXEEXT): $(parallel_group_wait_for_one_OBJECTS) $(parallel_group_wait_for_one_DEPENDENCIES) $(EXTRA_parallel_group_wait_for_one_DEPENDENCIES) parallel_group/$(am__dirstamp) + @rm -f parallel_group/wait_for_one$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(parallel_group_wait_for_one_OBJECTS) $(parallel_group_wait_for_one_LDADD) $(LIBS) +parallel_group/wait_for_one_error.$(OBJEXT): \ + parallel_group/$(am__dirstamp) \ + parallel_group/$(DEPDIR)/$(am__dirstamp) + +parallel_group/wait_for_one_error$(EXEEXT): $(parallel_group_wait_for_one_error_OBJECTS) $(parallel_group_wait_for_one_error_DEPENDENCIES) $(EXTRA_parallel_group_wait_for_one_error_DEPENDENCIES) parallel_group/$(am__dirstamp) + @rm -f parallel_group/wait_for_one_error$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(parallel_group_wait_for_one_error_OBJECTS) $(parallel_group_wait_for_one_error_LDADD) $(LIBS) +parallel_group/wait_for_one_success.$(OBJEXT): \ + parallel_group/$(am__dirstamp) \ + parallel_group/$(DEPDIR)/$(am__dirstamp) + +parallel_group/wait_for_one_success$(EXEEXT): $(parallel_group_wait_for_one_success_OBJECTS) $(parallel_group_wait_for_one_success_DEPENDENCIES) $(EXTRA_parallel_group_wait_for_one_success_DEPENDENCIES) parallel_group/$(am__dirstamp) + @rm -f parallel_group/wait_for_one_success$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(parallel_group_wait_for_one_success_OBJECTS) $(parallel_group_wait_for_one_success_LDADD) $(LIBS) +porthopper/$(am__dirstamp): + @$(MKDIR_P) porthopper + @: > porthopper/$(am__dirstamp) +porthopper/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) porthopper/$(DEPDIR) + @: > porthopper/$(DEPDIR)/$(am__dirstamp) +porthopper/client.$(OBJEXT): porthopper/$(am__dirstamp) \ + porthopper/$(DEPDIR)/$(am__dirstamp) + +porthopper/client$(EXEEXT): $(porthopper_client_OBJECTS) $(porthopper_client_DEPENDENCIES) $(EXTRA_porthopper_client_DEPENDENCIES) porthopper/$(am__dirstamp) + @rm -f porthopper/client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(porthopper_client_OBJECTS) $(porthopper_client_LDADD) $(LIBS) +porthopper/server.$(OBJEXT): porthopper/$(am__dirstamp) \ + porthopper/$(DEPDIR)/$(am__dirstamp) + +porthopper/server$(EXEEXT): $(porthopper_server_OBJECTS) $(porthopper_server_DEPENDENCIES) $(EXTRA_porthopper_server_DEPENDENCIES) porthopper/$(am__dirstamp) + @rm -f porthopper/server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(porthopper_server_OBJECTS) $(porthopper_server_LDADD) $(LIBS) +services/$(am__dirstamp): + @$(MKDIR_P) services + @: > services/$(am__dirstamp) +services/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) services/$(DEPDIR) + @: > services/$(DEPDIR)/$(am__dirstamp) +services/daytime_client.$(OBJEXT): services/$(am__dirstamp) \ + services/$(DEPDIR)/$(am__dirstamp) +services/logger_service.$(OBJEXT): services/$(am__dirstamp) \ + services/$(DEPDIR)/$(am__dirstamp) + +services/daytime_client$(EXEEXT): $(services_daytime_client_OBJECTS) $(services_daytime_client_DEPENDENCIES) $(EXTRA_services_daytime_client_DEPENDENCIES) services/$(am__dirstamp) + @rm -f services/daytime_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(services_daytime_client_OBJECTS) $(services_daytime_client_LDADD) $(LIBS) +socks4/$(am__dirstamp): + @$(MKDIR_P) socks4 + @: > socks4/$(am__dirstamp) +socks4/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) socks4/$(DEPDIR) + @: > socks4/$(DEPDIR)/$(am__dirstamp) +socks4/sync_client.$(OBJEXT): socks4/$(am__dirstamp) \ + socks4/$(DEPDIR)/$(am__dirstamp) + +socks4/sync_client$(EXEEXT): $(socks4_sync_client_OBJECTS) $(socks4_sync_client_DEPENDENCIES) $(EXTRA_socks4_sync_client_DEPENDENCIES) socks4/$(am__dirstamp) + @rm -f socks4/sync_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(socks4_sync_client_OBJECTS) $(socks4_sync_client_LDADD) $(LIBS) +spawn/$(am__dirstamp): + @$(MKDIR_P) spawn + @: > spawn/$(am__dirstamp) +spawn/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) spawn/$(DEPDIR) + @: > spawn/$(DEPDIR)/$(am__dirstamp) +spawn/echo_server.$(OBJEXT): spawn/$(am__dirstamp) \ + spawn/$(DEPDIR)/$(am__dirstamp) + +spawn/echo_server$(EXEEXT): $(spawn_echo_server_OBJECTS) $(spawn_echo_server_DEPENDENCIES) $(EXTRA_spawn_echo_server_DEPENDENCIES) spawn/$(am__dirstamp) + @rm -f spawn/echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(spawn_echo_server_OBJECTS) $(spawn_echo_server_LDADD) $(LIBS) +spawn/parallel_grep.$(OBJEXT): spawn/$(am__dirstamp) \ + spawn/$(DEPDIR)/$(am__dirstamp) + +spawn/parallel_grep$(EXEEXT): $(spawn_parallel_grep_OBJECTS) $(spawn_parallel_grep_DEPENDENCIES) $(EXTRA_spawn_parallel_grep_DEPENDENCIES) spawn/$(am__dirstamp) + @rm -f spawn/parallel_grep$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(spawn_parallel_grep_OBJECTS) $(spawn_parallel_grep_LDADD) $(LIBS) +ssl/$(am__dirstamp): + @$(MKDIR_P) ssl + @: > ssl/$(am__dirstamp) +ssl/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) ssl/$(DEPDIR) + @: > ssl/$(DEPDIR)/$(am__dirstamp) +ssl/client.$(OBJEXT): ssl/$(am__dirstamp) \ + ssl/$(DEPDIR)/$(am__dirstamp) + +ssl/client$(EXEEXT): $(ssl_client_OBJECTS) $(ssl_client_DEPENDENCIES) $(EXTRA_ssl_client_DEPENDENCIES) ssl/$(am__dirstamp) + @rm -f ssl/client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(ssl_client_OBJECTS) $(ssl_client_LDADD) $(LIBS) +ssl/server.$(OBJEXT): ssl/$(am__dirstamp) \ + ssl/$(DEPDIR)/$(am__dirstamp) + +ssl/server$(EXEEXT): $(ssl_server_OBJECTS) $(ssl_server_DEPENDENCIES) $(EXTRA_ssl_server_DEPENDENCIES) ssl/$(am__dirstamp) + @rm -f ssl/server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(ssl_server_OBJECTS) $(ssl_server_LDADD) $(LIBS) +timeouts/$(am__dirstamp): + @$(MKDIR_P) timeouts + @: > timeouts/$(am__dirstamp) +timeouts/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) timeouts/$(DEPDIR) + @: > timeouts/$(DEPDIR)/$(am__dirstamp) +timeouts/async_tcp_client.$(OBJEXT): timeouts/$(am__dirstamp) \ + timeouts/$(DEPDIR)/$(am__dirstamp) + +timeouts/async_tcp_client$(EXEEXT): $(timeouts_async_tcp_client_OBJECTS) $(timeouts_async_tcp_client_DEPENDENCIES) $(EXTRA_timeouts_async_tcp_client_DEPENDENCIES) timeouts/$(am__dirstamp) + @rm -f timeouts/async_tcp_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(timeouts_async_tcp_client_OBJECTS) $(timeouts_async_tcp_client_LDADD) $(LIBS) +timeouts/blocking_tcp_client.$(OBJEXT): timeouts/$(am__dirstamp) \ + timeouts/$(DEPDIR)/$(am__dirstamp) + +timeouts/blocking_tcp_client$(EXEEXT): $(timeouts_blocking_tcp_client_OBJECTS) $(timeouts_blocking_tcp_client_DEPENDENCIES) $(EXTRA_timeouts_blocking_tcp_client_DEPENDENCIES) timeouts/$(am__dirstamp) + @rm -f timeouts/blocking_tcp_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(timeouts_blocking_tcp_client_OBJECTS) $(timeouts_blocking_tcp_client_LDADD) $(LIBS) +timeouts/blocking_token_tcp_client.$(OBJEXT): \ + timeouts/$(am__dirstamp) timeouts/$(DEPDIR)/$(am__dirstamp) + +timeouts/blocking_token_tcp_client$(EXEEXT): $(timeouts_blocking_token_tcp_client_OBJECTS) $(timeouts_blocking_token_tcp_client_DEPENDENCIES) $(EXTRA_timeouts_blocking_token_tcp_client_DEPENDENCIES) timeouts/$(am__dirstamp) + @rm -f timeouts/blocking_token_tcp_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(timeouts_blocking_token_tcp_client_OBJECTS) $(timeouts_blocking_token_tcp_client_LDADD) $(LIBS) +timeouts/blocking_udp_client.$(OBJEXT): timeouts/$(am__dirstamp) \ + timeouts/$(DEPDIR)/$(am__dirstamp) + +timeouts/blocking_udp_client$(EXEEXT): $(timeouts_blocking_udp_client_OBJECTS) $(timeouts_blocking_udp_client_DEPENDENCIES) $(EXTRA_timeouts_blocking_udp_client_DEPENDENCIES) timeouts/$(am__dirstamp) + @rm -f timeouts/blocking_udp_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(timeouts_blocking_udp_client_OBJECTS) $(timeouts_blocking_udp_client_LDADD) $(LIBS) +timeouts/server.$(OBJEXT): timeouts/$(am__dirstamp) \ + timeouts/$(DEPDIR)/$(am__dirstamp) + +timeouts/server$(EXEEXT): $(timeouts_server_OBJECTS) $(timeouts_server_DEPENDENCIES) $(EXTRA_timeouts_server_DEPENDENCIES) timeouts/$(am__dirstamp) + @rm -f timeouts/server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(timeouts_server_OBJECTS) $(timeouts_server_LDADD) $(LIBS) +timers/$(am__dirstamp): + @$(MKDIR_P) timers + @: > timers/$(am__dirstamp) +timers/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) timers/$(DEPDIR) + @: > timers/$(DEPDIR)/$(am__dirstamp) +timers/time_t_timer.$(OBJEXT): timers/$(am__dirstamp) \ + timers/$(DEPDIR)/$(am__dirstamp) + +timers/time_t_timer$(EXEEXT): $(timers_time_t_timer_OBJECTS) $(timers_time_t_timer_DEPENDENCIES) $(EXTRA_timers_time_t_timer_DEPENDENCIES) timers/$(am__dirstamp) + @rm -f timers/time_t_timer$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(timers_time_t_timer_OBJECTS) $(timers_time_t_timer_LDADD) $(LIBS) +tutorial/daytime1/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime1 + @: > tutorial/daytime1/$(am__dirstamp) +tutorial/daytime1/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime1/$(DEPDIR) + @: > tutorial/daytime1/$(DEPDIR)/$(am__dirstamp) +tutorial/daytime1/client.$(OBJEXT): tutorial/daytime1/$(am__dirstamp) \ + tutorial/daytime1/$(DEPDIR)/$(am__dirstamp) + +tutorial/daytime1/client$(EXEEXT): $(tutorial_daytime1_client_OBJECTS) $(tutorial_daytime1_client_DEPENDENCIES) $(EXTRA_tutorial_daytime1_client_DEPENDENCIES) tutorial/daytime1/$(am__dirstamp) + @rm -f tutorial/daytime1/client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_daytime1_client_OBJECTS) $(tutorial_daytime1_client_LDADD) $(LIBS) +tutorial/daytime2/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime2 + @: > tutorial/daytime2/$(am__dirstamp) +tutorial/daytime2/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime2/$(DEPDIR) + @: > tutorial/daytime2/$(DEPDIR)/$(am__dirstamp) +tutorial/daytime2/server.$(OBJEXT): tutorial/daytime2/$(am__dirstamp) \ + tutorial/daytime2/$(DEPDIR)/$(am__dirstamp) + +tutorial/daytime2/server$(EXEEXT): $(tutorial_daytime2_server_OBJECTS) $(tutorial_daytime2_server_DEPENDENCIES) $(EXTRA_tutorial_daytime2_server_DEPENDENCIES) tutorial/daytime2/$(am__dirstamp) + @rm -f tutorial/daytime2/server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_daytime2_server_OBJECTS) $(tutorial_daytime2_server_LDADD) $(LIBS) +tutorial/daytime3/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime3 + @: > tutorial/daytime3/$(am__dirstamp) +tutorial/daytime3/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime3/$(DEPDIR) + @: > tutorial/daytime3/$(DEPDIR)/$(am__dirstamp) +tutorial/daytime3/server.$(OBJEXT): tutorial/daytime3/$(am__dirstamp) \ + tutorial/daytime3/$(DEPDIR)/$(am__dirstamp) + +tutorial/daytime3/server$(EXEEXT): $(tutorial_daytime3_server_OBJECTS) $(tutorial_daytime3_server_DEPENDENCIES) $(EXTRA_tutorial_daytime3_server_DEPENDENCIES) tutorial/daytime3/$(am__dirstamp) + @rm -f tutorial/daytime3/server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_daytime3_server_OBJECTS) $(tutorial_daytime3_server_LDADD) $(LIBS) +tutorial/daytime4/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime4 + @: > tutorial/daytime4/$(am__dirstamp) +tutorial/daytime4/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime4/$(DEPDIR) + @: > tutorial/daytime4/$(DEPDIR)/$(am__dirstamp) +tutorial/daytime4/client.$(OBJEXT): tutorial/daytime4/$(am__dirstamp) \ + tutorial/daytime4/$(DEPDIR)/$(am__dirstamp) + +tutorial/daytime4/client$(EXEEXT): $(tutorial_daytime4_client_OBJECTS) $(tutorial_daytime4_client_DEPENDENCIES) $(EXTRA_tutorial_daytime4_client_DEPENDENCIES) tutorial/daytime4/$(am__dirstamp) + @rm -f tutorial/daytime4/client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_daytime4_client_OBJECTS) $(tutorial_daytime4_client_LDADD) $(LIBS) +tutorial/daytime5/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime5 + @: > tutorial/daytime5/$(am__dirstamp) +tutorial/daytime5/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime5/$(DEPDIR) + @: > tutorial/daytime5/$(DEPDIR)/$(am__dirstamp) +tutorial/daytime5/server.$(OBJEXT): tutorial/daytime5/$(am__dirstamp) \ + tutorial/daytime5/$(DEPDIR)/$(am__dirstamp) + +tutorial/daytime5/server$(EXEEXT): $(tutorial_daytime5_server_OBJECTS) $(tutorial_daytime5_server_DEPENDENCIES) $(EXTRA_tutorial_daytime5_server_DEPENDENCIES) tutorial/daytime5/$(am__dirstamp) + @rm -f tutorial/daytime5/server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_daytime5_server_OBJECTS) $(tutorial_daytime5_server_LDADD) $(LIBS) +tutorial/daytime6/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime6 + @: > tutorial/daytime6/$(am__dirstamp) +tutorial/daytime6/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime6/$(DEPDIR) + @: > tutorial/daytime6/$(DEPDIR)/$(am__dirstamp) +tutorial/daytime6/server.$(OBJEXT): tutorial/daytime6/$(am__dirstamp) \ + tutorial/daytime6/$(DEPDIR)/$(am__dirstamp) + +tutorial/daytime6/server$(EXEEXT): $(tutorial_daytime6_server_OBJECTS) $(tutorial_daytime6_server_DEPENDENCIES) $(EXTRA_tutorial_daytime6_server_DEPENDENCIES) tutorial/daytime6/$(am__dirstamp) + @rm -f tutorial/daytime6/server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_daytime6_server_OBJECTS) $(tutorial_daytime6_server_LDADD) $(LIBS) +tutorial/daytime7/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime7 + @: > tutorial/daytime7/$(am__dirstamp) +tutorial/daytime7/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/daytime7/$(DEPDIR) + @: > tutorial/daytime7/$(DEPDIR)/$(am__dirstamp) +tutorial/daytime7/server.$(OBJEXT): tutorial/daytime7/$(am__dirstamp) \ + tutorial/daytime7/$(DEPDIR)/$(am__dirstamp) + +tutorial/daytime7/server$(EXEEXT): $(tutorial_daytime7_server_OBJECTS) $(tutorial_daytime7_server_DEPENDENCIES) $(EXTRA_tutorial_daytime7_server_DEPENDENCIES) tutorial/daytime7/$(am__dirstamp) + @rm -f tutorial/daytime7/server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_daytime7_server_OBJECTS) $(tutorial_daytime7_server_LDADD) $(LIBS) +tutorial/timer1/$(am__dirstamp): + @$(MKDIR_P) tutorial/timer1 + @: > tutorial/timer1/$(am__dirstamp) +tutorial/timer1/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/timer1/$(DEPDIR) + @: > tutorial/timer1/$(DEPDIR)/$(am__dirstamp) +tutorial/timer1/timer.$(OBJEXT): tutorial/timer1/$(am__dirstamp) \ + tutorial/timer1/$(DEPDIR)/$(am__dirstamp) + +tutorial/timer1/timer$(EXEEXT): $(tutorial_timer1_timer_OBJECTS) $(tutorial_timer1_timer_DEPENDENCIES) $(EXTRA_tutorial_timer1_timer_DEPENDENCIES) tutorial/timer1/$(am__dirstamp) + @rm -f tutorial/timer1/timer$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_timer1_timer_OBJECTS) $(tutorial_timer1_timer_LDADD) $(LIBS) +tutorial/timer2/$(am__dirstamp): + @$(MKDIR_P) tutorial/timer2 + @: > tutorial/timer2/$(am__dirstamp) +tutorial/timer2/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/timer2/$(DEPDIR) + @: > tutorial/timer2/$(DEPDIR)/$(am__dirstamp) +tutorial/timer2/timer.$(OBJEXT): tutorial/timer2/$(am__dirstamp) \ + tutorial/timer2/$(DEPDIR)/$(am__dirstamp) + +tutorial/timer2/timer$(EXEEXT): $(tutorial_timer2_timer_OBJECTS) $(tutorial_timer2_timer_DEPENDENCIES) $(EXTRA_tutorial_timer2_timer_DEPENDENCIES) tutorial/timer2/$(am__dirstamp) + @rm -f tutorial/timer2/timer$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_timer2_timer_OBJECTS) $(tutorial_timer2_timer_LDADD) $(LIBS) +tutorial/timer3/$(am__dirstamp): + @$(MKDIR_P) tutorial/timer3 + @: > tutorial/timer3/$(am__dirstamp) +tutorial/timer3/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/timer3/$(DEPDIR) + @: > tutorial/timer3/$(DEPDIR)/$(am__dirstamp) +tutorial/timer3/timer.$(OBJEXT): tutorial/timer3/$(am__dirstamp) \ + tutorial/timer3/$(DEPDIR)/$(am__dirstamp) + +tutorial/timer3/timer$(EXEEXT): $(tutorial_timer3_timer_OBJECTS) $(tutorial_timer3_timer_DEPENDENCIES) $(EXTRA_tutorial_timer3_timer_DEPENDENCIES) tutorial/timer3/$(am__dirstamp) + @rm -f tutorial/timer3/timer$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_timer3_timer_OBJECTS) $(tutorial_timer3_timer_LDADD) $(LIBS) +tutorial/timer4/$(am__dirstamp): + @$(MKDIR_P) tutorial/timer4 + @: > tutorial/timer4/$(am__dirstamp) +tutorial/timer4/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/timer4/$(DEPDIR) + @: > tutorial/timer4/$(DEPDIR)/$(am__dirstamp) +tutorial/timer4/timer.$(OBJEXT): tutorial/timer4/$(am__dirstamp) \ + tutorial/timer4/$(DEPDIR)/$(am__dirstamp) + +tutorial/timer4/timer$(EXEEXT): $(tutorial_timer4_timer_OBJECTS) $(tutorial_timer4_timer_DEPENDENCIES) $(EXTRA_tutorial_timer4_timer_DEPENDENCIES) tutorial/timer4/$(am__dirstamp) + @rm -f tutorial/timer4/timer$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_timer4_timer_OBJECTS) $(tutorial_timer4_timer_LDADD) $(LIBS) +tutorial/timer5/$(am__dirstamp): + @$(MKDIR_P) tutorial/timer5 + @: > tutorial/timer5/$(am__dirstamp) +tutorial/timer5/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tutorial/timer5/$(DEPDIR) + @: > tutorial/timer5/$(DEPDIR)/$(am__dirstamp) +tutorial/timer5/timer.$(OBJEXT): tutorial/timer5/$(am__dirstamp) \ + tutorial/timer5/$(DEPDIR)/$(am__dirstamp) + +tutorial/timer5/timer$(EXEEXT): $(tutorial_timer5_timer_OBJECTS) $(tutorial_timer5_timer_DEPENDENCIES) $(EXTRA_tutorial_timer5_timer_DEPENDENCIES) tutorial/timer5/$(am__dirstamp) + @rm -f tutorial/timer5/timer$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tutorial_timer5_timer_OBJECTS) $(tutorial_timer5_timer_LDADD) $(LIBS) +type_erasure/$(am__dirstamp): + @$(MKDIR_P) type_erasure + @: > type_erasure/$(am__dirstamp) +type_erasure/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) type_erasure/$(DEPDIR) + @: > type_erasure/$(DEPDIR)/$(am__dirstamp) +type_erasure/main.$(OBJEXT): type_erasure/$(am__dirstamp) \ + type_erasure/$(DEPDIR)/$(am__dirstamp) +type_erasure/stdin_line_reader.$(OBJEXT): \ + type_erasure/$(am__dirstamp) \ + type_erasure/$(DEPDIR)/$(am__dirstamp) +type_erasure/sleep.$(OBJEXT): type_erasure/$(am__dirstamp) \ + type_erasure/$(DEPDIR)/$(am__dirstamp) + +type_erasure/type_erasure$(EXEEXT): $(type_erasure_type_erasure_OBJECTS) $(type_erasure_type_erasure_DEPENDENCIES) $(EXTRA_type_erasure_type_erasure_DEPENDENCIES) type_erasure/$(am__dirstamp) + @rm -f type_erasure/type_erasure$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(type_erasure_type_erasure_OBJECTS) $(type_erasure_type_erasure_LDADD) $(LIBS) +windows/$(am__dirstamp): + @$(MKDIR_P) windows + @: > windows/$(am__dirstamp) +windows/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) windows/$(DEPDIR) + @: > windows/$(DEPDIR)/$(am__dirstamp) +windows/transmit_file.$(OBJEXT): windows/$(am__dirstamp) \ + windows/$(DEPDIR)/$(am__dirstamp) + +windows/transmit_file$(EXEEXT): $(windows_transmit_file_OBJECTS) $(windows_transmit_file_DEPENDENCIES) $(EXTRA_windows_transmit_file_DEPENDENCIES) windows/$(am__dirstamp) + @rm -f windows/transmit_file$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(windows_transmit_file_OBJECTS) $(windows_transmit_file_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + -rm -f ../../*.$(OBJEXT) + -rm -f allocation/*.$(OBJEXT) + -rm -f buffers/*.$(OBJEXT) + -rm -f chat/*.$(OBJEXT) + -rm -f deferred/*.$(OBJEXT) + -rm -f echo/*.$(OBJEXT) + -rm -f executors/*.$(OBJEXT) + -rm -f files/*.$(OBJEXT) + -rm -f fork/*.$(OBJEXT) + -rm -f futures/*.$(OBJEXT) + -rm -f handler_tracking/*.$(OBJEXT) + -rm -f http/client/*.$(OBJEXT) + -rm -f http/server/*.$(OBJEXT) + -rm -f http/server2/*.$(OBJEXT) + -rm -f http/server3/*.$(OBJEXT) + -rm -f http/server4/*.$(OBJEXT) + -rm -f icmp/*.$(OBJEXT) + -rm -f invocation/*.$(OBJEXT) + -rm -f iostreams/*.$(OBJEXT) + -rm -f local/*.$(OBJEXT) + -rm -f multicast/*.$(OBJEXT) + -rm -f nonblocking/*.$(OBJEXT) + -rm -f operations/*.$(OBJEXT) + -rm -f parallel_group/*.$(OBJEXT) + -rm -f porthopper/*.$(OBJEXT) + -rm -f services/*.$(OBJEXT) + -rm -f socks4/*.$(OBJEXT) + -rm -f spawn/*.$(OBJEXT) + -rm -f ssl/*.$(OBJEXT) + -rm -f timeouts/*.$(OBJEXT) + -rm -f timers/*.$(OBJEXT) + -rm -f tutorial/daytime1/*.$(OBJEXT) + -rm -f tutorial/daytime2/*.$(OBJEXT) + -rm -f tutorial/daytime3/*.$(OBJEXT) + -rm -f tutorial/daytime4/*.$(OBJEXT) + -rm -f tutorial/daytime5/*.$(OBJEXT) + -rm -f tutorial/daytime6/*.$(OBJEXT) + -rm -f tutorial/daytime7/*.$(OBJEXT) + -rm -f tutorial/timer1/*.$(OBJEXT) + -rm -f tutorial/timer2/*.$(OBJEXT) + -rm -f tutorial/timer3/*.$(OBJEXT) + -rm -f tutorial/timer4/*.$(OBJEXT) + -rm -f tutorial/timer5/*.$(OBJEXT) + -rm -f type_erasure/*.$(OBJEXT) + -rm -f windows/*.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@../../$(DEPDIR)/asio.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@../../$(DEPDIR)/asio_ssl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@allocation/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@buffers/$(DEPDIR)/reference_counted.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@chat/$(DEPDIR)/chat_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@chat/$(DEPDIR)/chat_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@chat/$(DEPDIR)/posix_chat_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@deferred/$(DEPDIR)/deferred_1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@deferred/$(DEPDIR)/deferred_2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/async_tcp_echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/async_udp_echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/blocking_tcp_echo_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/blocking_tcp_echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/blocking_udp_echo_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/blocking_udp_echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/actor.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/bank_account_1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/bank_account_2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/fork_join.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/pipeline.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/priority_scheduler.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@files/$(DEPDIR)/async_file_copy.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@files/$(DEPDIR)/blocking_file_copy.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@fork/$(DEPDIR)/daemon.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@fork/$(DEPDIR)/process_per_connection.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@futures/$(DEPDIR)/daytime_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@handler_tracking/$(DEPDIR)/async_tcp_echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/client/$(DEPDIR)/async_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/client/$(DEPDIR)/sync_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server/$(DEPDIR)/connection.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server/$(DEPDIR)/connection_manager.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server/$(DEPDIR)/main.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server/$(DEPDIR)/mime_types.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server/$(DEPDIR)/reply.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server/$(DEPDIR)/request_handler.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server/$(DEPDIR)/request_parser.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server2/$(DEPDIR)/connection.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server2/$(DEPDIR)/io_context_pool.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server2/$(DEPDIR)/main.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server2/$(DEPDIR)/mime_types.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server2/$(DEPDIR)/reply.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server2/$(DEPDIR)/request_handler.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server2/$(DEPDIR)/request_parser.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server2/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server3/$(DEPDIR)/connection.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server3/$(DEPDIR)/main.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server3/$(DEPDIR)/mime_types.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server3/$(DEPDIR)/reply.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server3/$(DEPDIR)/request_handler.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server3/$(DEPDIR)/request_parser.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server3/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server4/$(DEPDIR)/file_handler.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server4/$(DEPDIR)/main.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server4/$(DEPDIR)/mime_types.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server4/$(DEPDIR)/reply.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server4/$(DEPDIR)/request_parser.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@http/server4/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@icmp/$(DEPDIR)/ping.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@invocation/$(DEPDIR)/prioritised_handlers.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@iostreams/$(DEPDIR)/daytime_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@iostreams/$(DEPDIR)/daytime_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@iostreams/$(DEPDIR)/http_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@local/$(DEPDIR)/connect_pair.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@local/$(DEPDIR)/fd_passing_stream_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@local/$(DEPDIR)/fd_passing_stream_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@local/$(DEPDIR)/iostream_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@local/$(DEPDIR)/stream_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@local/$(DEPDIR)/stream_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@multicast/$(DEPDIR)/receiver.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@multicast/$(DEPDIR)/sender.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@nonblocking/$(DEPDIR)/third_party_lib.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_3.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_4.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_5.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_6.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_7.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_8.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@parallel_group/$(DEPDIR)/ranged_wait_for_all.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@parallel_group/$(DEPDIR)/wait_for_all.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@parallel_group/$(DEPDIR)/wait_for_one.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@parallel_group/$(DEPDIR)/wait_for_one_error.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@parallel_group/$(DEPDIR)/wait_for_one_success.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@porthopper/$(DEPDIR)/client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@porthopper/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@services/$(DEPDIR)/daytime_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@services/$(DEPDIR)/logger_service.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@socks4/$(DEPDIR)/sync_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@spawn/$(DEPDIR)/echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@spawn/$(DEPDIR)/parallel_grep.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@ssl/$(DEPDIR)/client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@ssl/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@timeouts/$(DEPDIR)/async_tcp_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@timeouts/$(DEPDIR)/blocking_tcp_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@timeouts/$(DEPDIR)/blocking_token_tcp_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@timeouts/$(DEPDIR)/blocking_udp_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@timeouts/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@timers/$(DEPDIR)/time_t_timer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/daytime1/$(DEPDIR)/client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/daytime2/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/daytime3/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/daytime4/$(DEPDIR)/client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/daytime5/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/daytime6/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/daytime7/$(DEPDIR)/server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/timer1/$(DEPDIR)/timer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/timer2/$(DEPDIR)/timer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/timer3/$(DEPDIR)/timer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/timer4/$(DEPDIR)/timer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@tutorial/timer5/$(DEPDIR)/timer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@type_erasure/$(DEPDIR)/main.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@type_erasure/$(DEPDIR)/sleep.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@type_erasure/$(DEPDIR)/stdin_line_reader.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@windows/$(DEPDIR)/transmit_file.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(LIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f ../../$(DEPDIR)/$(am__dirstamp) + -rm -f ../../$(am__dirstamp) + -rm -f allocation/$(DEPDIR)/$(am__dirstamp) + -rm -f allocation/$(am__dirstamp) + -rm -f buffers/$(DEPDIR)/$(am__dirstamp) + -rm -f buffers/$(am__dirstamp) + -rm -f chat/$(DEPDIR)/$(am__dirstamp) + -rm -f chat/$(am__dirstamp) + -rm -f deferred/$(DEPDIR)/$(am__dirstamp) + -rm -f deferred/$(am__dirstamp) + -rm -f echo/$(DEPDIR)/$(am__dirstamp) + -rm -f echo/$(am__dirstamp) + -rm -f executors/$(DEPDIR)/$(am__dirstamp) + -rm -f executors/$(am__dirstamp) + -rm -f files/$(DEPDIR)/$(am__dirstamp) + -rm -f files/$(am__dirstamp) + -rm -f fork/$(DEPDIR)/$(am__dirstamp) + -rm -f fork/$(am__dirstamp) + -rm -f futures/$(DEPDIR)/$(am__dirstamp) + -rm -f futures/$(am__dirstamp) + -rm -f handler_tracking/$(DEPDIR)/$(am__dirstamp) + -rm -f handler_tracking/$(am__dirstamp) + -rm -f http/client/$(DEPDIR)/$(am__dirstamp) + -rm -f http/client/$(am__dirstamp) + -rm -f http/server/$(DEPDIR)/$(am__dirstamp) + -rm -f http/server/$(am__dirstamp) + -rm -f http/server2/$(DEPDIR)/$(am__dirstamp) + -rm -f http/server2/$(am__dirstamp) + -rm -f http/server3/$(DEPDIR)/$(am__dirstamp) + -rm -f http/server3/$(am__dirstamp) + -rm -f http/server4/$(DEPDIR)/$(am__dirstamp) + -rm -f http/server4/$(am__dirstamp) + -rm -f icmp/$(DEPDIR)/$(am__dirstamp) + -rm -f icmp/$(am__dirstamp) + -rm -f invocation/$(DEPDIR)/$(am__dirstamp) + -rm -f invocation/$(am__dirstamp) + -rm -f iostreams/$(DEPDIR)/$(am__dirstamp) + -rm -f iostreams/$(am__dirstamp) + -rm -f local/$(DEPDIR)/$(am__dirstamp) + -rm -f local/$(am__dirstamp) + -rm -f multicast/$(DEPDIR)/$(am__dirstamp) + -rm -f multicast/$(am__dirstamp) + -rm -f nonblocking/$(DEPDIR)/$(am__dirstamp) + -rm -f nonblocking/$(am__dirstamp) + -rm -f operations/$(DEPDIR)/$(am__dirstamp) + -rm -f operations/$(am__dirstamp) + -rm -f parallel_group/$(DEPDIR)/$(am__dirstamp) + -rm -f parallel_group/$(am__dirstamp) + -rm -f porthopper/$(DEPDIR)/$(am__dirstamp) + -rm -f porthopper/$(am__dirstamp) + -rm -f services/$(DEPDIR)/$(am__dirstamp) + -rm -f services/$(am__dirstamp) + -rm -f socks4/$(DEPDIR)/$(am__dirstamp) + -rm -f socks4/$(am__dirstamp) + -rm -f spawn/$(DEPDIR)/$(am__dirstamp) + -rm -f spawn/$(am__dirstamp) + -rm -f ssl/$(DEPDIR)/$(am__dirstamp) + -rm -f ssl/$(am__dirstamp) + -rm -f timeouts/$(DEPDIR)/$(am__dirstamp) + -rm -f timeouts/$(am__dirstamp) + -rm -f timers/$(DEPDIR)/$(am__dirstamp) + -rm -f timers/$(am__dirstamp) + -rm -f tutorial/daytime1/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/daytime1/$(am__dirstamp) + -rm -f tutorial/daytime2/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/daytime2/$(am__dirstamp) + -rm -f tutorial/daytime3/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/daytime3/$(am__dirstamp) + -rm -f tutorial/daytime4/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/daytime4/$(am__dirstamp) + -rm -f tutorial/daytime5/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/daytime5/$(am__dirstamp) + -rm -f tutorial/daytime6/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/daytime6/$(am__dirstamp) + -rm -f tutorial/daytime7/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/daytime7/$(am__dirstamp) + -rm -f tutorial/timer1/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/timer1/$(am__dirstamp) + -rm -f tutorial/timer2/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/timer2/$(am__dirstamp) + -rm -f tutorial/timer3/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/timer3/$(am__dirstamp) + -rm -f tutorial/timer4/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/timer4/$(am__dirstamp) + -rm -f tutorial/timer5/$(DEPDIR)/$(am__dirstamp) + -rm -f tutorial/timer5/$(am__dirstamp) + -rm -f type_erasure/$(DEPDIR)/$(am__dirstamp) + -rm -f type_erasure/$(am__dirstamp) + -rm -f windows/$(DEPDIR)/$(am__dirstamp) + -rm -f windows/$(am__dirstamp) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -f ../../$(DEPDIR)/asio.Po + -rm -f ../../$(DEPDIR)/asio_ssl.Po + -rm -f allocation/$(DEPDIR)/server.Po + -rm -f buffers/$(DEPDIR)/reference_counted.Po + -rm -f chat/$(DEPDIR)/chat_client.Po + -rm -f chat/$(DEPDIR)/chat_server.Po + -rm -f chat/$(DEPDIR)/posix_chat_client.Po + -rm -f deferred/$(DEPDIR)/deferred_1.Po + -rm -f deferred/$(DEPDIR)/deferred_2.Po + -rm -f echo/$(DEPDIR)/async_tcp_echo_server.Po + -rm -f echo/$(DEPDIR)/async_udp_echo_server.Po + -rm -f echo/$(DEPDIR)/blocking_tcp_echo_client.Po + -rm -f echo/$(DEPDIR)/blocking_tcp_echo_server.Po + -rm -f echo/$(DEPDIR)/blocking_udp_echo_client.Po + -rm -f echo/$(DEPDIR)/blocking_udp_echo_server.Po + -rm -f executors/$(DEPDIR)/actor.Po + -rm -f executors/$(DEPDIR)/bank_account_1.Po + -rm -f executors/$(DEPDIR)/bank_account_2.Po + -rm -f executors/$(DEPDIR)/fork_join.Po + -rm -f executors/$(DEPDIR)/pipeline.Po + -rm -f executors/$(DEPDIR)/priority_scheduler.Po + -rm -f files/$(DEPDIR)/async_file_copy.Po + -rm -f files/$(DEPDIR)/blocking_file_copy.Po + -rm -f fork/$(DEPDIR)/daemon.Po + -rm -f fork/$(DEPDIR)/process_per_connection.Po + -rm -f futures/$(DEPDIR)/daytime_client.Po + -rm -f handler_tracking/$(DEPDIR)/async_tcp_echo_server.Po + -rm -f http/client/$(DEPDIR)/async_client.Po + -rm -f http/client/$(DEPDIR)/sync_client.Po + -rm -f http/server/$(DEPDIR)/connection.Po + -rm -f http/server/$(DEPDIR)/connection_manager.Po + -rm -f http/server/$(DEPDIR)/main.Po + -rm -f http/server/$(DEPDIR)/mime_types.Po + -rm -f http/server/$(DEPDIR)/reply.Po + -rm -f http/server/$(DEPDIR)/request_handler.Po + -rm -f http/server/$(DEPDIR)/request_parser.Po + -rm -f http/server/$(DEPDIR)/server.Po + -rm -f http/server2/$(DEPDIR)/connection.Po + -rm -f http/server2/$(DEPDIR)/io_context_pool.Po + -rm -f http/server2/$(DEPDIR)/main.Po + -rm -f http/server2/$(DEPDIR)/mime_types.Po + -rm -f http/server2/$(DEPDIR)/reply.Po + -rm -f http/server2/$(DEPDIR)/request_handler.Po + -rm -f http/server2/$(DEPDIR)/request_parser.Po + -rm -f http/server2/$(DEPDIR)/server.Po + -rm -f http/server3/$(DEPDIR)/connection.Po + -rm -f http/server3/$(DEPDIR)/main.Po + -rm -f http/server3/$(DEPDIR)/mime_types.Po + -rm -f http/server3/$(DEPDIR)/reply.Po + -rm -f http/server3/$(DEPDIR)/request_handler.Po + -rm -f http/server3/$(DEPDIR)/request_parser.Po + -rm -f http/server3/$(DEPDIR)/server.Po + -rm -f http/server4/$(DEPDIR)/file_handler.Po + -rm -f http/server4/$(DEPDIR)/main.Po + -rm -f http/server4/$(DEPDIR)/mime_types.Po + -rm -f http/server4/$(DEPDIR)/reply.Po + -rm -f http/server4/$(DEPDIR)/request_parser.Po + -rm -f http/server4/$(DEPDIR)/server.Po + -rm -f icmp/$(DEPDIR)/ping.Po + -rm -f invocation/$(DEPDIR)/prioritised_handlers.Po + -rm -f iostreams/$(DEPDIR)/daytime_client.Po + -rm -f iostreams/$(DEPDIR)/daytime_server.Po + -rm -f iostreams/$(DEPDIR)/http_client.Po + -rm -f local/$(DEPDIR)/connect_pair.Po + -rm -f local/$(DEPDIR)/fd_passing_stream_client.Po + -rm -f local/$(DEPDIR)/fd_passing_stream_server.Po + -rm -f local/$(DEPDIR)/iostream_client.Po + -rm -f local/$(DEPDIR)/stream_client.Po + -rm -f local/$(DEPDIR)/stream_server.Po + -rm -f multicast/$(DEPDIR)/receiver.Po + -rm -f multicast/$(DEPDIR)/sender.Po + -rm -f nonblocking/$(DEPDIR)/third_party_lib.Po + -rm -f operations/$(DEPDIR)/composed_1.Po + -rm -f operations/$(DEPDIR)/composed_2.Po + -rm -f operations/$(DEPDIR)/composed_3.Po + -rm -f operations/$(DEPDIR)/composed_4.Po + -rm -f operations/$(DEPDIR)/composed_5.Po + -rm -f operations/$(DEPDIR)/composed_6.Po + -rm -f operations/$(DEPDIR)/composed_7.Po + -rm -f operations/$(DEPDIR)/composed_8.Po + -rm -f parallel_group/$(DEPDIR)/ranged_wait_for_all.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_all.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one_error.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one_success.Po + -rm -f porthopper/$(DEPDIR)/client.Po + -rm -f porthopper/$(DEPDIR)/server.Po + -rm -f services/$(DEPDIR)/daytime_client.Po + -rm -f services/$(DEPDIR)/logger_service.Po + -rm -f socks4/$(DEPDIR)/sync_client.Po + -rm -f spawn/$(DEPDIR)/echo_server.Po + -rm -f spawn/$(DEPDIR)/parallel_grep.Po + -rm -f ssl/$(DEPDIR)/client.Po + -rm -f ssl/$(DEPDIR)/server.Po + -rm -f timeouts/$(DEPDIR)/async_tcp_client.Po + -rm -f timeouts/$(DEPDIR)/blocking_tcp_client.Po + -rm -f timeouts/$(DEPDIR)/blocking_token_tcp_client.Po + -rm -f timeouts/$(DEPDIR)/blocking_udp_client.Po + -rm -f timeouts/$(DEPDIR)/server.Po + -rm -f timers/$(DEPDIR)/time_t_timer.Po + -rm -f tutorial/daytime1/$(DEPDIR)/client.Po + -rm -f tutorial/daytime2/$(DEPDIR)/server.Po + -rm -f tutorial/daytime3/$(DEPDIR)/server.Po + -rm -f tutorial/daytime4/$(DEPDIR)/client.Po + -rm -f tutorial/daytime5/$(DEPDIR)/server.Po + -rm -f tutorial/daytime6/$(DEPDIR)/server.Po + -rm -f tutorial/daytime7/$(DEPDIR)/server.Po + -rm -f tutorial/timer1/$(DEPDIR)/timer.Po + -rm -f tutorial/timer2/$(DEPDIR)/timer.Po + -rm -f tutorial/timer3/$(DEPDIR)/timer.Po + -rm -f tutorial/timer4/$(DEPDIR)/timer.Po + -rm -f tutorial/timer5/$(DEPDIR)/timer.Po + -rm -f type_erasure/$(DEPDIR)/main.Po + -rm -f type_erasure/$(DEPDIR)/sleep.Po + -rm -f type_erasure/$(DEPDIR)/stdin_line_reader.Po + -rm -f windows/$(DEPDIR)/transmit_file.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ../../$(DEPDIR)/asio.Po + -rm -f ../../$(DEPDIR)/asio_ssl.Po + -rm -f allocation/$(DEPDIR)/server.Po + -rm -f buffers/$(DEPDIR)/reference_counted.Po + -rm -f chat/$(DEPDIR)/chat_client.Po + -rm -f chat/$(DEPDIR)/chat_server.Po + -rm -f chat/$(DEPDIR)/posix_chat_client.Po + -rm -f deferred/$(DEPDIR)/deferred_1.Po + -rm -f deferred/$(DEPDIR)/deferred_2.Po + -rm -f echo/$(DEPDIR)/async_tcp_echo_server.Po + -rm -f echo/$(DEPDIR)/async_udp_echo_server.Po + -rm -f echo/$(DEPDIR)/blocking_tcp_echo_client.Po + -rm -f echo/$(DEPDIR)/blocking_tcp_echo_server.Po + -rm -f echo/$(DEPDIR)/blocking_udp_echo_client.Po + -rm -f echo/$(DEPDIR)/blocking_udp_echo_server.Po + -rm -f executors/$(DEPDIR)/actor.Po + -rm -f executors/$(DEPDIR)/bank_account_1.Po + -rm -f executors/$(DEPDIR)/bank_account_2.Po + -rm -f executors/$(DEPDIR)/fork_join.Po + -rm -f executors/$(DEPDIR)/pipeline.Po + -rm -f executors/$(DEPDIR)/priority_scheduler.Po + -rm -f files/$(DEPDIR)/async_file_copy.Po + -rm -f files/$(DEPDIR)/blocking_file_copy.Po + -rm -f fork/$(DEPDIR)/daemon.Po + -rm -f fork/$(DEPDIR)/process_per_connection.Po + -rm -f futures/$(DEPDIR)/daytime_client.Po + -rm -f handler_tracking/$(DEPDIR)/async_tcp_echo_server.Po + -rm -f http/client/$(DEPDIR)/async_client.Po + -rm -f http/client/$(DEPDIR)/sync_client.Po + -rm -f http/server/$(DEPDIR)/connection.Po + -rm -f http/server/$(DEPDIR)/connection_manager.Po + -rm -f http/server/$(DEPDIR)/main.Po + -rm -f http/server/$(DEPDIR)/mime_types.Po + -rm -f http/server/$(DEPDIR)/reply.Po + -rm -f http/server/$(DEPDIR)/request_handler.Po + -rm -f http/server/$(DEPDIR)/request_parser.Po + -rm -f http/server/$(DEPDIR)/server.Po + -rm -f http/server2/$(DEPDIR)/connection.Po + -rm -f http/server2/$(DEPDIR)/io_context_pool.Po + -rm -f http/server2/$(DEPDIR)/main.Po + -rm -f http/server2/$(DEPDIR)/mime_types.Po + -rm -f http/server2/$(DEPDIR)/reply.Po + -rm -f http/server2/$(DEPDIR)/request_handler.Po + -rm -f http/server2/$(DEPDIR)/request_parser.Po + -rm -f http/server2/$(DEPDIR)/server.Po + -rm -f http/server3/$(DEPDIR)/connection.Po + -rm -f http/server3/$(DEPDIR)/main.Po + -rm -f http/server3/$(DEPDIR)/mime_types.Po + -rm -f http/server3/$(DEPDIR)/reply.Po + -rm -f http/server3/$(DEPDIR)/request_handler.Po + -rm -f http/server3/$(DEPDIR)/request_parser.Po + -rm -f http/server3/$(DEPDIR)/server.Po + -rm -f http/server4/$(DEPDIR)/file_handler.Po + -rm -f http/server4/$(DEPDIR)/main.Po + -rm -f http/server4/$(DEPDIR)/mime_types.Po + -rm -f http/server4/$(DEPDIR)/reply.Po + -rm -f http/server4/$(DEPDIR)/request_parser.Po + -rm -f http/server4/$(DEPDIR)/server.Po + -rm -f icmp/$(DEPDIR)/ping.Po + -rm -f invocation/$(DEPDIR)/prioritised_handlers.Po + -rm -f iostreams/$(DEPDIR)/daytime_client.Po + -rm -f iostreams/$(DEPDIR)/daytime_server.Po + -rm -f iostreams/$(DEPDIR)/http_client.Po + -rm -f local/$(DEPDIR)/connect_pair.Po + -rm -f local/$(DEPDIR)/fd_passing_stream_client.Po + -rm -f local/$(DEPDIR)/fd_passing_stream_server.Po + -rm -f local/$(DEPDIR)/iostream_client.Po + -rm -f local/$(DEPDIR)/stream_client.Po + -rm -f local/$(DEPDIR)/stream_server.Po + -rm -f multicast/$(DEPDIR)/receiver.Po + -rm -f multicast/$(DEPDIR)/sender.Po + -rm -f nonblocking/$(DEPDIR)/third_party_lib.Po + -rm -f operations/$(DEPDIR)/composed_1.Po + -rm -f operations/$(DEPDIR)/composed_2.Po + -rm -f operations/$(DEPDIR)/composed_3.Po + -rm -f operations/$(DEPDIR)/composed_4.Po + -rm -f operations/$(DEPDIR)/composed_5.Po + -rm -f operations/$(DEPDIR)/composed_6.Po + -rm -f operations/$(DEPDIR)/composed_7.Po + -rm -f operations/$(DEPDIR)/composed_8.Po + -rm -f parallel_group/$(DEPDIR)/ranged_wait_for_all.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_all.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one_error.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one_success.Po + -rm -f porthopper/$(DEPDIR)/client.Po + -rm -f porthopper/$(DEPDIR)/server.Po + -rm -f services/$(DEPDIR)/daytime_client.Po + -rm -f services/$(DEPDIR)/logger_service.Po + -rm -f socks4/$(DEPDIR)/sync_client.Po + -rm -f spawn/$(DEPDIR)/echo_server.Po + -rm -f spawn/$(DEPDIR)/parallel_grep.Po + -rm -f ssl/$(DEPDIR)/client.Po + -rm -f ssl/$(DEPDIR)/server.Po + -rm -f timeouts/$(DEPDIR)/async_tcp_client.Po + -rm -f timeouts/$(DEPDIR)/blocking_tcp_client.Po + -rm -f timeouts/$(DEPDIR)/blocking_token_tcp_client.Po + -rm -f timeouts/$(DEPDIR)/blocking_udp_client.Po + -rm -f timeouts/$(DEPDIR)/server.Po + -rm -f timers/$(DEPDIR)/time_t_timer.Po + -rm -f tutorial/daytime1/$(DEPDIR)/client.Po + -rm -f tutorial/daytime2/$(DEPDIR)/server.Po + -rm -f tutorial/daytime3/$(DEPDIR)/server.Po + -rm -f tutorial/daytime4/$(DEPDIR)/client.Po + -rm -f tutorial/daytime5/$(DEPDIR)/server.Po + -rm -f tutorial/daytime6/$(DEPDIR)/server.Po + -rm -f tutorial/daytime7/$(DEPDIR)/server.Po + -rm -f tutorial/timer1/$(DEPDIR)/timer.Po + -rm -f tutorial/timer2/$(DEPDIR)/timer.Po + -rm -f tutorial/timer3/$(DEPDIR)/timer.Po + -rm -f tutorial/timer4/$(DEPDIR)/timer.Po + -rm -f tutorial/timer5/$(DEPDIR)/timer.Po + -rm -f type_erasure/$(DEPDIR)/main.Po + -rm -f type_erasure/$(DEPDIR)/sleep.Po + -rm -f type_erasure/$(DEPDIR)/stdin_line_reader.Po + -rm -f windows/$(DEPDIR)/transmit_file.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/3rdparty/asio/src/examples/cpp11/allocation/.gitignore b/3rdparty/asio/src/examples/cpp11/allocation/.gitignore deleted file mode 100644 index 180ba886e58..00000000000 --- a/3rdparty/asio/src/examples/cpp11/allocation/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -server -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp11/allocation/server.cpp b/3rdparty/asio/src/examples/cpp11/allocation/server.cpp index cbcbe76fe68..48bc119c1c5 100644 --- a/3rdparty/asio/src/examples/cpp11/allocation/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/allocation/server.cpp @@ -2,7 +2,7 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -22,16 +22,16 @@ using asio::ip::tcp; // It contains a single block of memory which may be returned for allocation // requests. If the memory is in use when an allocation request is made, the // allocator delegates allocation to the global heap. -class handler_allocator +class handler_memory { public: - handler_allocator() + handler_memory() : in_use_(false) { } - handler_allocator(const handler_allocator&) = delete; - handler_allocator& operator=(const handler_allocator&) = delete; + handler_memory(const handler_memory&) = delete; + handler_memory& operator=(const handler_memory&) = delete; void* allocate(std::size_t size) { @@ -66,49 +66,51 @@ private: bool in_use_; }; -// Wrapper class template for handler objects to allow handler memory -// allocation to be customised. Calls to operator() are forwarded to the -// encapsulated handler. -template <typename Handler> -class custom_alloc_handler +// The allocator to be associated with the handler objects. This allocator only +// needs to satisfy the C++11 minimal allocator requirements. +template <typename T> +class handler_allocator { public: - custom_alloc_handler(handler_allocator& a, Handler h) - : allocator_(a), - handler_(h) + using value_type = T; + + explicit handler_allocator(handler_memory& mem) + : memory_(mem) { } - template <typename ...Args> - void operator()(Args&&... args) + template <typename U> + handler_allocator(const handler_allocator<U>& other) noexcept + : memory_(other.memory_) { - handler_(std::forward<Args>(args)...); } - friend void* asio_handler_allocate(std::size_t size, - custom_alloc_handler<Handler>* this_handler) + bool operator==(const handler_allocator& other) const noexcept { - return this_handler->allocator_.allocate(size); + return &memory_ == &other.memory_; } - friend void asio_handler_deallocate(void* pointer, std::size_t /*size*/, - custom_alloc_handler<Handler>* this_handler) + bool operator!=(const handler_allocator& other) const noexcept { - this_handler->allocator_.deallocate(pointer); + return &memory_ != &other.memory_; + } + + T* allocate(std::size_t n) const + { + return static_cast<T*>(memory_.allocate(sizeof(T) * n)); + } + + void deallocate(T* p, std::size_t /*n*/) const + { + return memory_.deallocate(p); } private: - handler_allocator& allocator_; - Handler handler_; -}; + template <typename> friend class handler_allocator; -// Helper function to wrap a handler object to add custom allocation. -template <typename Handler> -inline custom_alloc_handler<Handler> make_custom_alloc_handler( - handler_allocator& a, Handler h) -{ - return custom_alloc_handler<Handler>(a, h); -} + // The underlying memory. + handler_memory& memory_; +}; class session : public std::enable_shared_from_this<session> @@ -129,7 +131,8 @@ private: { auto self(shared_from_this()); socket_.async_read_some(asio::buffer(data_), - make_custom_alloc_handler(allocator_, + asio::bind_allocator( + handler_allocator<int>(handler_memory_), [this, self](std::error_code ec, std::size_t length) { if (!ec) @@ -143,7 +146,8 @@ private: { auto self(shared_from_this()); asio::async_write(socket_, asio::buffer(data_, length), - make_custom_alloc_handler(allocator_, + asio::bind_allocator( + handler_allocator<int>(handler_memory_), [this, self](std::error_code ec, std::size_t /*length*/) { if (!ec) @@ -159,8 +163,8 @@ private: // Buffer used to store data received from the client. std::array<char, 1024> data_; - // The allocator to use for handler-based custom memory allocation. - handler_allocator allocator_; + // The memory to use for handler-based custom memory allocation. + handler_memory handler_memory_; }; class server diff --git a/3rdparty/asio/src/examples/cpp11/buffers/.gitignore b/3rdparty/asio/src/examples/cpp11/buffers/.gitignore deleted file mode 100644 index abe68c665f5..00000000000 --- a/3rdparty/asio/src/examples/cpp11/buffers/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -reference_counted -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp11/buffers/reference_counted.cpp b/3rdparty/asio/src/examples/cpp11/buffers/reference_counted.cpp index 34fe9090dfd..cee56ff786b 100644 --- a/3rdparty/asio/src/examples/cpp11/buffers/reference_counted.cpp +++ b/3rdparty/asio/src/examples/cpp11/buffers/reference_counted.cpp @@ -2,7 +2,7 @@ // reference_counted.cpp // ~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,6 +13,7 @@ #include <memory> #include <utility> #include <vector> +#include <ctime> using asio::ip::tcp; @@ -60,7 +61,7 @@ private: auto self(shared_from_this()); asio::async_write(socket_, buffer, - [this, self](std::error_code /*ec*/, std::size_t /*length*/) + [self](std::error_code /*ec*/, std::size_t /*length*/) { }); } diff --git a/3rdparty/asio/src/examples/cpp11/chat/.gitignore b/3rdparty/asio/src/examples/cpp11/chat/.gitignore deleted file mode 100644 index 0882fa6ced3..00000000000 --- a/3rdparty/asio/src/examples/cpp11/chat/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp11/chat/chat_client.cpp b/3rdparty/asio/src/examples/cpp11/chat/chat_client.cpp index e672a022d04..c0393ee8266 100644 --- a/3rdparty/asio/src/examples/cpp11/chat/chat_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/chat/chat_client.cpp @@ -2,7 +2,7 @@ // chat_client.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/chat/chat_message.hpp b/3rdparty/asio/src/examples/cpp11/chat/chat_message.hpp index f6e949bf2e2..2ae82fa1257 100644 --- a/3rdparty/asio/src/examples/cpp11/chat/chat_message.hpp +++ b/3rdparty/asio/src/examples/cpp11/chat/chat_message.hpp @@ -2,7 +2,7 @@ // chat_message.hpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -18,8 +18,8 @@ class chat_message { public: - enum { header_length = 4 }; - enum { max_body_length = 512 }; + static constexpr std::size_t header_length = 4; + static constexpr std::size_t max_body_length = 512; chat_message() : body_length_(0) diff --git a/3rdparty/asio/src/examples/cpp11/chat/chat_server.cpp b/3rdparty/asio/src/examples/cpp11/chat/chat_server.cpp index 6e5ba3b8ee2..7a5dfe33d4f 100644 --- a/3rdparty/asio/src/examples/cpp11/chat/chat_server.cpp +++ b/3rdparty/asio/src/examples/cpp11/chat/chat_server.cpp @@ -2,7 +2,7 @@ // chat_server.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/chat/posix_chat_client.cpp b/3rdparty/asio/src/examples/cpp11/chat/posix_chat_client.cpp new file mode 100644 index 00000000000..a77b8cfb001 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/chat/posix_chat_client.cpp @@ -0,0 +1,198 @@ +// +// posix_chat_client.cpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <array> +#include <cstdlib> +#include <cstring> +#include <iostream> +#include "asio.hpp" +#include "chat_message.hpp" + +#if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) + +using asio::ip::tcp; +namespace posix = asio::posix; + +class posix_chat_client +{ +public: + posix_chat_client(asio::io_context& io_context, + const tcp::resolver::results_type& endpoints) + : socket_(io_context), + input_(io_context, ::dup(STDIN_FILENO)), + output_(io_context, ::dup(STDOUT_FILENO)), + input_buffer_(chat_message::max_body_length) + { + do_connect(endpoints); + } + +private: + void do_connect(const tcp::resolver::results_type& endpoints) + { + asio::async_connect(socket_, endpoints, + [this](std::error_code ec, tcp::endpoint) + { + if (!ec) + { + do_read_header(); + do_read_input(); + } + }); + } + + void do_read_header() + { + asio::async_read(socket_, + asio::buffer(read_msg_.data(), chat_message::header_length), + [this](std::error_code ec, std::size_t /*length*/) + { + if (!ec && read_msg_.decode_header()) + { + do_read_body(); + } + else + { + close(); + } + }); + } + + void do_read_body() + { + asio::async_read(socket_, + asio::buffer(read_msg_.body(), read_msg_.body_length()), + [this](std::error_code ec, std::size_t /*length*/) + { + if (!ec) + { + do_write_output(); + } + else + { + close(); + } + }); + } + + void do_write_output() + { + // Write out the message we just received, terminated by a newline. + static char eol[] = { '\n' }; + std::array<asio::const_buffer, 2> buffers = {{ + asio::buffer(read_msg_.body(), read_msg_.body_length()), + asio::buffer(eol) }}; + asio::async_write(output_, buffers, + [this](std::error_code ec, std::size_t /*length*/) + { + if (!ec) + { + do_read_header(); + } + else + { + close(); + } + }); + } + + void do_read_input() + { + // Read a line of input entered by the user. + asio::async_read_until(input_, input_buffer_, '\n', + [this](std::error_code ec, std::size_t length) + { + if (!ec) + { + // Write the message (minus the newline) to the server. + write_msg_.body_length(length - 1); + input_buffer_.sgetn(write_msg_.body(), length - 1); + input_buffer_.consume(1); // Remove newline from input. + write_msg_.encode_header(); + do_write_message(); + } + else if (ec == asio::error::not_found) + { + // Didn't get a newline. Send whatever we have. + write_msg_.body_length(input_buffer_.size()); + input_buffer_.sgetn(write_msg_.body(), input_buffer_.size()); + write_msg_.encode_header(); + do_write_message(); + } + else + { + close(); + } + }); + } + + void do_write_message() + { + asio::async_write(socket_, + asio::buffer(write_msg_.data(), write_msg_.length()), + [this](std::error_code ec, std::size_t /*length*/) + { + if (!ec) + { + do_read_input(); + } + else + { + close(); + } + }); + } + + void close() + { + // Cancel all outstanding asynchronous operations. + socket_.close(); + input_.close(); + output_.close(); + } + +private: + tcp::socket socket_; + posix::stream_descriptor input_; + posix::stream_descriptor output_; + chat_message read_msg_; + chat_message write_msg_; + asio::streambuf input_buffer_; +}; + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 3) + { + std::cerr << "Usage: posix_chat_client <host> <port>\n"; + return 1; + } + + asio::io_context io_context; + + tcp::resolver resolver(io_context); + tcp::resolver::results_type endpoints = resolver.resolve(argv[1], argv[2]); + + posix_chat_client c(io_context, endpoints); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} + +#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +int main() {} +#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp11/deferred/deferred_1.cpp b/3rdparty/asio/src/examples/cpp11/deferred/deferred_1.cpp new file mode 100644 index 00000000000..db9213eb3be --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/deferred/deferred_1.cpp @@ -0,0 +1,35 @@ +// +// deferred_1.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> + +using asio::deferred; + +int main() +{ + asio::io_context ctx; + + asio::steady_timer timer(ctx); + timer.expires_after(std::chrono::seconds(1)); + + auto deferred_op = timer.async_wait(deferred); + + std::move(deferred_op)( + [](std::error_code ec) + { + std::cout << "timer wait finished: " << ec.message() << "\n"; + } + ); + + ctx.run(); + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp11/deferred/deferred_2.cpp b/3rdparty/asio/src/examples/cpp11/deferred/deferred_2.cpp new file mode 100644 index 00000000000..07528282de5 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/deferred/deferred_2.cpp @@ -0,0 +1,44 @@ +// +// deferred_2.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> + +using asio::deferred; + +int main() +{ + asio::io_context ctx; + + asio::steady_timer timer(ctx); + timer.expires_after(std::chrono::seconds(1)); + + auto deferred_op = timer.async_wait( + deferred( + [&](std::error_code ec) + { + std::cout << "first timer wait finished: " << ec.message() << "\n"; + timer.expires_after(std::chrono::seconds(1)); + return timer.async_wait(deferred); + } + ) + ); + + std::move(deferred_op)( + [](std::error_code ec) + { + std::cout << "second timer wait finished: " << ec.message() << "\n"; + } + ); + + ctx.run(); + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp11/echo/.gitignore b/3rdparty/asio/src/examples/cpp11/echo/.gitignore deleted file mode 100644 index 0882fa6ced3..00000000000 --- a/3rdparty/asio/src/examples/cpp11/echo/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp11/echo/async_tcp_echo_server.cpp b/3rdparty/asio/src/examples/cpp11/echo/async_tcp_echo_server.cpp index d76ebe94aae..b8ba5337697 100644 --- a/3rdparty/asio/src/examples/cpp11/echo/async_tcp_echo_server.cpp +++ b/3rdparty/asio/src/examples/cpp11/echo/async_tcp_echo_server.cpp @@ -2,7 +2,7 @@ // async_tcp_echo_server.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/echo/async_udp_echo_server.cpp b/3rdparty/asio/src/examples/cpp11/echo/async_udp_echo_server.cpp index 8eb1b37f8b6..8e5c26fba2a 100644 --- a/3rdparty/asio/src/examples/cpp11/echo/async_udp_echo_server.cpp +++ b/3rdparty/asio/src/examples/cpp11/echo/async_udp_echo_server.cpp @@ -2,7 +2,7 @@ // async_udp_echo_server.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/echo/blocking_tcp_echo_client.cpp b/3rdparty/asio/src/examples/cpp11/echo/blocking_tcp_echo_client.cpp index c7c648df97f..8a281203f89 100644 --- a/3rdparty/asio/src/examples/cpp11/echo/blocking_tcp_echo_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/echo/blocking_tcp_echo_client.cpp @@ -2,7 +2,7 @@ // blocking_tcp_echo_client.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/echo/blocking_tcp_echo_server.cpp b/3rdparty/asio/src/examples/cpp11/echo/blocking_tcp_echo_server.cpp index 84a72d44453..34e5f221695 100644 --- a/3rdparty/asio/src/examples/cpp11/echo/blocking_tcp_echo_server.cpp +++ b/3rdparty/asio/src/examples/cpp11/echo/blocking_tcp_echo_server.cpp @@ -2,7 +2,7 @@ // blocking_tcp_echo_server.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -26,12 +26,12 @@ void session(tcp::socket sock) { char data[max_length]; - asio::error_code error; + std::error_code error; size_t length = sock.read_some(asio::buffer(data), error); if (error == asio::error::eof) break; // Connection closed cleanly by peer. else if (error) - throw asio::system_error(error); // Some other error. + throw std::system_error(error); // Some other error. asio::write(sock, asio::buffer(data, length)); } diff --git a/3rdparty/asio/src/examples/cpp11/echo/blocking_udp_echo_client.cpp b/3rdparty/asio/src/examples/cpp11/echo/blocking_udp_echo_client.cpp index 1d15780c429..3f2b60e3ccc 100644 --- a/3rdparty/asio/src/examples/cpp11/echo/blocking_udp_echo_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/echo/blocking_udp_echo_client.cpp @@ -2,7 +2,7 @@ // blocking_udp_echo_client.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/echo/blocking_udp_echo_server.cpp b/3rdparty/asio/src/examples/cpp11/echo/blocking_udp_echo_server.cpp index 8bb51735f26..64c6defb885 100644 --- a/3rdparty/asio/src/examples/cpp11/echo/blocking_udp_echo_server.cpp +++ b/3rdparty/asio/src/examples/cpp11/echo/blocking_udp_echo_server.cpp @@ -2,7 +2,7 @@ // blocking_udp_echo_server.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/executors/.gitignore b/3rdparty/asio/src/examples/cpp11/executors/.gitignore deleted file mode 100644 index 183cecf7165..00000000000 --- a/3rdparty/asio/src/examples/cpp11/executors/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -actor -bank_account_[0-9] -fork_join -pipeline -priority_scheduler diff --git a/3rdparty/asio/src/examples/cpp11/executors/actor.cpp b/3rdparty/asio/src/examples/cpp11/executors/actor.cpp index 22dbf206a17..1f0e2c11308 100644 --- a/3rdparty/asio/src/examples/cpp11/executors/actor.cpp +++ b/3rdparty/asio/src/examples/cpp11/executors/actor.cpp @@ -1,5 +1,5 @@ +#include <asio/any_io_executor.hpp> #include <asio/defer.hpp> -#include <asio/executor.hpp> #include <asio/post.hpp> #include <asio/strand.hpp> #include <asio/system_executor.hpp> @@ -10,8 +10,8 @@ #include <typeinfo> #include <vector> +using asio::any_io_executor; using asio::defer; -using asio::executor; using asio::post; using asio::strand; using asio::system_executor; @@ -106,7 +106,7 @@ public: protected: // Construct the actor to use the specified executor for all message handlers. - actor(executor e) + actor(any_io_executor e) : executor_(std::move(e)) { } @@ -124,7 +124,7 @@ protected: template <class Actor, class Message> void deregister_handler(void (Actor::* mf)(Message, actor_address)) { - const std::type_info& id = typeid(message_handler<Message>); + const std::type_info& id = typeid(Message); for (auto iter = handlers_.begin(); iter != handlers_.end(); ++iter) { if ((*iter)->message_id() == id) @@ -171,7 +171,7 @@ private: // All messages associated with a single actor object should be processed // non-concurrently. We use a strand to ensure non-concurrent execution even // if the underlying executor may use multiple threads. - strand<executor> executor_; + strand<any_io_executor> executor_; std::vector<std::shared_ptr<message_handler_base>> handlers_; }; @@ -221,7 +221,7 @@ using asio::thread_pool; class member : public actor { public: - explicit member(executor e) + explicit member(any_io_executor e) : actor(std::move(e)) { register_handler(&member::init_handler); diff --git a/3rdparty/asio/src/examples/cpp11/executors/bank_account_1.cpp b/3rdparty/asio/src/examples/cpp11/executors/bank_account_1.cpp index 85f7d9582af..a63d7fc059b 100644 --- a/3rdparty/asio/src/examples/cpp11/executors/bank_account_1.cpp +++ b/3rdparty/asio/src/examples/cpp11/executors/bank_account_1.cpp @@ -1,9 +1,9 @@ -#include <asio/post.hpp> -#include <asio/thread_pool.hpp> +#include <asio/execution.hpp> +#include <asio/static_thread_pool.hpp> #include <iostream> -using asio::post; -using asio::thread_pool; +using asio::static_thread_pool; +namespace execution = asio::execution; // Traditional active object pattern. // Member functions do not block. @@ -11,37 +11,40 @@ using asio::thread_pool; class bank_account { int balance_ = 0; - mutable thread_pool pool_{1}; + mutable static_thread_pool pool_{1}; public: void deposit(int amount) { - post(pool_, [=] - { - balance_ += amount; - }); + pool_.executor().execute( + [this, amount] + { + balance_ += amount; + }); } void withdraw(int amount) { - post(pool_, [=] - { - if (balance_ >= amount) - balance_ -= amount; - }); + pool_.executor().execute( + [this, amount] + { + if (balance_ >= amount) + balance_ -= amount; + }); } void print_balance() const { - post(pool_, [=] - { - std::cout << "balance = " << balance_ << "\n"; - }); + pool_.executor().execute( + [this] + { + std::cout << "balance = " << balance_ << "\n"; + }); } ~bank_account() { - pool_.join(); + pool_.wait(); } }; diff --git a/3rdparty/asio/src/examples/cpp11/executors/bank_account_2.cpp b/3rdparty/asio/src/examples/cpp11/executors/bank_account_2.cpp index b646cb29518..45a24abc352 100644 --- a/3rdparty/asio/src/examples/cpp11/executors/bank_account_2.cpp +++ b/3rdparty/asio/src/examples/cpp11/executors/bank_account_2.cpp @@ -1,11 +1,9 @@ -#include <asio/post.hpp> -#include <asio/thread_pool.hpp> -#include <asio/use_future.hpp> +#include <asio/execution.hpp> +#include <asio/static_thread_pool.hpp> #include <iostream> -using asio::post; -using asio::thread_pool; -using asio::use_future; +using asio::static_thread_pool; +namespace execution = asio::execution; // Traditional active object pattern. // Member functions block until operation is finished. @@ -13,35 +11,37 @@ using asio::use_future; class bank_account { int balance_ = 0; - mutable thread_pool pool_{1}; + mutable static_thread_pool pool_{1}; public: void deposit(int amount) { - post(pool_, - use_future([=] + asio::require(pool_.executor(), execution::blocking.always).execute( + [this, amount] { balance_ += amount; - })).get(); + }); } void withdraw(int amount) { - post(pool_, - use_future([=] + asio::require(pool_.executor(), execution::blocking.always).execute( + [this, amount] { if (balance_ >= amount) balance_ -= amount; - })).get(); + }); } int balance() const { - return post(pool_, - use_future([=] + int result = 0; + asio::require(pool_.executor(), execution::blocking.always).execute( + [this, &result] { - return balance_; - })).get(); + result = balance_; + }); + return result; } }; diff --git a/3rdparty/asio/src/examples/cpp11/executors/fork_join.cpp b/3rdparty/asio/src/examples/cpp11/executors/fork_join.cpp index 69716814823..7e8a827356d 100644 --- a/3rdparty/asio/src/examples/cpp11/executors/fork_join.cpp +++ b/3rdparty/asio/src/examples/cpp11/executors/fork_join.cpp @@ -1,20 +1,20 @@ -#include <asio/dispatch.hpp> -#include <asio/execution_context.hpp> -#include <asio/thread_pool.hpp> +#include <asio/execution.hpp> +#include <asio/static_thread_pool.hpp> +#include <algorithm> #include <condition_variable> #include <memory> #include <mutex> #include <queue> #include <thread> +#include <numeric> -using asio::dispatch; -using asio::execution_context; -using asio::thread_pool; +using asio::static_thread_pool; +namespace execution = asio::execution; // A fixed-size thread pool used to implement fork/join semantics. Functions // are scheduled using a simple FIFO queue. Implementing work stealing, or // using a queue based on atomic operations, are left as tasks for the reader. -class fork_join_pool : public execution_context +class fork_join_pool { public: // The constructor starts a thread pool with the specified number of threads. @@ -22,7 +22,7 @@ public: // Additional threads may temporarily be added to the pool if they join a // fork_executor. explicit fork_join_pool( - std::size_t thread_count = std::thread::hardware_concurrency() * 2) + std::size_t thread_count = std::max(std::thread::hardware_concurrency(), 1u) * 2) : use_count_(1), threads_(thread_count) { @@ -32,7 +32,8 @@ public: // it is time to shut down, i.e. the use count is zero. for (thread_count_ = 0; thread_count_ < thread_count; ++thread_count_) { - dispatch(threads_, [&] + threads_.executor().execute( + [this] { std::unique_lock<std::mutex> lock(mutex_); while (use_count_ > 0) @@ -44,7 +45,7 @@ public: catch (...) { stop_threads(); - threads_.join(); + threads_.wait(); throw; } } @@ -53,7 +54,7 @@ public: ~fork_join_pool() { stop_threads(); - threads_.join(); + threads_.wait(); } private: @@ -117,7 +118,7 @@ private: // Dispatch a function, executing it immediately if the queue is already // loaded. Otherwise adds the function to the queue and wakes a thread. - void do_dispatch(std::shared_ptr<function_base> p, + void do_execute(std::shared_ptr<function_base> p, const std::shared_ptr<std::size_t>& work_count) { std::unique_lock<std::mutex> lock(mutex_); @@ -135,16 +136,6 @@ private: } } - // Add a function to the queue and wake a thread. - void do_post(std::shared_ptr<function_base> p, - const std::shared_ptr<std::size_t>& work_count) - { - std::lock_guard<std::mutex> lock(mutex_); - queue_.push(p); - do_work_started(work_count); - condition_.notify_one(); - } - // Ask all threads to shut down. void stop_threads() { @@ -158,7 +149,7 @@ private: std::queue<std::shared_ptr<function_base>> queue_; std::size_t use_count_; std::size_t thread_count_; - thread_pool threads_; + static_thread_pool threads_; }; // A class that satisfies the Executor requirements. Every function or piece of @@ -172,45 +163,16 @@ public: { } - fork_join_pool& context() const noexcept + fork_join_pool& query(execution::context_t) const noexcept { return context_; } - void on_work_started() const noexcept - { - std::lock_guard<std::mutex> lock(context_.mutex_); - context_.do_work_started(work_count_); - } - - void on_work_finished() const noexcept - { - std::lock_guard<std::mutex> lock(context_.mutex_); - context_.do_work_finished(work_count_); - } - - template <class Func, class Alloc> - void dispatch(Func&& f, const Alloc& a) const - { - auto p(std::allocate_shared<function<Func>>( - typename std::allocator_traits<Alloc>::template rebind_alloc<char>(a), - std::move(f), work_count_)); - context_.do_dispatch(p, work_count_); - } - - template <class Func, class Alloc> - void post(Func f, const Alloc& a) const - { - auto p(std::allocate_shared<function<Func>>( - typename std::allocator_traits<Alloc>::template rebind_alloc<char>(a), - std::move(f), work_count_)); - context_.do_post(p, work_count_); - } - - template <class Func, class Alloc> - void defer(Func&& f, const Alloc& a) const + template <class Func> + void execute(Func f) const { - post(std::forward<Func>(f), a); + auto p(std::make_shared<function<Func>>(std::move(f), work_count_)); + context_.do_execute(p, work_count_); } friend bool operator==(const fork_executor& a, @@ -289,8 +251,8 @@ void fork_join_sort(Iterator begin, Iterator end) { fork_executor fork(pool); join_guard join(fork); - dispatch(fork, [=]{ fork_join_sort(begin, begin + n / 2); }); - dispatch(fork, [=]{ fork_join_sort(begin + n / 2, end); }); + fork.execute([=]{ fork_join_sort(begin, begin + n / 2); }); + fork.execute([=]{ fork_join_sort(begin + n / 2, end); }); } std::inplace_merge(begin, begin + n / 2, end); } diff --git a/3rdparty/asio/src/examples/cpp11/executors/pipeline.cpp b/3rdparty/asio/src/examples/cpp11/executors/pipeline.cpp index 86bf860cb9c..f441e322688 100644 --- a/3rdparty/asio/src/examples/cpp11/executors/pipeline.cpp +++ b/3rdparty/asio/src/examples/cpp11/executors/pipeline.cpp @@ -11,6 +11,7 @@ #include <queue> #include <thread> #include <vector> +#include <cctype> using asio::execution_context; using asio::executor_binder; @@ -19,9 +20,10 @@ using asio::post; using asio::system_executor; using asio::use_future; using asio::use_service; +namespace execution = asio::execution; // An executor that launches a new thread for each function submitted to it. -// This class satisfies the Executor requirements. +// This class satisfies the executor requirements. class thread_executor { private: @@ -54,40 +56,28 @@ private: }; public: - execution_context& context() const noexcept + execution_context& query(execution::context_t) const { - return system_executor().context(); + return asio::query(system_executor(), execution::context); } - void on_work_started() const noexcept + execution::blocking_t query(execution::blocking_t) const { - // This executor doesn't count work. + return execution::blocking.never; } - void on_work_finished() const noexcept + thread_executor require(execution::blocking_t::never_t) const { - // This executor doesn't count work. + return *this; } - template <class Func, class Alloc> - void dispatch(Func&& f, const Alloc& a) const + template <class Func> + void execute(Func f) const { - post(std::forward<Func>(f), a); - } - - template <class Func, class Alloc> - void post(Func f, const Alloc&) const - { - thread_bag& bag = use_service<thread_bag>(context()); + thread_bag& bag = use_service<thread_bag>(query(execution::context)); bag.add_thread(std::thread(std::move(f))); } - template <class Func, class Alloc> - void defer(Func&& f, const Alloc& a) const - { - post(std::forward<Func>(f), a); - } - friend bool operator==(const thread_executor&, const thread_executor&) noexcept { @@ -291,7 +281,7 @@ void writer(queue_back<std::string> in) int main() { - thread_pool pool; + thread_pool pool(1); auto f = pipeline(reader, filter, bind_executor(pool, upper), writer); f.wait(); diff --git a/3rdparty/asio/src/examples/cpp11/executors/priority_scheduler.cpp b/3rdparty/asio/src/examples/cpp11/executors/priority_scheduler.cpp index fb38fa2ce4b..d8ef79f3a51 100644 --- a/3rdparty/asio/src/examples/cpp11/executors/priority_scheduler.cpp +++ b/3rdparty/asio/src/examples/cpp11/executors/priority_scheduler.cpp @@ -8,6 +8,7 @@ using asio::dispatch; using asio::execution_context; +namespace execution = 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 { @@ -79,6 +53,12 @@ public: int priority_; }; + ~priority_scheduler() noexcept + { + shutdown(); + destroy(); + } + executor_type get_executor(int pri = 0) noexcept { return executor_type(*const_cast<priority_scheduler*>(this), pri); diff --git a/3rdparty/asio/src/examples/cpp11/files/async_file_copy.cpp b/3rdparty/asio/src/examples/cpp11/files/async_file_copy.cpp new file mode 100644 index 00000000000..edfb2765ed5 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/files/async_file_copy.cpp @@ -0,0 +1,101 @@ +// +// async_file_copy.cpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <iostream> +#include "asio.hpp" + +#if defined(ASIO_HAS_FILE) + +class file_copier +{ +public: + file_copier(asio::io_context& io_context, + const char* from, const char* to) + : from_file_(io_context, from, + asio::stream_file::read_only), + to_file_(io_context, to, + asio::stream_file::write_only + | asio::stream_file::create + | asio::stream_file::truncate) + { + } + + void start() + { + do_read(); + } + +private: + void do_read() + { + from_file_.async_read_some(asio::buffer(data_), + [this](std::error_code error, std::size_t n) + { + if (!error) + { + do_write(n); + } + else if (error != asio::error::eof) + { + std::cerr << "Error copying file: " << error.message() << "\n"; + } + }); + } + + void do_write(std::size_t n) + { + asio::async_write(to_file_, asio::buffer(data_, n), + [this](std::error_code error, std::size_t /*n*/) + { + if (!error) + { + do_read(); + } + else + { + std::cerr << "Error copying file: " << error.message() << "\n"; + } + }); + } + + asio::stream_file from_file_; + asio::stream_file to_file_; + char data_[4096]; +}; + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 3) + { + std::cerr << "Usage: async_file_copy <from> <to>\n"; + return 1; + } + + asio::io_context io_context; + + file_copier copier(io_context, argv[1], argv[2]); + copier.start(); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + return 1; + } + + return 0; +} + +#else // defined(ASIO_HAS_FILE) +int main() {} +#endif // defined(ASIO_HAS_FILE) diff --git a/3rdparty/asio/src/examples/cpp11/files/blocking_file_copy.cpp b/3rdparty/asio/src/examples/cpp11/files/blocking_file_copy.cpp new file mode 100644 index 00000000000..6e111b4909d --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/files/blocking_file_copy.cpp @@ -0,0 +1,65 @@ +// +// blocking_file_copy.cpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <iostream> +#include "asio.hpp" + +#if defined(ASIO_HAS_FILE) + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 3) + { + std::cerr << "Usage: blocking_file_copy <from> <to>\n"; + return 1; + } + + asio::io_context io_context; + + asio::stream_file from_file(io_context, argv[1], + asio::stream_file::read_only); + + asio::stream_file to_file(io_context, argv[2], + asio::stream_file::write_only + | asio::stream_file::create + | asio::stream_file::truncate); + + char data[4096]; + std::error_code error; + for (;;) + { + std::size_t n = from_file.read_some(asio::buffer(data), error); + if (error) + break; + asio::write(to_file, asio::buffer(data, n), error); + if (error) + break; + } + + if (error && error != asio::error::eof) + { + std::cerr << "Error copying file: " << error.message() << "\n"; + return 1; + } + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + return 1; + } + + return 0; +} + +#else // defined(ASIO_HAS_FILE) +int main() {} +#endif // defined(ASIO_HAS_FILE) diff --git a/3rdparty/asio/src/examples/cpp03/fork/daemon.cpp b/3rdparty/asio/src/examples/cpp11/fork/daemon.cpp index 06eef3d6b49..547acb33a5a 100644 --- a/3rdparty/asio/src/examples/cpp03/fork/daemon.cpp +++ b/3rdparty/asio/src/examples/cpp11/fork/daemon.cpp @@ -2,7 +2,7 @@ // daemon.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,8 +11,7 @@ #include <asio/io_context.hpp> #include <asio/ip/udp.hpp> #include <asio/signal_set.hpp> -#include <boost/array.hpp> -#include <boost/bind.hpp> +#include <array> #include <ctime> #include <iostream> #include <syslog.h> @@ -24,38 +23,36 @@ class udp_daytime_server { public: udp_daytime_server(asio::io_context& io_context) - : socket_(io_context, udp::endpoint(udp::v4(), 13)) + : socket_(io_context, {udp::v4(), 13}) { - start_receive(); + receive(); } private: - void start_receive() + void receive() { socket_.async_receive_from( asio::buffer(recv_buffer_), remote_endpoint_, - boost::bind(&udp_daytime_server::handle_receive, this, _1)); - } - - void handle_receive(const asio::error_code& ec) - { - if (!ec || ec == asio::error::message_size) - { - using namespace std; // For time_t, time and ctime; - time_t now = time(0); - std::string message = ctime(&now); - - asio::error_code ignored_ec; - socket_.send_to(asio::buffer(message), - remote_endpoint_, 0, ignored_ec); - } - - start_receive(); + [this](std::error_code ec, std::size_t /*n*/) + { + if (!ec) + { + using namespace std; // For time_t, time and ctime; + time_t now = time(0); + std::string message = ctime(&now); + + std::error_code ignored_ec; + socket_.send_to(asio::buffer(message), + remote_endpoint_, 0, ignored_ec); + } + + receive(); + }); } udp::socket socket_; udp::endpoint remote_endpoint_; - boost::array<char, 1> recv_buffer_; + std::array<char, 1> recv_buffer_; }; int main() @@ -74,7 +71,10 @@ int main() // re-read of a configuration file. asio::signal_set signals(io_context, SIGINT, SIGTERM); signals.async_wait( - boost::bind(&asio::io_context::stop, &io_context)); + [&](std::error_code /*ec*/, int /*signo*/) + { + io_context.stop(); + }); // Inform the io_context that we are about to become a daemon. The // io_context cleans up any internal resources, such as threads, that may diff --git a/3rdparty/asio/src/examples/cpp11/fork/process_per_connection.cpp b/3rdparty/asio/src/examples/cpp11/fork/process_per_connection.cpp new file mode 100644 index 00000000000..cad52e7ab9f --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/fork/process_per_connection.cpp @@ -0,0 +1,162 @@ +// +// process_per_connection.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdlib> +#include <iostream> +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> + +using asio::ip::tcp; + +class server +{ +public: + server(asio::io_context& io_context, unsigned short port) + : io_context_(io_context), + signal_(io_context, SIGCHLD), + acceptor_(io_context, {tcp::v4(), port}), + socket_(io_context) + { + wait_for_signal(); + accept(); + } + +private: + void wait_for_signal() + { + signal_.async_wait( + [this](std::error_code /*ec*/, int /*signo*/) + { + // Only the parent process should check for this signal. We can + // determine whether we are in the parent by checking if the acceptor + // is still open. + if (acceptor_.is_open()) + { + // Reap completed child processes so that we don't end up with + // zombies. + int status = 0; + while (waitpid(-1, &status, WNOHANG) > 0) {} + + wait_for_signal(); + } + }); + } + + void accept() + { + acceptor_.async_accept( + [this](std::error_code ec, tcp::socket new_socket) + { + if (!ec) + { + // Take ownership of the newly accepted socket. + socket_ = std::move(new_socket); + + // Inform the io_context that we are about to fork. The io_context + // cleans up any internal resources, such as threads, that may + // interfere with forking. + io_context_.notify_fork(asio::io_context::fork_prepare); + + if (fork() == 0) + { + // Inform the io_context that the fork is finished and that this + // is the child process. The io_context uses this opportunity to + // create any internal file descriptors that must be private to + // the new process. + io_context_.notify_fork(asio::io_context::fork_child); + + // The child won't be accepting new connections, so we can close + // the acceptor. It remains open in the parent. + acceptor_.close(); + + // The child process is not interested in processing the SIGCHLD + // signal. + signal_.cancel(); + + read(); + } + else + { + + // Inform the io_context that the fork is finished (or failed) + // and that this is the parent process. The io_context uses this + // opportunity to recreate any internal resources that were + // cleaned up during preparation for the fork. + io_context_.notify_fork(asio::io_context::fork_parent); + + // The parent process can now close the newly accepted socket. It + // remains open in the child. + socket_.close(); + + accept(); + } + } + else + { + std::cerr << "Accept error: " << ec.message() << std::endl; + accept(); + } + }); + } + + void read() + { + socket_.async_read_some(asio::buffer(data_), + [this](std::error_code ec, std::size_t length) + { + if (!ec) + write(length); + }); + } + + void write(std::size_t length) + { + asio::async_write(socket_, asio::buffer(data_, length), + [this](std::error_code ec, std::size_t /*length*/) + { + if (!ec) + read(); + }); + } + + asio::io_context& io_context_; + asio::signal_set signal_; + tcp::acceptor acceptor_; + tcp::socket socket_; + std::array<char, 1024> data_; +}; + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 2) + { + std::cerr << "Usage: process_per_connection <port>\n"; + return 1; + } + + asio::io_context io_context; + + using namespace std; // For atoi. + server s(io_context, atoi(argv[1])); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << std::endl; + } +} diff --git a/3rdparty/asio/src/examples/cpp11/futures/.gitignore b/3rdparty/asio/src/examples/cpp11/futures/.gitignore deleted file mode 100644 index 0882fa6ced3..00000000000 --- a/3rdparty/asio/src/examples/cpp11/futures/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp11/futures/daytime_client.cpp b/3rdparty/asio/src/examples/cpp11/futures/daytime_client.cpp index 0004e124ff6..2f5314ede39 100644 --- a/3rdparty/asio/src/examples/cpp11/futures/daytime_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/futures/daytime_client.cpp @@ -2,7 +2,7 @@ // daytime_client.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/handler_tracking/async_tcp_echo_server.cpp b/3rdparty/asio/src/examples/cpp11/handler_tracking/async_tcp_echo_server.cpp new file mode 100644 index 00000000000..42a31f7b316 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/handler_tracking/async_tcp_echo_server.cpp @@ -0,0 +1,135 @@ +// +// async_tcp_echo_server.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <cstdlib> +#include <iostream> +#include <memory> +#include <utility> +#include <asio.hpp> + +using asio::ip::tcp; + +// Define a helper macro to invoke ASIO_HANDLER_LOCATION with the current +// file name, line number, and function name. For the function name, you might +// also consider using __PRETTY_FUNCTION__, BOOST_CURRENT_FUNCTION, or a hand- +// crafted name. For C++20 or later, you may also use std::source_location. +#define HANDLER_LOCATION \ + ASIO_HANDLER_LOCATION((__FILE__, __LINE__, __func__)) + +class session + : public std::enable_shared_from_this<session> +{ +public: + session(tcp::socket socket) + : socket_(std::move(socket)) + { + } + + void start() + { + HANDLER_LOCATION; + + do_read(); + } + +private: + void do_read() + { + HANDLER_LOCATION; + + auto self(shared_from_this()); + socket_.async_read_some(asio::buffer(data_, max_length), + [this, self](std::error_code ec, std::size_t length) + { + HANDLER_LOCATION; + + if (!ec) + { + do_write(length); + } + }); + } + + void do_write(std::size_t length) + { + HANDLER_LOCATION; + + auto self(shared_from_this()); + asio::async_write(socket_, asio::buffer(data_, length), + [this, self](std::error_code ec, std::size_t /*length*/) + { + HANDLER_LOCATION; + + if (!ec) + { + do_read(); + } + }); + } + + tcp::socket socket_; + enum { max_length = 1024 }; + char data_[max_length]; +}; + +class server +{ +public: + server(asio::io_context& io_context, short port) + : acceptor_(io_context, tcp::endpoint(tcp::v4(), port)) + { + do_accept(); + } + +private: + void do_accept() + { + HANDLER_LOCATION; + + acceptor_.async_accept( + [this](std::error_code ec, tcp::socket socket) + { + HANDLER_LOCATION; + + if (!ec) + { + std::make_shared<session>(std::move(socket))->start(); + } + + do_accept(); + }); + } + + tcp::acceptor acceptor_; +}; + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 2) + { + std::cerr << "Usage: async_tcp_echo_server <port>\n"; + return 1; + } + + asio::io_context io_context; + + server s(io_context, std::atoi(argv[1])); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp11/handler_tracking/custom_tracking.hpp b/3rdparty/asio/src/examples/cpp11/handler_tracking/custom_tracking.hpp index 41b355c748c..57b162a51e8 100644 --- a/3rdparty/asio/src/examples/cpp11/handler_tracking/custom_tracking.hpp +++ b/3rdparty/asio/src/examples/cpp11/handler_tracking/custom_tracking.hpp @@ -2,7 +2,7 @@ // custom_tracking.hpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -24,6 +24,9 @@ # define ASIO_HANDLER_TRACKING_INIT \ ::custom_tracking::init() +# define ASIO_HANDLER_LOCATION(args) \ + ::custom_tracking::location args + # define ASIO_HANDLER_CREATION(args) \ ::custom_tracking::creation args @@ -71,9 +74,16 @@ struct custom_tracking { } + // Record a source location. + static void location(const char* file_name, + int line, const char* function_name) + { + std::printf("At location %s:%d in %s\n", file_name, line, function_name); + } + // Record the creation of a tracked handler. - static void creation(asio::execution_context& /*ctx*/, tracked_handler& h, - const char* object_type, void* /*object*/, + static void creation(asio::execution_context& /*ctx*/, + tracked_handler& h, const char* object_type, void* /*object*/, std::uintmax_t native_handle, const char* op_name) { // Generate a unique id for the new handler. @@ -177,7 +187,7 @@ struct custom_tracking // Record a reactor-based operation that is associated with a handler. static void reactor_operation(const tracked_handler& h, - const char* op_name, const asio::error_code& ec) + const char* op_name, const std::error_code& ec) { std::printf( "Performed operation %s.%s for native_handle = %" PRIuMAX @@ -187,7 +197,7 @@ struct custom_tracking // Record a reactor-based operation that is associated with a handler. static void reactor_operation(const tracked_handler& h, - const char* op_name, const asio::error_code& ec, + const char* op_name, const std::error_code& ec, std::size_t bytes_transferred) { std::printf( diff --git a/3rdparty/asio/src/examples/cpp03/http/client/async_client.cpp b/3rdparty/asio/src/examples/cpp11/http/client/async_client.cpp index 83dcc36d53a..309ae252147 100644 --- a/3rdparty/asio/src/examples/cpp03/http/client/async_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/client/async_client.cpp @@ -2,18 +2,18 @@ // async_client.cpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <functional> #include <iostream> #include <istream> #include <ostream> #include <string> #include <asio.hpp> -#include <boost/bind.hpp> using asio::ip::tcp; @@ -37,13 +37,13 @@ public: // Start an asynchronous resolve to translate the server and service names // into a list of endpoints. resolver_.async_resolve(server, "http", - boost::bind(&client::handle_resolve, this, + std::bind(&client::handle_resolve, this, asio::placeholders::error, asio::placeholders::results)); } private: - void handle_resolve(const asio::error_code& err, + void handle_resolve(const std::error_code& err, const tcp::resolver::results_type& endpoints) { if (!err) @@ -51,7 +51,7 @@ private: // Attempt a connection to each endpoint in the list until we // successfully establish a connection. asio::async_connect(socket_, endpoints, - boost::bind(&client::handle_connect, this, + std::bind(&client::handle_connect, this, asio::placeholders::error)); } else @@ -60,13 +60,13 @@ private: } } - void handle_connect(const asio::error_code& err) + void handle_connect(const std::error_code& err) { if (!err) { // The connection was successful. Send the request. asio::async_write(socket_, request_, - boost::bind(&client::handle_write_request, this, + std::bind(&client::handle_write_request, this, asio::placeholders::error)); } else @@ -75,7 +75,7 @@ private: } } - void handle_write_request(const asio::error_code& err) + void handle_write_request(const std::error_code& err) { if (!err) { @@ -83,7 +83,7 @@ private: // automatically grow to accommodate the entire line. The growth may be // limited by passing a maximum size to the streambuf constructor. asio::async_read_until(socket_, response_, "\r\n", - boost::bind(&client::handle_read_status_line, this, + std::bind(&client::handle_read_status_line, this, asio::placeholders::error)); } else @@ -92,7 +92,7 @@ private: } } - void handle_read_status_line(const asio::error_code& err) + void handle_read_status_line(const std::error_code& err) { if (!err) { @@ -118,7 +118,7 @@ private: // Read the response headers, which are terminated by a blank line. asio::async_read_until(socket_, response_, "\r\n\r\n", - boost::bind(&client::handle_read_headers, this, + std::bind(&client::handle_read_headers, this, asio::placeholders::error)); } else @@ -127,7 +127,7 @@ private: } } - void handle_read_headers(const asio::error_code& err) + void handle_read_headers(const std::error_code& err) { if (!err) { @@ -145,7 +145,7 @@ private: // Start reading remaining data until EOF. asio::async_read(socket_, response_, asio::transfer_at_least(1), - boost::bind(&client::handle_read_content, this, + std::bind(&client::handle_read_content, this, asio::placeholders::error)); } else @@ -154,7 +154,7 @@ private: } } - void handle_read_content(const asio::error_code& err) + void handle_read_content(const std::error_code& err) { if (!err) { @@ -164,7 +164,7 @@ private: // Continue reading remaining data until EOF. asio::async_read(socket_, response_, asio::transfer_at_least(1), - boost::bind(&client::handle_read_content, this, + std::bind(&client::handle_read_content, this, asio::placeholders::error)); } else if (err != asio::error::eof) diff --git a/3rdparty/asio/src/examples/cpp03/http/client/sync_client.cpp b/3rdparty/asio/src/examples/cpp11/http/client/sync_client.cpp index a11b5c7c76a..4f5ad099317 100644 --- a/3rdparty/asio/src/examples/cpp03/http/client/sync_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/client/sync_client.cpp @@ -2,7 +2,7 @@ // sync_client.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -90,12 +90,12 @@ int main(int argc, char* argv[]) std::cout << &response; // Read until EOF, writing data to output as we go. - asio::error_code error; + std::error_code error; while (asio::read(socket, response, asio::transfer_at_least(1), error)) std::cout << &response; if (error != asio::error::eof) - throw asio::system_error(error); + throw std::system_error(error); } catch (std::exception& e) { diff --git a/3rdparty/asio/src/examples/cpp11/http/server/.gitignore b/3rdparty/asio/src/examples/cpp11/http/server/.gitignore deleted file mode 100644 index 0882fa6ced3..00000000000 --- a/3rdparty/asio/src/examples/cpp11/http/server/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp11/http/server/connection.cpp b/3rdparty/asio/src/examples/cpp11/http/server/connection.cpp index f4d9cac46e5..58d619fec76 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/connection.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/connection.cpp @@ -2,7 +2,7 @@ // connection.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,6 @@ #include "connection.hpp" #include <utility> -#include <vector> #include "connection_manager.hpp" #include "request_handler.hpp" @@ -78,7 +77,7 @@ void connection::do_write() if (!ec) { // Initiate graceful connection closure. - asio::error_code ignored_ec; + std::error_code ignored_ec; socket_.shutdown(asio::ip::tcp::socket::shutdown_both, ignored_ec); } diff --git a/3rdparty/asio/src/examples/cpp11/http/server/connection.hpp b/3rdparty/asio/src/examples/cpp11/http/server/connection.hpp index 96364db0daa..1d671ebdcbe 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/connection.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/connection.hpp @@ -2,7 +2,7 @@ // connection.hpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,9 +11,9 @@ #ifndef HTTP_CONNECTION_HPP #define HTTP_CONNECTION_HPP +#include <asio.hpp> #include <array> #include <memory> -#include <asio.hpp> #include "reply.hpp" #include "request.hpp" #include "request_handler.hpp" diff --git a/3rdparty/asio/src/examples/cpp11/http/server/connection_manager.cpp b/3rdparty/asio/src/examples/cpp11/http/server/connection_manager.cpp index 55bfb9ad719..88161919330 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/connection_manager.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/connection_manager.cpp @@ -2,7 +2,7 @@ // connection_manager.cpp // ~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/connection_manager.hpp b/3rdparty/asio/src/examples/cpp11/http/server/connection_manager.hpp index 8dadf416347..0b35408fae5 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/connection_manager.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/connection_manager.hpp @@ -2,7 +2,7 @@ // connection_manager.hpp // ~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/header.hpp b/3rdparty/asio/src/examples/cpp11/http/server/header.hpp index 22e3c4a7a10..e91e6ff23a2 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/header.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/header.hpp @@ -2,7 +2,7 @@ // header.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/main.cpp b/3rdparty/asio/src/examples/cpp11/http/server/main.cpp index 44fc930f494..b76044a96cd 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/main.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/main.cpp @@ -2,7 +2,7 @@ // main.cpp // ~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/mime_types.cpp b/3rdparty/asio/src/examples/cpp11/http/server/mime_types.cpp index eb779197189..23153caa1df 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/mime_types.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/mime_types.cpp @@ -2,7 +2,7 @@ // mime_types.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/mime_types.hpp b/3rdparty/asio/src/examples/cpp11/http/server/mime_types.hpp index 2fc0332791f..fcefce5437b 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/mime_types.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/mime_types.hpp @@ -2,7 +2,7 @@ // mime_types.hpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/reply.cpp b/3rdparty/asio/src/examples/cpp11/http/server/reply.cpp index 2c9901312bb..9d8f04e2ae1 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/reply.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/reply.cpp @@ -2,7 +2,7 @@ // reply.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/reply.hpp b/3rdparty/asio/src/examples/cpp11/http/server/reply.hpp index 5189ac4363e..f1eee1f891b 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/reply.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/reply.hpp @@ -2,7 +2,7 @@ // reply.hpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/request.hpp b/3rdparty/asio/src/examples/cpp11/http/server/request.hpp index 129a3990b3d..93a96db12b4 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/request.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/request.hpp @@ -2,7 +2,7 @@ // request.hpp // ~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/request_handler.cpp b/3rdparty/asio/src/examples/cpp11/http/server/request_handler.cpp index c346ab9791e..97b4ac6a8e6 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/request_handler.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/request_handler.cpp @@ -2,7 +2,7 @@ // request_handler.cpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/request_handler.hpp b/3rdparty/asio/src/examples/cpp11/http/server/request_handler.hpp index 24cca33565a..978b37ca537 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/request_handler.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/request_handler.hpp @@ -2,7 +2,7 @@ // request_handler.hpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/request_parser.cpp b/3rdparty/asio/src/examples/cpp11/http/server/request_parser.cpp index 6812a558879..ff56e9c618a 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/request_parser.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/request_parser.cpp @@ -2,7 +2,7 @@ // request_parser.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/request_parser.hpp b/3rdparty/asio/src/examples/cpp11/http/server/request_parser.hpp index 643dd71c6f4..260e8759acb 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/request_parser.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/request_parser.hpp @@ -2,7 +2,7 @@ // request_parser.hpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/server.cpp b/3rdparty/asio/src/examples/cpp11/http/server/server.cpp index fa76a4def03..d824ebbf229 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/server.cpp @@ -2,7 +2,7 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server/server.hpp b/3rdparty/asio/src/examples/cpp11/http/server/server.hpp index 4f98f6cd07f..c88d0149114 100644 --- a/3rdparty/asio/src/examples/cpp11/http/server/server.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server/server.hpp @@ -2,7 +2,7 @@ // server.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/http/server2/connection.cpp b/3rdparty/asio/src/examples/cpp11/http/server2/connection.cpp new file mode 100644 index 00000000000..ab8ab9e0524 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/http/server2/connection.cpp @@ -0,0 +1,89 @@ +// +// connection.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "connection.hpp" +#include <utility> +#include "request_handler.hpp" + +namespace http { +namespace server2 { + +connection::connection(asio::ip::tcp::socket socket, + request_handler& handler) + : socket_(std::move(socket)), + request_handler_(handler) +{ +} + +void connection::start() +{ + do_read(); +} + +void connection::do_read() +{ + auto self(shared_from_this()); + socket_.async_read_some(asio::buffer(buffer_), + [this, self](std::error_code ec, std::size_t bytes_transferred) + { + if (!ec) + { + request_parser::result_type result; + std::tie(result, std::ignore) = request_parser_.parse( + request_, buffer_.data(), buffer_.data() + bytes_transferred); + + if (result == request_parser::good) + { + request_handler_.handle_request(request_, reply_); + do_write(); + } + else if (result == request_parser::bad) + { + reply_ = reply::stock_reply(reply::bad_request); + do_write(); + } + else + { + do_read(); + } + } + + // If an error occurs then no new asynchronous operations are + // started. This means that all shared_ptr references to the + // connection object will disappear and the object will be + // destroyed automatically after this handler returns. The + // connection class's destructor closes the socket. + }); +} + +void connection::do_write() +{ + auto self(shared_from_this()); + asio::async_write(socket_, reply_.to_buffers(), + [this, self](std::error_code ec, std::size_t) + { + if (!ec) + { + // Initiate graceful connection closure. + std::error_code ignored_ec; + socket_.shutdown(asio::ip::tcp::socket::shutdown_both, + ignored_ec); + } + + // No new asynchronous operations are started. This means that + // all shared_ptr references to the connection object will + // disappear and the object will be destroyed automatically after + // this handler returns. The connection class's destructor closes + // the socket. + }); +} + +} // namespace server2 +} // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/connection.hpp b/3rdparty/asio/src/examples/cpp11/http/server2/connection.hpp index 9c624a8a172..7d4a4735754 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/connection.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/connection.hpp @@ -2,7 +2,7 @@ // connection.hpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,10 +12,8 @@ #define HTTP_SERVER2_CONNECTION_HPP #include <asio.hpp> -#include <boost/array.hpp> -#include <boost/noncopyable.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> +#include <array> +#include <memory> #include "reply.hpp" #include "request.hpp" #include "request_handler.hpp" @@ -26,27 +24,25 @@ namespace server2 { /// Represents a single connection from a client. class connection - : public boost::enable_shared_from_this<connection>, - private boost::noncopyable + : public std::enable_shared_from_this<connection> { public: - /// Construct a connection with the given io_context. - explicit connection(asio::io_context& io_context, - request_handler& handler); + connection(const connection&) = delete; + connection& operator=(const connection&) = delete; - /// Get the socket associated with the connection. - asio::ip::tcp::socket& socket(); + /// Construct a connection with the given socket. + explicit connection(asio::ip::tcp::socket socket, + request_handler& handler); /// Start the first asynchronous operation for the connection. void start(); private: - /// Handle completion of a read operation. - void handle_read(const asio::error_code& e, - std::size_t bytes_transferred); + /// Perform an asynchronous read operation. + void do_read(); - /// Handle completion of a write operation. - void handle_write(const asio::error_code& e); + /// Perform an asynchronous write operation. + void do_write(); /// Socket for the connection. asio::ip::tcp::socket socket_; @@ -55,7 +51,7 @@ private: request_handler& request_handler_; /// Buffer for incoming data. - boost::array<char, 8192> buffer_; + std::array<char, 8192> buffer_; /// The incoming request. request request_; @@ -67,7 +63,7 @@ private: reply reply_; }; -typedef boost::shared_ptr<connection> connection_ptr; +typedef std::shared_ptr<connection> connection_ptr; } // namespace server2 } // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/header.hpp b/3rdparty/asio/src/examples/cpp11/http/server2/header.hpp index 0e44c551409..f888dde03c0 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/header.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/header.hpp @@ -2,7 +2,7 @@ // header.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/io_context_pool.cpp b/3rdparty/asio/src/examples/cpp11/http/server2/io_context_pool.cpp index 049ac988615..bea08903087 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/io_context_pool.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/io_context_pool.cpp @@ -2,7 +2,7 @@ // io_context_pool.cpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,8 +10,7 @@ #include "server.hpp" #include <stdexcept> -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> +#include <thread> namespace http { namespace server2 { @@ -35,17 +34,13 @@ io_context_pool::io_context_pool(std::size_t pool_size) void io_context_pool::run() { // Create a pool of threads to run all of the io_contexts. - std::vector<boost::shared_ptr<asio::thread> > threads; + std::vector<std::thread> threads; for (std::size_t i = 0; i < io_contexts_.size(); ++i) - { - boost::shared_ptr<asio::thread> thread(new asio::thread( - boost::bind(&asio::io_context::run, io_contexts_[i]))); - threads.push_back(thread); - } + threads.emplace_back([this, i]{ io_contexts_[i]->run(); }); // Wait for all threads in the pool to exit. for (std::size_t i = 0; i < threads.size(); ++i) - threads[i]->join(); + threads[i].join(); } void io_context_pool::stop() diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/io_context_pool.hpp b/3rdparty/asio/src/examples/cpp11/http/server2/io_context_pool.hpp index 6a573c539f6..0946ba6e484 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/io_context_pool.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/io_context_pool.hpp @@ -2,7 +2,7 @@ // io_context_pool.hpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,16 +12,15 @@ #define HTTP_SERVER2_IO_SERVICE_POOL_HPP #include <asio.hpp> +#include <list> +#include <memory> #include <vector> -#include <boost/noncopyable.hpp> -#include <boost/shared_ptr.hpp> namespace http { namespace server2 { /// A pool of io_context objects. class io_context_pool - : private boost::noncopyable { public: /// Construct the io_context pool. @@ -37,7 +36,10 @@ public: asio::io_context& get_io_context(); private: - typedef boost::shared_ptr<asio::io_context> io_context_ptr; + io_context_pool(const io_context_pool&) = delete; + io_context_pool& operator=(const io_context_pool&) = delete; + + typedef std::shared_ptr<asio::io_context> io_context_ptr; typedef asio::executor_work_guard< asio::io_context::executor_type> io_context_work; @@ -45,7 +47,7 @@ private: std::vector<io_context_ptr> io_contexts_; /// The work that keeps the io_contexts running. - std::vector<io_context_work> work_; + std::list<io_context_work> work_; /// The next io_context to use for a connection. std::size_t next_io_context_; diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/main.cpp b/3rdparty/asio/src/examples/cpp11/http/server2/main.cpp index 2d224c5bac1..5b6a9a36cb3 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/main.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/main.cpp @@ -2,7 +2,7 @@ // main.cpp // ~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,8 +11,6 @@ #include <iostream> #include <string> #include <asio.hpp> -#include <boost/bind.hpp> -#include <boost/lexical_cast.hpp> #include "server.hpp" int main(int argc, char* argv[]) @@ -31,7 +29,7 @@ int main(int argc, char* argv[]) } // Initialise the server. - std::size_t num_threads = boost::lexical_cast<std::size_t>(argv[3]); + std::size_t num_threads = std::stoi(argv[3]); http::server2::server s(argv[1], argv[2], argv[4], num_threads); // Run the server until stopped. diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/mime_types.cpp b/3rdparty/asio/src/examples/cpp11/http/server2/mime_types.cpp index 640f3aedc44..03079331e93 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/mime_types.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/mime_types.cpp @@ -2,7 +2,7 @@ // mime_types.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/mime_types.hpp b/3rdparty/asio/src/examples/cpp11/http/server2/mime_types.hpp index 57d1412b7b1..32985c18e59 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/mime_types.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/mime_types.hpp @@ -2,7 +2,7 @@ // mime_types.hpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/reply.cpp b/3rdparty/asio/src/examples/cpp11/http/server2/reply.cpp index 958577b2ce4..d48bfd9e463 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/reply.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/reply.cpp @@ -2,7 +2,7 @@ // reply.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,6 @@ #include "reply.hpp" #include <string> -#include <boost/lexical_cast.hpp> namespace http { namespace server2 { @@ -246,7 +245,7 @@ reply reply::stock_reply(reply::status_type status) rep.content = stock_replies::to_string(status); rep.headers.resize(2); rep.headers[0].name = "Content-Length"; - rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size()); + rep.headers[0].value = std::to_string(rep.content.size()); rep.headers[1].name = "Content-Type"; rep.headers[1].value = "text/html"; return rep; diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/reply.hpp b/3rdparty/asio/src/examples/cpp11/http/server2/reply.hpp index 17f11e7dde3..f4be7ca94fe 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/reply.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/reply.hpp @@ -2,7 +2,7 @@ // reply.hpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/request.hpp b/3rdparty/asio/src/examples/cpp11/http/server2/request.hpp index 39070ee2f84..b0000b00967 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/request.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/request.hpp @@ -2,7 +2,7 @@ // request.hpp // ~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/request_handler.cpp b/3rdparty/asio/src/examples/cpp11/http/server2/request_handler.cpp index 9369c107166..c57fa9757f5 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/request_handler.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/request_handler.cpp @@ -2,7 +2,7 @@ // request_handler.cpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,7 +12,6 @@ #include <fstream> #include <sstream> #include <string> -#include <boost/lexical_cast.hpp> #include "mime_types.hpp" #include "reply.hpp" #include "request.hpp" @@ -74,7 +73,7 @@ void request_handler::handle_request(const request& req, reply& rep) rep.content.append(buf, is.gcount()); rep.headers.resize(2); rep.headers[0].name = "Content-Length"; - rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size()); + rep.headers[0].value = std::to_string(rep.content.size()); rep.headers[1].name = "Content-Type"; rep.headers[1].value = mime_types::extension_to_type(extension); } diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/request_handler.hpp b/3rdparty/asio/src/examples/cpp11/http/server2/request_handler.hpp index 8d24686fa54..c9e9ebf418f 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/request_handler.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/request_handler.hpp @@ -2,7 +2,7 @@ // request_handler.hpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,7 +12,6 @@ #define HTTP_SERVER2_REQUEST_HANDLER_HPP #include <string> -#include <boost/noncopyable.hpp> namespace http { namespace server2 { @@ -22,9 +21,11 @@ struct request; /// The common handler for all incoming requests. class request_handler - : private boost::noncopyable { public: + request_handler(const request_handler&) = delete; + request_handler& operator=(const request_handler&) = delete; + /// Construct with a directory containing files to be served. explicit request_handler(const std::string& doc_root); diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/request_parser.cpp b/3rdparty/asio/src/examples/cpp11/http/server2/request_parser.cpp index ae80b20f784..2cd8ac00b47 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/request_parser.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/request_parser.cpp @@ -2,7 +2,7 @@ // request_parser.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -24,90 +24,90 @@ void request_parser::reset() state_ = method_start; } -boost::tribool request_parser::consume(request& req, char input) +request_parser::result_type request_parser::consume(request& req, char input) { switch (state_) { case method_start: if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { state_ = method; req.method.push_back(input); - return boost::indeterminate; + return indeterminate; } case method: if (input == ' ') { state_ = uri; - return boost::indeterminate; + return indeterminate; } else if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { req.method.push_back(input); - return boost::indeterminate; + return indeterminate; } case uri: if (input == ' ') { state_ = http_version_h; - return boost::indeterminate; + return indeterminate; } else if (is_ctl(input)) { - return false; + return bad; } else { req.uri.push_back(input); - return boost::indeterminate; + return indeterminate; } case http_version_h: if (input == 'H') { state_ = http_version_t_1; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_t_1: if (input == 'T') { state_ = http_version_t_2; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_t_2: if (input == 'T') { state_ = http_version_p; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_p: if (input == 'P') { state_ = http_version_slash; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_slash: if (input == '/') @@ -115,170 +115,170 @@ boost::tribool request_parser::consume(request& req, char input) req.http_version_major = 0; req.http_version_minor = 0; state_ = http_version_major_start; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_major_start: if (is_digit(input)) { req.http_version_major = req.http_version_major * 10 + input - '0'; state_ = http_version_major; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_major: if (input == '.') { state_ = http_version_minor_start; - return boost::indeterminate; + return indeterminate; } else if (is_digit(input)) { req.http_version_major = req.http_version_major * 10 + input - '0'; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_minor_start: if (is_digit(input)) { req.http_version_minor = req.http_version_minor * 10 + input - '0'; state_ = http_version_minor; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_minor: if (input == '\r') { state_ = expecting_newline_1; - return boost::indeterminate; + return indeterminate; } else if (is_digit(input)) { req.http_version_minor = req.http_version_minor * 10 + input - '0'; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case expecting_newline_1: if (input == '\n') { state_ = header_line_start; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case header_line_start: if (input == '\r') { state_ = expecting_newline_3; - return boost::indeterminate; + return indeterminate; } else if (!req.headers.empty() && (input == ' ' || input == '\t')) { state_ = header_lws; - return boost::indeterminate; + return indeterminate; } else if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { req.headers.push_back(header()); req.headers.back().name.push_back(input); state_ = header_name; - return boost::indeterminate; + return indeterminate; } case header_lws: if (input == '\r') { state_ = expecting_newline_2; - return boost::indeterminate; + return indeterminate; } else if (input == ' ' || input == '\t') { - return boost::indeterminate; + return indeterminate; } else if (is_ctl(input)) { - return false; + return bad; } else { state_ = header_value; req.headers.back().value.push_back(input); - return boost::indeterminate; + return indeterminate; } case header_name: if (input == ':') { state_ = space_before_header_value; - return boost::indeterminate; + return indeterminate; } else if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { req.headers.back().name.push_back(input); - return boost::indeterminate; + return indeterminate; } case space_before_header_value: if (input == ' ') { state_ = header_value; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case header_value: if (input == '\r') { state_ = expecting_newline_2; - return boost::indeterminate; + return indeterminate; } else if (is_ctl(input)) { - return false; + return bad; } else { req.headers.back().value.push_back(input); - return boost::indeterminate; + return indeterminate; } case expecting_newline_2: if (input == '\n') { state_ = header_line_start; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case expecting_newline_3: - return (input == '\n'); + return (input == '\n') ? good : bad; default: - return false; + return bad; } } diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/request_parser.hpp b/3rdparty/asio/src/examples/cpp11/http/server2/request_parser.hpp index 133a6492058..1d11168b72d 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/request_parser.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/request_parser.hpp @@ -2,7 +2,7 @@ // request_parser.hpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,8 +11,7 @@ #ifndef HTTP_SERVER2_REQUEST_PARSER_HPP #define HTTP_SERVER2_REQUEST_PARSER_HPP -#include <boost/logic/tribool.hpp> -#include <boost/tuple/tuple.hpp> +#include <tuple> namespace http { namespace server2 { @@ -29,27 +28,29 @@ public: /// Reset to initial parser state. void reset(); - /// Parse some data. The tribool return value is true when a complete request - /// has been parsed, false if the data is invalid, indeterminate when more - /// data is required. The InputIterator return value indicates how much of the - /// input has been consumed. + /// Result of parse. + enum result_type { good, bad, indeterminate }; + + /// Parse some data. The enum return value is good when a complete request has + /// been parsed, bad if the data is invalid, indeterminate when more data is + /// required. The InputIterator return value indicates how much of the input + /// has been consumed. template <typename InputIterator> - boost::tuple<boost::tribool, InputIterator> parse(request& req, + std::tuple<result_type, InputIterator> parse(request& req, InputIterator begin, InputIterator end) { while (begin != end) { - boost::tribool result = consume(req, *begin++); - if (result || !result) - return boost::make_tuple(result, begin); + result_type result = consume(req, *begin++); + if (result == good || result == bad) + return std::make_tuple(result, begin); } - boost::tribool result = boost::indeterminate; - return boost::make_tuple(result, begin); + return std::make_tuple(indeterminate, begin); } private: /// Handle the next character of input. - boost::tribool consume(request& req, char input); + result_type consume(request& req, char input); /// Check if a byte is an HTTP character. static bool is_char(int c); diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/server.cpp b/3rdparty/asio/src/examples/cpp11/http/server2/server.cpp index 75d3a48aa84..2ae733086a5 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/server.cpp @@ -2,14 +2,16 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "server.hpp" -#include <boost/bind.hpp> +#include <signal.h> +#include <utility> +#include "connection.hpp" namespace http { namespace server2 { @@ -19,7 +21,6 @@ server::server(const std::string& address, const std::string& port, : io_context_pool_(io_context_pool_size), signals_(io_context_pool_.get_io_context()), acceptor_(io_context_pool_.get_io_context()), - new_connection_(), request_handler_(doc_root) { // Register to handle the signals that indicate when the server should exit. @@ -30,10 +31,11 @@ server::server(const std::string& address, const std::string& port, #if defined(SIGQUIT) signals_.add(SIGQUIT); #endif // defined(SIGQUIT) - signals_.async_wait(boost::bind(&server::handle_stop, this)); + + do_await_stop(); // Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR). - asio::ip::tcp::resolver resolver(acceptor_.get_executor().context()); + asio::ip::tcp::resolver resolver(acceptor_.get_executor()); asio::ip::tcp::endpoint endpoint = *resolver.resolve(address, port).begin(); acceptor_.open(endpoint.protocol()); @@ -41,7 +43,7 @@ server::server(const std::string& address, const std::string& port, acceptor_.bind(endpoint); acceptor_.listen(); - start_accept(); + do_accept(); } void server::run() @@ -49,28 +51,35 @@ void server::run() io_context_pool_.run(); } -void server::start_accept() +void server::do_accept() { - new_connection_.reset(new connection( - io_context_pool_.get_io_context(), request_handler_)); - acceptor_.async_accept(new_connection_->socket(), - boost::bind(&server::handle_accept, this, - asio::placeholders::error)); -} + acceptor_.async_accept(io_context_pool_.get_io_context(), + [this](std::error_code ec, asio::ip::tcp::socket socket) + { + // Check whether the server was stopped by a signal before this + // completion handler had a chance to run. + if (!acceptor_.is_open()) + { + return; + } -void server::handle_accept(const asio::error_code& e) -{ - if (!e) - { - new_connection_->start(); - } + if (!ec) + { + std::make_shared<connection>( + std::move(socket), request_handler_)->start(); + } - start_accept(); + do_accept(); + }); } -void server::handle_stop() +void server::do_await_stop() { - io_context_pool_.stop(); + signals_.async_wait( + [this](std::error_code /*ec*/, int /*signo*/) + { + io_context_pool_.stop(); + }); } } // namespace server2 diff --git a/3rdparty/asio/src/examples/cpp03/http/server2/server.hpp b/3rdparty/asio/src/examples/cpp11/http/server2/server.hpp index 6a742a8220a..9d34a77ed7c 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server2/server.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server2/server.hpp @@ -2,7 +2,7 @@ // server.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,10 +13,6 @@ #include <asio.hpp> #include <string> -#include <vector> -#include <boost/noncopyable.hpp> -#include <boost/shared_ptr.hpp> -#include "connection.hpp" #include "io_context_pool.hpp" #include "request_handler.hpp" @@ -25,9 +21,11 @@ namespace server2 { /// The top-level class of the HTTP server. class server - : private boost::noncopyable { public: + server(const server&) = delete; + server& operator=(const server&) = delete; + /// Construct the server to listen on the specified TCP address and port, and /// serve up files from the given directory. explicit server(const std::string& address, const std::string& port, @@ -37,14 +35,11 @@ public: void run(); private: - /// Initiate an asynchronous accept operation. - void start_accept(); - - /// Handle completion of an asynchronous accept operation. - void handle_accept(const asio::error_code& e); + /// Perform an asynchronous accept operation. + void do_accept(); - /// Handle a request to stop the server. - void handle_stop(); + /// Wait for a request to stop the server. + void do_await_stop(); /// The pool of io_context objects used to perform asynchronous operations. io_context_pool io_context_pool_; @@ -55,9 +50,6 @@ private: /// Acceptor used to listen for incoming connections. asio::ip::tcp::acceptor acceptor_; - /// The next connection to be accepted. - connection_ptr new_connection_; - /// The handler for all incoming requests. request_handler request_handler_; }; diff --git a/3rdparty/asio/src/examples/cpp11/http/server3/connection.cpp b/3rdparty/asio/src/examples/cpp11/http/server3/connection.cpp new file mode 100644 index 00000000000..d4070364fb4 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/http/server3/connection.cpp @@ -0,0 +1,89 @@ +// +// connection.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "connection.hpp" +#include <utility> +#include "request_handler.hpp" + +namespace http { +namespace server3 { + +connection::connection(asio::ip::tcp::socket socket, + request_handler& handler) + : socket_(std::move(socket)), + request_handler_(handler) +{ +} + +void connection::start() +{ + do_read(); +} + +void connection::do_read() +{ + auto self(shared_from_this()); + socket_.async_read_some(asio::buffer(buffer_), + [this, self](std::error_code ec, std::size_t bytes_transferred) + { + if (!ec) + { + request_parser::result_type result; + std::tie(result, std::ignore) = request_parser_.parse( + request_, buffer_.data(), buffer_.data() + bytes_transferred); + + if (result == request_parser::good) + { + request_handler_.handle_request(request_, reply_); + do_write(); + } + else if (result == request_parser::bad) + { + reply_ = reply::stock_reply(reply::bad_request); + do_write(); + } + else + { + do_read(); + } + } + + // If an error occurs then no new asynchronous operations are + // started. This means that all shared_ptr references to the + // connection object will disappear and the object will be + // destroyed automatically after this handler returns. The + // connection class's destructor closes the socket. + }); +} + +void connection::do_write() +{ + auto self(shared_from_this()); + asio::async_write(socket_, reply_.to_buffers(), + [this, self](std::error_code ec, std::size_t) + { + if (!ec) + { + // Initiate graceful connection closure. + std::error_code ignored_ec; + socket_.shutdown(asio::ip::tcp::socket::shutdown_both, + ignored_ec); + } + + // No new asynchronous operations are started. This means that + // all shared_ptr references to the connection object will + // disappear and the object will be destroyed automatically after + // this handler returns. The connection class's destructor closes + // the socket. + }); +} + +} // namespace server3 +} // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/connection.hpp b/3rdparty/asio/src/examples/cpp11/http/server3/connection.hpp index 2aac1a5c7ae..878cd45d366 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/connection.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/connection.hpp @@ -2,7 +2,7 @@ // connection.hpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,10 +12,8 @@ #define HTTP_SERVER3_CONNECTION_HPP #include <asio.hpp> -#include <boost/array.hpp> -#include <boost/noncopyable.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> +#include <array> +#include <memory> #include "reply.hpp" #include "request.hpp" #include "request_handler.hpp" @@ -26,30 +24,25 @@ namespace server3 { /// Represents a single connection from a client. class connection - : public boost::enable_shared_from_this<connection>, - private boost::noncopyable + : public std::enable_shared_from_this<connection> { public: - /// Construct a connection with the given io_context. - explicit connection(asio::io_context& io_context, - request_handler& handler); + connection(const connection&) = delete; + connection& operator=(const connection&) = delete; - /// Get the socket associated with the connection. - asio::ip::tcp::socket& socket(); + /// Construct a connection with the given socket. + explicit connection(asio::ip::tcp::socket socket, + request_handler& handler); /// Start the first asynchronous operation for the connection. void start(); private: - /// Handle completion of a read operation. - void handle_read(const asio::error_code& e, - std::size_t bytes_transferred); - - /// Handle completion of a write operation. - void handle_write(const asio::error_code& e); + /// Perform an asynchronous read operation. + void do_read(); - /// Strand to ensure the connection's handlers are not called concurrently. - asio::io_context::strand strand_; + /// Perform an asynchronous write operation. + void do_write(); /// Socket for the connection. asio::ip::tcp::socket socket_; @@ -58,7 +51,7 @@ private: request_handler& request_handler_; /// Buffer for incoming data. - boost::array<char, 8192> buffer_; + std::array<char, 8192> buffer_; /// The incoming request. request request_; @@ -70,7 +63,7 @@ private: reply reply_; }; -typedef boost::shared_ptr<connection> connection_ptr; +typedef std::shared_ptr<connection> connection_ptr; } // namespace server3 } // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/header.hpp b/3rdparty/asio/src/examples/cpp11/http/server3/header.hpp index 207c6290784..8ab5d145a6d 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/header.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/header.hpp @@ -2,7 +2,7 @@ // header.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/main.cpp b/3rdparty/asio/src/examples/cpp11/http/server3/main.cpp index 367efad729f..243de69bc75 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/main.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/main.cpp @@ -2,7 +2,7 @@ // main.cpp // ~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,8 +11,6 @@ #include <iostream> #include <string> #include <asio.hpp> -#include <boost/bind.hpp> -#include <boost/lexical_cast.hpp> #include "server.hpp" int main(int argc, char* argv[]) @@ -31,7 +29,7 @@ int main(int argc, char* argv[]) } // Initialise the server. - std::size_t num_threads = boost::lexical_cast<std::size_t>(argv[3]); + std::size_t num_threads = std::stoi(argv[3]); http::server3::server s(argv[1], argv[2], argv[4], num_threads); // Run the server until stopped. diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/mime_types.cpp b/3rdparty/asio/src/examples/cpp11/http/server3/mime_types.cpp index 0b0c66e3ce4..d0d804c7caa 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/mime_types.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/mime_types.cpp @@ -2,7 +2,7 @@ // mime_types.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/mime_types.hpp b/3rdparty/asio/src/examples/cpp11/http/server3/mime_types.hpp index 502766aa5ab..a144c8677e6 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/mime_types.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/mime_types.hpp @@ -2,7 +2,7 @@ // mime_types.hpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/reply.cpp b/3rdparty/asio/src/examples/cpp11/http/server3/reply.cpp index 79790a1df77..4695d4a8da2 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/reply.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/reply.cpp @@ -2,7 +2,7 @@ // reply.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,6 @@ #include "reply.hpp" #include <string> -#include <boost/lexical_cast.hpp> namespace http { namespace server3 { @@ -246,7 +245,7 @@ reply reply::stock_reply(reply::status_type status) rep.content = stock_replies::to_string(status); rep.headers.resize(2); rep.headers[0].name = "Content-Length"; - rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size()); + rep.headers[0].value = std::to_string(rep.content.size()); rep.headers[1].name = "Content-Type"; rep.headers[1].value = "text/html"; return rep; diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/reply.hpp b/3rdparty/asio/src/examples/cpp11/http/server3/reply.hpp index 9b057ca351d..fd9c7ed9ed5 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/reply.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/reply.hpp @@ -2,7 +2,7 @@ // reply.hpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/request.hpp b/3rdparty/asio/src/examples/cpp11/http/server3/request.hpp index a5b34e03f8a..89a2f285b7a 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/request.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/request.hpp @@ -2,7 +2,7 @@ // request.hpp // ~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/request_handler.cpp b/3rdparty/asio/src/examples/cpp11/http/server3/request_handler.cpp index 9feb1cf1e3c..bdc6bd60892 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/request_handler.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/request_handler.cpp @@ -2,7 +2,7 @@ // request_handler.cpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,7 +12,6 @@ #include <fstream> #include <sstream> #include <string> -#include <boost/lexical_cast.hpp> #include "mime_types.hpp" #include "reply.hpp" #include "request.hpp" @@ -74,7 +73,7 @@ void request_handler::handle_request(const request& req, reply& rep) rep.content.append(buf, is.gcount()); rep.headers.resize(2); rep.headers[0].name = "Content-Length"; - rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size()); + rep.headers[0].value = std::to_string(rep.content.size()); rep.headers[1].name = "Content-Type"; rep.headers[1].value = mime_types::extension_to_type(extension); } diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/request_handler.hpp b/3rdparty/asio/src/examples/cpp11/http/server3/request_handler.hpp index bb94cad0d1d..e3fe84ed0cb 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/request_handler.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/request_handler.hpp @@ -2,7 +2,7 @@ // request_handler.hpp // ~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,7 +12,6 @@ #define HTTP_SERVER3_REQUEST_HANDLER_HPP #include <string> -#include <boost/noncopyable.hpp> namespace http { namespace server3 { @@ -22,9 +21,11 @@ struct request; /// The common handler for all incoming requests. class request_handler - : private boost::noncopyable { public: + request_handler(const request_handler&) = delete; + request_handler& operator=(const request_handler&) = delete; + /// Construct with a directory containing files to be served. explicit request_handler(const std::string& doc_root); diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/request_parser.cpp b/3rdparty/asio/src/examples/cpp11/http/server3/request_parser.cpp index 98f91286fe8..9fb6424fad7 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/request_parser.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/request_parser.cpp @@ -2,7 +2,7 @@ // request_parser.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -24,90 +24,90 @@ void request_parser::reset() state_ = method_start; } -boost::tribool request_parser::consume(request& req, char input) +request_parser::result_type request_parser::consume(request& req, char input) { switch (state_) { case method_start: if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { state_ = method; req.method.push_back(input); - return boost::indeterminate; + return indeterminate; } case method: if (input == ' ') { state_ = uri; - return boost::indeterminate; + return indeterminate; } else if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { req.method.push_back(input); - return boost::indeterminate; + return indeterminate; } case uri: if (input == ' ') { state_ = http_version_h; - return boost::indeterminate; + return indeterminate; } else if (is_ctl(input)) { - return false; + return bad; } else { req.uri.push_back(input); - return boost::indeterminate; + return indeterminate; } case http_version_h: if (input == 'H') { state_ = http_version_t_1; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_t_1: if (input == 'T') { state_ = http_version_t_2; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_t_2: if (input == 'T') { state_ = http_version_p; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_p: if (input == 'P') { state_ = http_version_slash; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_slash: if (input == '/') @@ -115,170 +115,170 @@ boost::tribool request_parser::consume(request& req, char input) req.http_version_major = 0; req.http_version_minor = 0; state_ = http_version_major_start; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_major_start: if (is_digit(input)) { req.http_version_major = req.http_version_major * 10 + input - '0'; state_ = http_version_major; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_major: if (input == '.') { state_ = http_version_minor_start; - return boost::indeterminate; + return indeterminate; } else if (is_digit(input)) { req.http_version_major = req.http_version_major * 10 + input - '0'; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_minor_start: if (is_digit(input)) { req.http_version_minor = req.http_version_minor * 10 + input - '0'; state_ = http_version_minor; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_minor: if (input == '\r') { state_ = expecting_newline_1; - return boost::indeterminate; + return indeterminate; } else if (is_digit(input)) { req.http_version_minor = req.http_version_minor * 10 + input - '0'; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case expecting_newline_1: if (input == '\n') { state_ = header_line_start; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case header_line_start: if (input == '\r') { state_ = expecting_newline_3; - return boost::indeterminate; + return indeterminate; } else if (!req.headers.empty() && (input == ' ' || input == '\t')) { state_ = header_lws; - return boost::indeterminate; + return indeterminate; } else if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { req.headers.push_back(header()); req.headers.back().name.push_back(input); state_ = header_name; - return boost::indeterminate; + return indeterminate; } case header_lws: if (input == '\r') { state_ = expecting_newline_2; - return boost::indeterminate; + return indeterminate; } else if (input == ' ' || input == '\t') { - return boost::indeterminate; + return indeterminate; } else if (is_ctl(input)) { - return false; + return bad; } else { state_ = header_value; req.headers.back().value.push_back(input); - return boost::indeterminate; + return indeterminate; } case header_name: if (input == ':') { state_ = space_before_header_value; - return boost::indeterminate; + return indeterminate; } else if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { req.headers.back().name.push_back(input); - return boost::indeterminate; + return indeterminate; } case space_before_header_value: if (input == ' ') { state_ = header_value; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case header_value: if (input == '\r') { state_ = expecting_newline_2; - return boost::indeterminate; + return indeterminate; } else if (is_ctl(input)) { - return false; + return bad; } else { req.headers.back().value.push_back(input); - return boost::indeterminate; + return indeterminate; } case expecting_newline_2: if (input == '\n') { state_ = header_line_start; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case expecting_newline_3: - return (input == '\n'); + return (input == '\n') ? good : bad; default: - return false; + return bad; } } diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/request_parser.hpp b/3rdparty/asio/src/examples/cpp11/http/server3/request_parser.hpp index b680eee037b..a8334ed13ee 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/request_parser.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/request_parser.hpp @@ -2,7 +2,7 @@ // request_parser.hpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,8 +11,7 @@ #ifndef HTTP_SERVER3_REQUEST_PARSER_HPP #define HTTP_SERVER3_REQUEST_PARSER_HPP -#include <boost/logic/tribool.hpp> -#include <boost/tuple/tuple.hpp> +#include <tuple> namespace http { namespace server3 { @@ -29,27 +28,29 @@ public: /// Reset to initial parser state. void reset(); - /// Parse some data. The tribool return value is true when a complete request - /// has been parsed, false if the data is invalid, indeterminate when more - /// data is required. The InputIterator return value indicates how much of the - /// input has been consumed. + /// Result of parse. + enum result_type { good, bad, indeterminate }; + + /// Parse some data. The enum return value is good when a complete request has + /// been parsed, bad if the data is invalid, indeterminate when more data is + /// required. The InputIterator return value indicates how much of the input + /// has been consumed. template <typename InputIterator> - boost::tuple<boost::tribool, InputIterator> parse(request& req, + std::tuple<result_type, InputIterator> parse(request& req, InputIterator begin, InputIterator end) { while (begin != end) { - boost::tribool result = consume(req, *begin++); - if (result || !result) - return boost::make_tuple(result, begin); + result_type result = consume(req, *begin++); + if (result == good || result == bad) + return std::make_tuple(result, begin); } - boost::tribool result = boost::indeterminate; - return boost::make_tuple(result, begin); + return std::make_tuple(indeterminate, begin); } private: /// Handle the next character of input. - boost::tribool consume(request& req, char input); + result_type consume(request& req, char input); /// Check if a byte is an HTTP character. static bool is_char(int c); diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/server.cpp b/3rdparty/asio/src/examples/cpp11/http/server3/server.cpp index 2a78bc9719e..c8da4b4f4db 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/server.cpp @@ -2,16 +2,18 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "server.hpp" -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> +#include <signal.h> +#include <thread> +#include <utility> #include <vector> +#include "connection.hpp" namespace http { namespace server3 { @@ -21,7 +23,6 @@ server::server(const std::string& address, const std::string& port, : thread_pool_size_(thread_pool_size), signals_(io_context_), acceptor_(io_context_), - new_connection_(), request_handler_(doc_root) { // Register to handle the signals that indicate when the server should exit. @@ -32,7 +33,8 @@ server::server(const std::string& address, const std::string& port, #if defined(SIGQUIT) signals_.add(SIGQUIT); #endif // defined(SIGQUIT) - signals_.async_wait(boost::bind(&server::handle_stop, this)); + + do_await_stop(); // Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR). asio::ip::tcp::resolver resolver(io_context_); @@ -43,46 +45,52 @@ server::server(const std::string& address, const std::string& port, acceptor_.bind(endpoint); acceptor_.listen(); - start_accept(); + do_accept(); } void server::run() { - // Create a pool of threads to run all of the io_contexts. - std::vector<boost::shared_ptr<asio::thread> > threads; + // Create a pool of threads to run the io_context. + std::vector<std::thread> threads; for (std::size_t i = 0; i < thread_pool_size_; ++i) - { - boost::shared_ptr<asio::thread> thread(new asio::thread( - boost::bind(&asio::io_context::run, &io_context_))); - threads.push_back(thread); - } + threads.emplace_back([this]{ io_context_.run(); }); // Wait for all threads in the pool to exit. for (std::size_t i = 0; i < threads.size(); ++i) - threads[i]->join(); + threads[i].join(); } -void server::start_accept() +void server::do_accept() { - new_connection_.reset(new connection(io_context_, request_handler_)); - acceptor_.async_accept(new_connection_->socket(), - boost::bind(&server::handle_accept, this, - asio::placeholders::error)); -} + // The newly accepted socket is put into its own strand to ensure that all + // completion handlers associated with the connection do not run concurrently. + acceptor_.async_accept(asio::make_strand(io_context_), + [this](std::error_code ec, asio::ip::tcp::socket socket) + { + // Check whether the server was stopped by a signal before this + // completion handler had a chance to run. + if (!acceptor_.is_open()) + { + return; + } -void server::handle_accept(const asio::error_code& e) -{ - if (!e) - { - new_connection_->start(); - } + if (!ec) + { + std::make_shared<connection>( + std::move(socket), request_handler_)->start(); + } - start_accept(); + do_accept(); + }); } -void server::handle_stop() +void server::do_await_stop() { - io_context_.stop(); + signals_.async_wait( + [this](std::error_code /*ec*/, int /*signo*/) + { + io_context_.stop(); + }); } } // namespace server3 diff --git a/3rdparty/asio/src/examples/cpp03/http/server3/server.hpp b/3rdparty/asio/src/examples/cpp11/http/server3/server.hpp index c58c2433f65..2948cadbf17 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server3/server.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server3/server.hpp @@ -2,7 +2,7 @@ // server.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,10 +13,6 @@ #include <asio.hpp> #include <string> -#include <vector> -#include <boost/noncopyable.hpp> -#include <boost/shared_ptr.hpp> -#include "connection.hpp" #include "request_handler.hpp" namespace http { @@ -24,9 +20,11 @@ namespace server3 { /// The top-level class of the HTTP server. class server - : private boost::noncopyable { public: + server(const server&) = delete; + server& operator=(const server&) = delete; + /// Construct the server to listen on the specified TCP address and port, and /// serve up files from the given directory. explicit server(const std::string& address, const std::string& port, @@ -36,14 +34,11 @@ public: void run(); private: - /// Initiate an asynchronous accept operation. - void start_accept(); - - /// Handle completion of an asynchronous accept operation. - void handle_accept(const asio::error_code& e); + /// Perform an asynchronous accept operation. + void do_accept(); - /// Handle a request to stop the server. - void handle_stop(); + /// Wait for a request to stop the server. + void do_await_stop(); /// The number of threads that will call io_context::run(). std::size_t thread_pool_size_; @@ -57,9 +52,6 @@ private: /// Acceptor used to listen for incoming connections. asio::ip::tcp::acceptor acceptor_; - /// The next connection to be accepted. - connection_ptr new_connection_; - /// The handler for all incoming requests. request_handler request_handler_; }; diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/file_handler.cpp b/3rdparty/asio/src/examples/cpp11/http/server4/file_handler.cpp index a4ac912b155..ad982e58b26 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server4/file_handler.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/file_handler.cpp @@ -2,7 +2,7 @@ // file_handler.cpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,7 +12,6 @@ #include <fstream> #include <sstream> #include <string> -#include <boost/lexical_cast.hpp> #include "mime_types.hpp" #include "reply.hpp" #include "request.hpp" @@ -74,7 +73,7 @@ void file_handler::operator()(const request& req, reply& rep) rep.content.append(buf, is.gcount()); rep.headers.resize(2); rep.headers[0].name = "Content-Length"; - rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size()); + rep.headers[0].value = std::to_string(rep.content.size()); rep.headers[1].name = "Content-Type"; rep.headers[1].value = mime_types::extension_to_type(extension); } diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/file_handler.hpp b/3rdparty/asio/src/examples/cpp11/http/server4/file_handler.hpp index 22055dbcb1b..a16e5b6905c 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server4/file_handler.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/file_handler.hpp @@ -2,7 +2,7 @@ // file_handler.hpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/header.hpp b/3rdparty/asio/src/examples/cpp11/http/server4/header.hpp index 9c9b89cca06..a4148e5d910 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server4/header.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/header.hpp @@ -2,7 +2,7 @@ // header.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/main.cpp b/3rdparty/asio/src/examples/cpp11/http/server4/main.cpp index 0ebe535ad17..29706e6a335 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server4/main.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/main.cpp @@ -2,7 +2,7 @@ // main.cpp // ~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,6 @@ #include <iostream> #include <asio.hpp> -#include <boost/bind.hpp> #include <signal.h> #include "server.hpp" #include "file_handler.hpp" @@ -43,8 +42,11 @@ int main(int argc, char* argv[]) #if defined(SIGQUIT) signals.add(SIGQUIT); #endif // defined(SIGQUIT) - signals.async_wait(boost::bind( - &asio::io_context::stop, &io_context)); + signals.async_wait( + [&io_context](std::error_code, int) + { + io_context.stop(); + }); // Run the server. io_context.run(); diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/mime_types.cpp b/3rdparty/asio/src/examples/cpp11/http/server4/mime_types.cpp index 903dffca59e..6cf11e383d8 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server4/mime_types.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/mime_types.cpp @@ -2,7 +2,7 @@ // mime_types.cpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/mime_types.hpp b/3rdparty/asio/src/examples/cpp11/http/server4/mime_types.hpp index f702c6f859b..6086fce22eb 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server4/mime_types.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/mime_types.hpp @@ -2,7 +2,7 @@ // mime_types.hpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/reply.cpp b/3rdparty/asio/src/examples/cpp11/http/server4/reply.cpp index f508a46765f..4e5752ea7d0 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server4/reply.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/reply.cpp @@ -2,7 +2,7 @@ // reply.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,6 @@ #include "reply.hpp" #include <string> -#include <boost/lexical_cast.hpp> namespace http { namespace server4 { @@ -246,7 +245,7 @@ reply reply::stock_reply(reply::status_type status) rep.content = stock_replies::to_string(status); rep.headers.resize(2); rep.headers[0].name = "Content-Length"; - rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size()); + rep.headers[0].value = std::to_string(rep.content.size()); rep.headers[1].name = "Content-Type"; rep.headers[1].value = "text/html"; return rep; diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/reply.hpp b/3rdparty/asio/src/examples/cpp11/http/server4/reply.hpp index 02743a549be..d08579a3339 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server4/reply.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/reply.hpp @@ -2,7 +2,7 @@ // reply.hpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/http/server/request.hpp b/3rdparty/asio/src/examples/cpp11/http/server4/request.hpp index 129a3990b3d..8b20c4db0db 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server/request.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/request.hpp @@ -2,21 +2,21 @@ // request.hpp // ~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef HTTP_REQUEST_HPP -#define HTTP_REQUEST_HPP +#ifndef HTTP_SERVER4_REQUEST_HPP +#define HTTP_SERVER4_REQUEST_HPP #include <string> #include <vector> #include "header.hpp" namespace http { -namespace server { +namespace server4 { /// A request received from a client. struct request @@ -28,7 +28,7 @@ struct request std::vector<header> headers; }; -} // namespace server +} // namespace server4 } // namespace http -#endif // HTTP_REQUEST_HPP +#endif // HTTP_SERVER4_REQUEST_HPP diff --git a/3rdparty/asio/src/examples/cpp03/http/server/request_parser.cpp b/3rdparty/asio/src/examples/cpp11/http/server4/request_parser.cpp index 80644eea529..ec557fccdd6 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server/request_parser.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/request_parser.cpp @@ -2,7 +2,7 @@ // request_parser.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,7 +12,7 @@ #include "request.hpp" namespace http { -namespace server { +namespace server4 { request_parser::request_parser() : state_(method_start) @@ -24,90 +24,90 @@ void request_parser::reset() state_ = method_start; } -boost::tribool request_parser::consume(request& req, char input) +request_parser::result_type request_parser::consume(request& req, char input) { switch (state_) { case method_start: if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { state_ = method; req.method.push_back(input); - return boost::indeterminate; + return indeterminate; } case method: if (input == ' ') { state_ = uri; - return boost::indeterminate; + return indeterminate; } else if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { req.method.push_back(input); - return boost::indeterminate; + return indeterminate; } case uri: if (input == ' ') { state_ = http_version_h; - return boost::indeterminate; + return indeterminate; } else if (is_ctl(input)) { - return false; + return bad; } else { req.uri.push_back(input); - return boost::indeterminate; + return indeterminate; } case http_version_h: if (input == 'H') { state_ = http_version_t_1; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_t_1: if (input == 'T') { state_ = http_version_t_2; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_t_2: if (input == 'T') { state_ = http_version_p; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_p: if (input == 'P') { state_ = http_version_slash; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_slash: if (input == '/') @@ -115,170 +115,170 @@ boost::tribool request_parser::consume(request& req, char input) req.http_version_major = 0; req.http_version_minor = 0; state_ = http_version_major_start; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_major_start: if (is_digit(input)) { req.http_version_major = req.http_version_major * 10 + input - '0'; state_ = http_version_major; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_major: if (input == '.') { state_ = http_version_minor_start; - return boost::indeterminate; + return indeterminate; } else if (is_digit(input)) { req.http_version_major = req.http_version_major * 10 + input - '0'; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_minor_start: if (is_digit(input)) { req.http_version_minor = req.http_version_minor * 10 + input - '0'; state_ = http_version_minor; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case http_version_minor: if (input == '\r') { state_ = expecting_newline_1; - return boost::indeterminate; + return indeterminate; } else if (is_digit(input)) { req.http_version_minor = req.http_version_minor * 10 + input - '0'; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case expecting_newline_1: if (input == '\n') { state_ = header_line_start; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case header_line_start: if (input == '\r') { state_ = expecting_newline_3; - return boost::indeterminate; + return indeterminate; } else if (!req.headers.empty() && (input == ' ' || input == '\t')) { state_ = header_lws; - return boost::indeterminate; + return indeterminate; } else if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { req.headers.push_back(header()); req.headers.back().name.push_back(input); state_ = header_name; - return boost::indeterminate; + return indeterminate; } case header_lws: if (input == '\r') { state_ = expecting_newline_2; - return boost::indeterminate; + return indeterminate; } else if (input == ' ' || input == '\t') { - return boost::indeterminate; + return indeterminate; } else if (is_ctl(input)) { - return false; + return bad; } else { state_ = header_value; req.headers.back().value.push_back(input); - return boost::indeterminate; + return indeterminate; } case header_name: if (input == ':') { state_ = space_before_header_value; - return boost::indeterminate; + return indeterminate; } else if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { - return false; + return bad; } else { req.headers.back().name.push_back(input); - return boost::indeterminate; + return indeterminate; } case space_before_header_value: if (input == ' ') { state_ = header_value; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case header_value: if (input == '\r') { state_ = expecting_newline_2; - return boost::indeterminate; + return indeterminate; } else if (is_ctl(input)) { - return false; + return bad; } else { req.headers.back().value.push_back(input); - return boost::indeterminate; + return indeterminate; } case expecting_newline_2: if (input == '\n') { state_ = header_line_start; - return boost::indeterminate; + return indeterminate; } else { - return false; + return bad; } case expecting_newline_3: - return (input == '\n'); + return (input == '\n') ? good : bad; default: - return false; + return bad; } } @@ -311,5 +311,5 @@ bool request_parser::is_digit(int c) return c >= '0' && c <= '9'; } -} // namespace server +} // namespace server4 } // namespace http diff --git a/3rdparty/asio/src/examples/cpp03/http/server/request_parser.hpp b/3rdparty/asio/src/examples/cpp11/http/server4/request_parser.hpp index d7da53cf030..4129c489b51 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server/request_parser.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/request_parser.hpp @@ -2,20 +2,19 @@ // request_parser.hpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef HTTP_REQUEST_PARSER_HPP -#define HTTP_REQUEST_PARSER_HPP +#ifndef HTTP_SERVER4_REQUEST_PARSER_HPP +#define HTTP_SERVER4_REQUEST_PARSER_HPP -#include <boost/logic/tribool.hpp> -#include <boost/tuple/tuple.hpp> +#include <tuple> namespace http { -namespace server { +namespace server4 { struct request; @@ -29,27 +28,29 @@ public: /// Reset to initial parser state. void reset(); - /// Parse some data. The tribool return value is true when a complete request - /// has been parsed, false if the data is invalid, indeterminate when more - /// data is required. The InputIterator return value indicates how much of the - /// input has been consumed. + /// Result of parse. + enum result_type { good, bad, indeterminate }; + + /// Parse some data. The enum return value is good when a complete request has + /// been parsed, bad if the data is invalid, indeterminate when more data is + /// required. The InputIterator return value indicates how much of the input + /// has been consumed. template <typename InputIterator> - boost::tuple<boost::tribool, InputIterator> parse(request& req, + std::tuple<result_type, InputIterator> parse(request& req, InputIterator begin, InputIterator end) { while (begin != end) { - boost::tribool result = consume(req, *begin++); - if (result || !result) - return boost::make_tuple(result, begin); + result_type result = consume(req, *begin++); + if (result == good || result == bad) + return std::make_tuple(result, begin); } - boost::tribool result = boost::indeterminate; - return boost::make_tuple(result, begin); + return std::make_tuple(indeterminate, begin); } private: /// Handle the next character of input. - boost::tribool consume(request& req, char input); + result_type consume(request& req, char input); /// Check if a byte is an HTTP character. static bool is_char(int c); @@ -89,7 +90,7 @@ private: } state_; }; -} // namespace server +} // namespace server4 } // namespace http -#endif // HTTP_REQUEST_PARSER_HPP +#endif // HTTP_SERVER4_REQUEST_PARSER_HPP diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/server.cpp b/3rdparty/asio/src/examples/cpp11/http/server4/server.cpp index 04d81a984b6..9c75f75e982 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server4/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/server.cpp @@ -2,7 +2,7 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -17,7 +17,7 @@ namespace server4 { server::server(asio::io_context& io_context, const std::string& address, const std::string& port, - boost::function<void(const request&, reply&)> request_handler) + std::function<void(const request&, reply&)> request_handler) : request_handler_(request_handler) { tcp::resolver resolver(io_context); @@ -29,7 +29,7 @@ server::server(asio::io_context& io_context, // Enable the pseudo-keywords reenter, yield and fork. #include <asio/yield.hpp> -void server::operator()(asio::error_code ec, std::size_t length) +void server::operator()(std::error_code ec, std::size_t length) { // In this example we keep the error handling code in one place by // hoisting it outside the coroutine. An alternative approach would be to @@ -45,7 +45,7 @@ void server::operator()(asio::error_code ec, std::size_t length) do { // Create a new socket for the next incoming connection. - socket_.reset(new tcp::socket(acceptor_->get_executor().context())); + socket_.reset(new tcp::socket(acceptor_->get_executor())); // Accept a new connection. The "yield" pseudo-keyword saves the current // line number and exits the coroutine's "reenter" block. We use the @@ -67,7 +67,7 @@ void server::operator()(asio::error_code ec, std::size_t length) } while (is_parent()); // Create the objects needed to receive a request on the connection. - buffer_.reset(new boost::array<char, 8192>); + buffer_.reset(new std::array<char, 8192>); request_.reset(new request); // Loop until a complete request (or an invalid one) has been received. @@ -79,17 +79,17 @@ void server::operator()(asio::error_code ec, std::size_t length) yield socket_->async_read_some(asio::buffer(*buffer_), *this); // Parse the data we just received. - boost::tie(valid_request_, boost::tuples::ignore) + std::tie(parse_result_, std::ignore) = request_parser_.parse(*request_, buffer_->data(), buffer_->data() + length); // An indeterminate result means we need more data, so keep looping. - } while (boost::indeterminate(valid_request_)); + } while (parse_result_ == request_parser::indeterminate); // Create the reply object that will be sent back to the client. reply_.reset(new reply); - if (valid_request_) + if (parse_result_ == request_parser::good) { // A valid request was received. Call the user-supplied function object // to process the request and compose a reply. diff --git a/3rdparty/asio/src/examples/cpp03/http/server4/server.hpp b/3rdparty/asio/src/examples/cpp11/http/server4/server.hpp index 580ece5e097..54d67832ba6 100644 --- a/3rdparty/asio/src/examples/cpp03/http/server4/server.hpp +++ b/3rdparty/asio/src/examples/cpp11/http/server4/server.hpp @@ -2,7 +2,7 @@ // server.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,10 +12,10 @@ #define HTTP_SERVER4_SERVER_HPP #include <asio.hpp> +#include <array> +#include <functional> +#include <memory> #include <string> -#include <boost/array.hpp> -#include <boost/function.hpp> -#include <boost/shared_ptr.hpp> #include "request_parser.hpp" namespace http { @@ -32,39 +32,39 @@ public: /// serve up files from the given directory. explicit server(asio::io_context& io_context, const std::string& address, const std::string& port, - boost::function<void(const request&, reply&)> request_handler); + std::function<void(const request&, reply&)> request_handler); /// Perform work associated with the server. void operator()( - asio::error_code ec = asio::error_code(), + std::error_code ec = std::error_code(), std::size_t length = 0); private: typedef asio::ip::tcp tcp; /// The user-supplied handler for all incoming requests. - boost::function<void(const request&, reply&)> request_handler_; + std::function<void(const request&, reply&)> request_handler_; /// Acceptor used to listen for incoming connections. - boost::shared_ptr<tcp::acceptor> acceptor_; + std::shared_ptr<tcp::acceptor> acceptor_; /// The current connection from a client. - boost::shared_ptr<tcp::socket> socket_; + std::shared_ptr<tcp::socket> socket_; /// Buffer for incoming data. - boost::shared_ptr<boost::array<char, 8192> > buffer_; + std::shared_ptr<std::array<char, 8192>> buffer_; /// The incoming request. - boost::shared_ptr<request> request_; + std::shared_ptr<request> request_; /// Whether the request is valid or not. - boost::tribool valid_request_; + request_parser::result_type parse_result_; /// The parser for the incoming request. request_parser request_parser_; /// The reply to be sent back to the client. - boost::shared_ptr<reply> reply_; + std::shared_ptr<reply> reply_; }; } // namespace server4 diff --git a/3rdparty/asio/src/examples/cpp03/icmp/icmp_header.hpp b/3rdparty/asio/src/examples/cpp11/icmp/icmp_header.hpp index 3b7b4bf5032..369511c6267 100644 --- a/3rdparty/asio/src/examples/cpp03/icmp/icmp_header.hpp +++ b/3rdparty/asio/src/examples/cpp11/icmp/icmp_header.hpp @@ -2,7 +2,7 @@ // icmp_header.hpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/icmp/ipv4_header.hpp b/3rdparty/asio/src/examples/cpp11/icmp/ipv4_header.hpp index 6785fd74d6c..d296571938f 100644 --- a/3rdparty/asio/src/examples/cpp03/icmp/ipv4_header.hpp +++ b/3rdparty/asio/src/examples/cpp11/icmp/ipv4_header.hpp @@ -2,7 +2,7 @@ // ipv4_header.hpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/icmp/ping.cpp b/3rdparty/asio/src/examples/cpp11/icmp/ping.cpp index 3a1d278415d..f179ea3461b 100644 --- a/3rdparty/asio/src/examples/cpp03/icmp/ping.cpp +++ b/3rdparty/asio/src/examples/cpp11/icmp/ping.cpp @@ -2,14 +2,13 @@ // ping.cpp // ~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include <asio.hpp> -#include <boost/bind.hpp> #include <istream> #include <iostream> #include <ostream> @@ -18,8 +17,8 @@ #include "ipv4_header.hpp" using asio::ip::icmp; -using asio::deadline_timer; -namespace posix_time = boost::posix_time; +using asio::steady_timer; +namespace chrono = asio::chrono; class pinger { @@ -53,13 +52,13 @@ private: os << echo_request << body; // Send the request. - time_sent_ = posix_time::microsec_clock::universal_time(); + time_sent_ = steady_timer::clock_type::now(); socket_.send_to(request_buffer.data(), destination_); // Wait up to five seconds for a reply. num_replies_ = 0; - timer_.expires_at(time_sent_ + posix_time::seconds(5)); - timer_.async_wait(boost::bind(&pinger::handle_timeout, this)); + timer_.expires_at(time_sent_ + chrono::seconds(5)); + timer_.async_wait(std::bind(&pinger::handle_timeout, this)); } void handle_timeout() @@ -68,8 +67,8 @@ private: std::cout << "Request timed out" << std::endl; // Requests must be sent no less than one second apart. - timer_.expires_at(time_sent_ + posix_time::seconds(1)); - timer_.async_wait(boost::bind(&pinger::start_send, this)); + timer_.expires_at(time_sent_ + chrono::seconds(1)); + timer_.async_wait(std::bind(&pinger::start_send, this)); } void start_receive() @@ -79,7 +78,7 @@ private: // Wait for a reply. We prepare the buffer to receive up to 64KB. socket_.async_receive(reply_buffer_.prepare(65536), - boost::bind(&pinger::handle_receive, this, _2)); + std::bind(&pinger::handle_receive, this, std::placeholders::_2)); } void handle_receive(std::size_t length) @@ -106,12 +105,14 @@ private: timer_.cancel(); // Print out some information about the reply packet. - posix_time::ptime now = posix_time::microsec_clock::universal_time(); + chrono::steady_clock::time_point now = chrono::steady_clock::now(); + chrono::steady_clock::duration elapsed = now - time_sent_; std::cout << length - ipv4_hdr.header_length() << " bytes from " << ipv4_hdr.source_address() << ": icmp_seq=" << icmp_hdr.sequence_number() << ", ttl=" << ipv4_hdr.time_to_live() - << ", time=" << (now - time_sent_).total_milliseconds() << " ms" + << ", time=" + << chrono::duration_cast<chrono::milliseconds>(elapsed).count() << std::endl; } @@ -130,9 +131,9 @@ private: icmp::resolver resolver_; icmp::endpoint destination_; icmp::socket socket_; - deadline_timer timer_; + steady_timer timer_; unsigned short sequence_number_; - posix_time::ptime time_sent_; + chrono::steady_clock::time_point time_sent_; asio::streambuf reply_buffer_; std::size_t num_replies_; }; diff --git a/3rdparty/asio/src/examples/cpp11/invocation/prioritised_handlers.cpp b/3rdparty/asio/src/examples/cpp11/invocation/prioritised_handlers.cpp new file mode 100644 index 00000000000..533bfd06861 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/invocation/prioritised_handlers.cpp @@ -0,0 +1,202 @@ +// +// prioritised_handlers.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "asio.hpp" +#include <iostream> +#include <memory> +#include <queue> + +using asio::ip::tcp; + +class handler_priority_queue : public asio::execution_context +{ +public: + template <typename Function> + void add(int priority, Function function) + { + std::unique_ptr<queued_handler_base> handler( + new queued_handler<Function>( + priority, std::move(function))); + + handlers_.push(std::move(handler)); + } + + void execute_all() + { + while (!handlers_.empty()) + { + handlers_.top()->execute(); + handlers_.pop(); + } + } + + class executor + { + public: + executor(handler_priority_queue& q, int p) + : context_(q), priority_(p) + { + } + + handler_priority_queue& context() const noexcept + { + return context_; + } + + template <typename Function, typename Allocator> + void dispatch(Function f, const Allocator&) const + { + context_.add(priority_, std::move(f)); + } + + template <typename Function, typename Allocator> + void post(Function f, const Allocator&) const + { + context_.add(priority_, std::move(f)); + } + + template <typename Function, typename Allocator> + void defer(Function f, const Allocator&) const + { + context_.add(priority_, std::move(f)); + } + + void on_work_started() const noexcept {} + void on_work_finished() const noexcept {} + + bool operator==(const executor& other) const noexcept + { + return &context_ == &other.context_ && priority_ == other.priority_; + } + + bool operator!=(const executor& other) const noexcept + { + return !operator==(other); + } + + private: + handler_priority_queue& context_; + int priority_; + }; + + template <typename Handler> + asio::executor_binder<Handler, executor> + wrap(int priority, Handler handler) + { + return asio::bind_executor( + executor(*this, priority), std::move(handler)); + } + +private: + class queued_handler_base + { + public: + queued_handler_base(int p) + : priority_(p) + { + } + + virtual ~queued_handler_base() + { + } + + virtual void execute() = 0; + + friend bool operator<(const std::unique_ptr<queued_handler_base>& a, + const std::unique_ptr<queued_handler_base>& b) noexcept + { + return a->priority_ < b->priority_; + } + + private: + int priority_; + }; + + template <typename Function> + class queued_handler : public queued_handler_base + { + public: + queued_handler(int p, Function f) + : queued_handler_base(p), function_(std::move(f)) + { + } + + void execute() override + { + function_(); + } + + private: + Function function_; + }; + + std::priority_queue<std::unique_ptr<queued_handler_base>> handlers_; +}; + +//---------------------------------------------------------------------- + +void high_priority_handler(const std::error_code& /*ec*/, + tcp::socket /*socket*/) +{ + std::cout << "High priority handler\n"; +} + +void middle_priority_handler(const std::error_code& /*ec*/) +{ + std::cout << "Middle priority handler\n"; +} + +struct low_priority_handler +{ + // Make the handler a move-only type. + low_priority_handler() = default; + low_priority_handler(const low_priority_handler&) = delete; + low_priority_handler(low_priority_handler&&) = default; + + void operator()() + { + std::cout << "Low priority handler\n"; + } +}; + +int main() +{ + asio::io_context io_context; + + handler_priority_queue pri_queue; + + // Post a completion handler to be run immediately. + asio::post(io_context, pri_queue.wrap(0, low_priority_handler())); + + // Start an asynchronous accept that will complete immediately. + tcp::endpoint endpoint(asio::ip::address_v4::loopback(), 0); + tcp::acceptor acceptor(io_context, endpoint); + tcp::socket server_socket(io_context); + acceptor.async_accept(pri_queue.wrap(100, high_priority_handler)); + tcp::socket client_socket(io_context); + client_socket.connect(acceptor.local_endpoint()); + + // Set a deadline timer to expire immediately. + asio::steady_timer timer(io_context); + timer.expires_at(asio::steady_timer::clock_type::time_point::min()); + timer.async_wait(pri_queue.wrap(42, middle_priority_handler)); + + while (io_context.run_one()) + { + // The custom invocation hook adds the handlers to the priority queue + // rather than executing them from within the poll_one() call. + while (io_context.poll_one()) + ; + + pri_queue.execute_all(); + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp11/iostreams/.gitignore b/3rdparty/asio/src/examples/cpp11/iostreams/.gitignore deleted file mode 100644 index bc2b4f8f7fe..00000000000 --- a/3rdparty/asio/src/examples/cpp11/iostreams/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_client -*_server -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp03/iostreams/daytime_client.cpp b/3rdparty/asio/src/examples/cpp11/iostreams/daytime_client.cpp index 4d0f68ca989..0c8df192534 100644 --- a/3rdparty/asio/src/examples/cpp03/iostreams/daytime_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/iostreams/daytime_client.cpp @@ -2,7 +2,7 @@ // daytime_client.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/iostreams/daytime_server.cpp b/3rdparty/asio/src/examples/cpp11/iostreams/daytime_server.cpp index ed3f94b0505..1e644085ef1 100644 --- a/3rdparty/asio/src/examples/cpp03/iostreams/daytime_server.cpp +++ b/3rdparty/asio/src/examples/cpp11/iostreams/daytime_server.cpp @@ -2,7 +2,7 @@ // daytime_server.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -34,7 +34,7 @@ int main() for (;;) { tcp::iostream stream; - asio::error_code ec; + std::error_code ec; acceptor.accept(stream.socket(), ec); if (!ec) { diff --git a/3rdparty/asio/src/examples/cpp11/iostreams/http_client.cpp b/3rdparty/asio/src/examples/cpp11/iostreams/http_client.cpp index 7972a67ecf9..313f177bce4 100644 --- a/3rdparty/asio/src/examples/cpp11/iostreams/http_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/iostreams/http_client.cpp @@ -2,7 +2,7 @@ // http_client.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/local/connect_pair.cpp b/3rdparty/asio/src/examples/cpp11/local/connect_pair.cpp new file mode 100644 index 00000000000..50d0a06712c --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/local/connect_pair.cpp @@ -0,0 +1,129 @@ +// +// connect_pair.cpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <array> +#include <iostream> +#include <string> +#include <cctype> +#include <asio.hpp> + +#if defined(ASIO_HAS_LOCAL_SOCKETS) + +using asio::local::stream_protocol; + +class uppercase_filter +{ +public: + uppercase_filter(stream_protocol::socket sock) + : socket_(std::move(sock)) + { + read(); + } + +private: + void read() + { + socket_.async_read_some(asio::buffer(data_), + [this](std::error_code ec, std::size_t size) + { + if (!ec) + { + // Compute result. + for (std::size_t i = 0; i < size; ++i) + data_[i] = std::toupper(data_[i]); + + // Send result. + write(size); + } + else + { + throw std::system_error(ec); + } + }); + } + + void write(std::size_t size) + { + asio::async_write(socket_, asio::buffer(data_, size), + [this](std::error_code ec, std::size_t /*size*/) + { + if (!ec) + { + // Wait for request. + read(); + } + else + { + throw std::system_error(ec); + } + }); + } + + stream_protocol::socket socket_; + std::array<char, 512> data_; +}; + +int main() +{ + try + { + asio::io_context io_context; + + // Create a connected pair and pass one end to a filter. + stream_protocol::socket socket(io_context); + stream_protocol::socket filter_socket(io_context); + asio::local::connect_pair(socket, filter_socket); + uppercase_filter filter(std::move(filter_socket)); + + // The io_context runs in a background thread to perform filtering. + asio::thread thread( + [&io_context]() + { + try + { + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception in thread: " << e.what() << "\n"; + std::exit(1); + } + }); + + for (;;) + { + // Collect request from user. + std::cout << "Enter a string: "; + std::string request; + std::getline(std::cin, request); + + // Send request to filter. + asio::write(socket, asio::buffer(request)); + + // Wait for reply from filter. + std::vector<char> reply(request.size()); + asio::read(socket, asio::buffer(reply)); + + // Show reply to user. + std::cout << "Result: "; + std::cout.write(&reply[0], request.size()); + std::cout << std::endl; + } + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + std::exit(1); + } +} + +#else // defined(ASIO_HAS_LOCAL_SOCKETS) +# error Local sockets not available on this platform. +#endif // defined(ASIO_HAS_LOCAL_SOCKETS) diff --git a/3rdparty/asio/src/examples/cpp11/local/fd_passing_stream_client.cpp b/3rdparty/asio/src/examples/cpp11/local/fd_passing_stream_client.cpp new file mode 100644 index 00000000000..229509f1c14 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/local/fd_passing_stream_client.cpp @@ -0,0 +1,102 @@ +// +// fd_passing_stream_client.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2021 Heiko Hund (heiko at openvpn dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +// Demonstrates how to pass file descriptors between processes with Asio. +// The client send a file name (destfile) to the server. The server opens +// the file and the associated file descriptor back to the client. + +#include <cstdlib> +#include <cstring> +#include <iostream> +#include "asio.hpp" + +#if defined(ASIO_HAS_LOCAL_SOCKETS) + +#include <sys/types.h> +#include <sys/socket.h> + +using asio::local::stream_protocol; + +constexpr std::size_t max_length = 1024; + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 2) + { + std::cerr << "Usage: fd_passing_stream_client <serversocket>\n"; + return 1; + } + + asio::io_context io_context; + + stream_protocol::socket s(io_context); + s.connect(stream_protocol::endpoint(argv[1])); + + std::cout << "Enter path to write to: "; + char request[max_length]; + std::cin.getline(request, max_length); + size_t request_length = std::strlen(request); + asio::write(s, asio::buffer(request, request_length)); + + char reply[max_length]; + struct msghdr msg = {}; + struct iovec iov = { reply, sizeof(reply) }; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + + union + { + struct cmsghdr align; + char buf[CMSG_SPACE(sizeof(int))]; + } cmsgu; + msg.msg_control = cmsgu.buf; + msg.msg_controllen = sizeof(cmsgu.buf); + + ::recvmsg(s.native_handle(), &msg, 0); + + int fd = -1; + struct cmsghdr* cmsg = CMSG_FIRSTHDR(&msg); + while (cmsg != NULL) + { + if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) + { + std::memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd)); + break; + } + cmsg = CMSG_NXTHDR(&msg, cmsg); + } + + if (fd != -1) + { + std::cout << "File descriptor received is: " << fd << "\n"; + FILE* f(::fdopen(fd, "w+")); + if (f) + { + ::fprintf(f, "stream_client writing to received fd #%d\n", fd); + ::fclose(f); + } + else + ::close(fd); + } + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} + +#else // defined(ASIO_HAS_LOCAL_SOCKETS) +# error Local sockets not available on this platform. +#endif // defined(ASIO_HAS_LOCAL_SOCKETS) diff --git a/3rdparty/asio/src/examples/cpp11/local/fd_passing_stream_server.cpp b/3rdparty/asio/src/examples/cpp11/local/fd_passing_stream_server.cpp new file mode 100644 index 00000000000..5082185e75c --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/local/fd_passing_stream_server.cpp @@ -0,0 +1,160 @@ +// +// fd_passing_stream_server.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2021 Heiko Hund (heiko at openvpn dot net) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +// Demonstrates how to pass file descriptors between processes with Asio. +// The client sends a file name to the server. The server opens the file and +// passes the associated file descriptor back to the client. + +#include <array> +#include <cstdio> +#include <cassert> +#include <iostream> +#include <memory> +#include "asio.hpp" + +#if defined(ASIO_HAS_LOCAL_SOCKETS) + +using asio::local::stream_protocol; + +class session + : public std::enable_shared_from_this<session> +{ +public: + session(stream_protocol::socket sock) + : socket_(std::move(sock)) + { + } + + void start() + { + do_read(); + } + +private: + void do_read() + { + auto self(shared_from_this()); + socket_.async_read_some(asio::buffer(data_), + [this, self](std::error_code ec, std::size_t length) + { + if (ec) + return; + + assert(length < data_.size()); + data_[length] = 0; + do_write(data_.data()); + }); + } + + void do_write(const char* filename) + { + auto self(shared_from_this()); + socket_.async_wait(stream_protocol::socket::wait_write, + [this, self, filename](std::error_code ec) + { + if (ec) + return; + + FILE* f(::fopen(filename, "w+")); + if (!f) + return; + + struct msghdr msg = {}; + char buf[] = { 0 }; + struct iovec iov = { buf, sizeof(buf) }; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + + union + { + struct cmsghdr align; + char buf[CMSG_SPACE(sizeof(int))]; + } cmsgu; + msg.msg_control = cmsgu.buf; + msg.msg_controllen = sizeof(cmsgu.buf); + + struct cmsghdr* cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_len = CMSG_LEN(sizeof(int)); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + int fd = ::fileno(f); + std::memcpy(CMSG_DATA(cmsg), &fd, sizeof(int)); + + ssize_t s(::sendmsg(socket_.native_handle(), &msg, 0)); + ::fclose(f); + if (s != -1) + do_read(); + }); + } + + // The socket used to communicate with the client. + stream_protocol::socket socket_; + + // Buffer used to store data received from the client. + std::array<char, 1024> data_; +}; + +class server +{ +public: + server(asio::io_context& io_context, const std::string& file) + : acceptor_(io_context, stream_protocol::endpoint(file)) + { + do_accept(); + } + +private: + void do_accept() + { + acceptor_.async_accept( + [this](std::error_code ec, stream_protocol::socket socket) + { + if (!ec) + { + std::make_shared<session>(std::move(socket))->start(); + } + + do_accept(); + }); + } + + stream_protocol::acceptor acceptor_; +}; + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 2) + { + std::cerr << "Usage: fd_passing_stream_server <socketfile>\n"; + std::cerr << "*** WARNING: existing file is removed ***\n"; + return 1; + } + + asio::io_context io_context; + + std::remove(argv[1]); + server s(io_context, argv[1]); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} + +#else // defined(ASIO_HAS_LOCAL_SOCKETS) +# error Local sockets not available on this platform. +#endif // defined(ASIO_HAS_LOCAL_SOCKETS) diff --git a/3rdparty/asio/src/examples/cpp03/local/iostream_client.cpp b/3rdparty/asio/src/examples/cpp11/local/iostream_client.cpp index d28d29e88c1..932f29d3459 100644 --- a/3rdparty/asio/src/examples/cpp03/local/iostream_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/local/iostream_client.cpp @@ -2,7 +2,7 @@ // stream_client.cpp // ~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,7 +16,7 @@ using asio::local::stream_protocol; -enum { max_length = 1024 }; +constexpr std::size_t max_length = 1024; int main(int argc, char* argv[]) { @@ -36,11 +36,10 @@ int main(int argc, char* argv[]) return 1; } - using namespace std; // For strlen. std::cout << "Enter message: "; char request[max_length]; std::cin.getline(request, max_length); - size_t length = strlen(request); + size_t length = std::strlen(request); s << request; char reply[max_length]; diff --git a/3rdparty/asio/src/examples/cpp03/local/stream_client.cpp b/3rdparty/asio/src/examples/cpp11/local/stream_client.cpp index 6374f8fb534..32f408933ca 100644 --- a/3rdparty/asio/src/examples/cpp03/local/stream_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/local/stream_client.cpp @@ -2,7 +2,7 @@ // stream_client.cpp // ~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -17,7 +17,7 @@ using asio::local::stream_protocol; -enum { max_length = 1024 }; +constexpr std::size_t max_length = 1024; int main(int argc, char* argv[]) { @@ -34,11 +34,10 @@ int main(int argc, char* argv[]) stream_protocol::socket s(io_context); s.connect(stream_protocol::endpoint(argv[1])); - using namespace std; // For strlen. std::cout << "Enter message: "; char request[max_length]; std::cin.getline(request, max_length); - size_t request_length = strlen(request); + size_t request_length = std::strlen(request); asio::write(s, asio::buffer(request, request_length)); char reply[max_length]; diff --git a/3rdparty/asio/src/examples/cpp11/local/stream_server.cpp b/3rdparty/asio/src/examples/cpp11/local/stream_server.cpp new file mode 100644 index 00000000000..85cd58f87d6 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/local/stream_server.cpp @@ -0,0 +1,121 @@ +// +// stream_server.cpp +// ~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <array> +#include <cstdio> +#include <iostream> +#include <memory> +#include "asio.hpp" + +#if defined(ASIO_HAS_LOCAL_SOCKETS) + +using asio::local::stream_protocol; + +class session + : public std::enable_shared_from_this<session> +{ +public: + session(stream_protocol::socket sock) + : socket_(std::move(sock)) + { + } + + void start() + { + do_read(); + } + +private: + void do_read() + { + auto self(shared_from_this()); + socket_.async_read_some(asio::buffer(data_), + [this, self](std::error_code ec, std::size_t length) + { + if (!ec) + do_write(length); + }); + } + + void do_write(std::size_t length) + { + auto self(shared_from_this()); + asio::async_write(socket_, + asio::buffer(data_, length), + [this, self](std::error_code ec, std::size_t /*length*/) + { + if (!ec) + do_read(); + }); + } + + // The socket used to communicate with the client. + stream_protocol::socket socket_; + + // Buffer used to store data received from the client. + std::array<char, 1024> data_; +}; + +class server +{ +public: + server(asio::io_context& io_context, const std::string& file) + : acceptor_(io_context, stream_protocol::endpoint(file)) + { + do_accept(); + } + +private: + void do_accept() + { + acceptor_.async_accept( + [this](std::error_code ec, stream_protocol::socket socket) + { + if (!ec) + { + std::make_shared<session>(std::move(socket))->start(); + } + + do_accept(); + }); + } + + stream_protocol::acceptor acceptor_; +}; + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 2) + { + std::cerr << "Usage: stream_server <file>\n"; + std::cerr << "*** WARNING: existing file is removed ***\n"; + return 1; + } + + asio::io_context io_context; + + std::remove(argv[1]); + server s(io_context, argv[1]); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} + +#else // defined(ASIO_HAS_LOCAL_SOCKETS) +# error Local sockets not available on this platform. +#endif // defined(ASIO_HAS_LOCAL_SOCKETS) diff --git a/3rdparty/asio/src/examples/cpp03/multicast/receiver.cpp b/3rdparty/asio/src/examples/cpp11/multicast/receiver.cpp index 5937050b0a8..5973bede5bb 100644 --- a/3rdparty/asio/src/examples/cpp03/multicast/receiver.cpp +++ b/3rdparty/asio/src/examples/cpp11/multicast/receiver.cpp @@ -2,18 +2,18 @@ // receiver.cpp // ~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <array> #include <iostream> #include <string> #include "asio.hpp" -#include "boost/bind.hpp" -const short multicast_port = 30001; +constexpr short multicast_port = 30001; class receiver { @@ -34,34 +34,29 @@ public: socket_.set_option( asio::ip::multicast::join_group(multicast_address)); - socket_.async_receive_from( - asio::buffer(data_, max_length), sender_endpoint_, - boost::bind(&receiver::handle_receive_from, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); + do_receive(); } - void handle_receive_from(const asio::error_code& error, - size_t bytes_recvd) +private: + void do_receive() { - if (!error) - { - std::cout.write(data_, bytes_recvd); - std::cout << std::endl; + socket_.async_receive_from( + asio::buffer(data_), sender_endpoint_, + [this](std::error_code ec, std::size_t length) + { + if (!ec) + { + std::cout.write(data_.data(), length); + std::cout << std::endl; - socket_.async_receive_from( - asio::buffer(data_, max_length), sender_endpoint_, - boost::bind(&receiver::handle_receive_from, this, - asio::placeholders::error, - asio::placeholders::bytes_transferred)); - } + do_receive(); + } + }); } -private: asio::ip::udp::socket socket_; asio::ip::udp::endpoint sender_endpoint_; - enum { max_length = 1024 }; - char data_[max_length]; + std::array<char, 1024> data_; }; int main(int argc, char* argv[]) diff --git a/3rdparty/asio/src/examples/cpp03/multicast/sender.cpp b/3rdparty/asio/src/examples/cpp11/multicast/sender.cpp index 995f05aa48e..dc3cf7fd0e7 100644 --- a/3rdparty/asio/src/examples/cpp03/multicast/sender.cpp +++ b/3rdparty/asio/src/examples/cpp11/multicast/sender.cpp @@ -2,7 +2,7 @@ // sender.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,11 +12,9 @@ #include <sstream> #include <string> #include "asio.hpp" -#include "boost/bind.hpp" -#include "boost/date_time/posix_time/posix_time_types.hpp" -const short multicast_port = 30001; -const int max_message_count = 10; +constexpr short multicast_port = 30001; +constexpr int max_message_count = 10; class sender { @@ -28,46 +26,40 @@ public: timer_(io_context), message_count_(0) { + do_send(); + } + +private: + void do_send() + { std::ostringstream os; os << "Message " << message_count_++; message_ = os.str(); socket_.async_send_to( asio::buffer(message_), endpoint_, - boost::bind(&sender::handle_send_to, this, - asio::placeholders::error)); - } - - void handle_send_to(const asio::error_code& error) - { - if (!error && message_count_ < max_message_count) - { - timer_.expires_from_now(boost::posix_time::seconds(1)); - timer_.async_wait( - boost::bind(&sender::handle_timeout, this, - asio::placeholders::error)); - } + [this](std::error_code ec, std::size_t /*length*/) + { + if (!ec && message_count_ < max_message_count) + do_timeout(); + }); } - void handle_timeout(const asio::error_code& error) + void do_timeout() { - if (!error) - { - std::ostringstream os; - os << "Message " << message_count_++; - message_ = os.str(); - - socket_.async_send_to( - asio::buffer(message_), endpoint_, - boost::bind(&sender::handle_send_to, this, - asio::placeholders::error)); - } + timer_.expires_after(std::chrono::seconds(1)); + timer_.async_wait( + [this](std::error_code ec) + { + if (!ec) + do_send(); + }); } private: asio::ip::udp::endpoint endpoint_; asio::ip::udp::socket socket_; - asio::deadline_timer timer_; + asio::steady_timer timer_; int message_count_; std::string message_; }; diff --git a/3rdparty/asio/src/examples/cpp11/nonblocking/third_party_lib.cpp b/3rdparty/asio/src/examples/cpp11/nonblocking/third_party_lib.cpp new file mode 100644 index 00000000000..7239a598532 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/nonblocking/third_party_lib.cpp @@ -0,0 +1,212 @@ +// +// third_party_lib.cpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <array> +#include <iostream> +#include <memory> + +using asio::ip::tcp; + +namespace third_party_lib { + +// Simulation of a third party library that wants to perform read and write +// operations directly on a socket. It needs to be polled to determine whether +// it requires a read or write operation, and notified when the socket is ready +// for reading or writing. +class session +{ +public: + session(tcp::socket& socket) + : socket_(socket) + { + } + + // Returns true if the third party library wants to be notified when the + // socket is ready for reading. + bool want_read() const + { + return state_ == reading; + } + + // Notify that third party library that it should perform its read operation. + void do_read(std::error_code& ec) + { + if (std::size_t len = socket_.read_some(asio::buffer(data_), ec)) + { + write_buffer_ = asio::buffer(data_, len); + state_ = writing; + } + } + + // Returns true if the third party library wants to be notified when the + // socket is ready for writing. + bool want_write() const + { + return state_ == writing; + } + + // Notify that third party library that it should perform its write operation. + void do_write(std::error_code& ec) + { + if (std::size_t len = socket_.write_some( + asio::buffer(write_buffer_), ec)) + { + write_buffer_ = write_buffer_ + len; + state_ = asio::buffer_size(write_buffer_) > 0 ? writing : reading; + } + } + +private: + tcp::socket& socket_; + enum { reading, writing } state_ = reading; + std::array<char, 128> data_; + asio::const_buffer write_buffer_; +}; + +} // namespace third_party_lib + +// The glue between asio's sockets and the third party library. +class connection + : public std::enable_shared_from_this<connection> +{ +public: + connection(tcp::socket socket) + : socket_(std::move(socket)) + { + } + + void start() + { + // Put the socket into non-blocking mode. + socket_.non_blocking(true); + + do_operations(); + } + +private: + void do_operations() + { + auto self(shared_from_this()); + + // Start a read operation if the third party library wants one. + if (session_impl_.want_read() && !read_in_progress_) + { + read_in_progress_ = true; + socket_.async_wait(tcp::socket::wait_read, + [this, self](std::error_code ec) + { + read_in_progress_ = false; + + // Notify third party library that it can perform a read. + if (!ec) + session_impl_.do_read(ec); + + // The third party library successfully performed a read on the + // socket. Start new read or write operations based on what it now + // wants. + if (!ec || ec == asio::error::would_block) + do_operations(); + + // Otherwise, an error occurred. Closing the socket cancels any + // outstanding asynchronous read or write operations. The + // connection object will be destroyed automatically once those + // outstanding operations complete. + else + socket_.close(); + }); + } + + // Start a write operation if the third party library wants one. + if (session_impl_.want_write() && !write_in_progress_) + { + write_in_progress_ = true; + socket_.async_wait(tcp::socket::wait_write, + [this, self](std::error_code ec) + { + write_in_progress_ = false; + + // Notify third party library that it can perform a write. + if (!ec) + session_impl_.do_write(ec); + + // The third party library successfully performed a write on the + // socket. Start new read or write operations based on what it now + // wants. + if (!ec || ec == asio::error::would_block) + do_operations(); + + // Otherwise, an error occurred. Closing the socket cancels any + // outstanding asynchronous read or write operations. The + // connection object will be destroyed automatically once those + // outstanding operations complete. + else + socket_.close(); + }); + } + } + +private: + tcp::socket socket_; + third_party_lib::session session_impl_{socket_}; + bool read_in_progress_ = false; + bool write_in_progress_ = false; +}; + +class server +{ +public: + server(asio::io_context& io_context, unsigned short port) + : acceptor_(io_context, {tcp::v4(), port}) + { + do_accept(); + } + +private: + void do_accept() + { + acceptor_.async_accept( + [this](std::error_code ec, tcp::socket socket) + { + if (!ec) + { + std::make_shared<connection>(std::move(socket))->start(); + } + + do_accept(); + }); + } + + tcp::acceptor acceptor_; +}; + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 2) + { + std::cerr << "Usage: third_party_lib <port>\n"; + return 1; + } + + asio::io_context io_context; + + server s(io_context, std::atoi(argv[1])); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp11/operations/composed_1.cpp b/3rdparty/asio/src/examples/cpp11/operations/composed_1.cpp new file mode 100644 index 00000000000..054dbdbbc88 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/operations/composed_1.cpp @@ -0,0 +1,159 @@ +// +// composed_1.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +//------------------------------------------------------------------------------ + +// This is the simplest example of a composed asynchronous operation, where we +// simply repackage an existing operation. The asynchronous operation +// requirements are met by delegating responsibility to the underlying +// operation. + +template <typename CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is void. + // However, when the completion token is asio::yield_context (used for + // stackful coroutines) the return type would be std::size_t, and when the + // completion token is asio::use_future it would be std::future<std::size_t>. + // When the completion token is asio::deferred, the return type differs for + // each asynchronous operation. + // + // In this example we are trivially delegating to an underlying asynchronous + // operation, so we can deduce the return type from that. + -> decltype( + asio::async_write(socket, + asio::buffer(message, std::strlen(message)), + std::forward<CompletionToken>(token))) +{ + // When delegating to the underlying operation we must take care to perfectly + // forward the completion token. This ensures that our operation works + // correctly with move-only function objects as callbacks, as well as other + // completion token types. + return asio::async_write(socket, + asio::buffer(message, std::strlen(message)), + std::forward<CompletionToken>(token)); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "Testing callback\r\n", + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation and its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_message(socket, + "Testing deferred\r\n", asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<std::size_t> f = async_write_message( + socket, "Testing future\r\n", asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + std::size_t n = f.get(); + std::cout << n << " bytes transferred\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp11/operations/composed_2.cpp b/3rdparty/asio/src/examples/cpp11/operations/composed_2.cpp new file mode 100644 index 00000000000..306d4b343b4 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/operations/composed_2.cpp @@ -0,0 +1,229 @@ +// +// composed_2.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This next simplest example of a composed asynchronous operation involves +// repackaging multiple operations but choosing to invoke just one of them. All +// of these underlying operations have the same completion signature. The +// asynchronous operation requirements are met by delegating responsibility to +// the underlying operations. + +// In addition to determining the mechanism by which an asynchronous operation +// delivers its result, a completion token also determines the time when the +// operation commences. For example, when the completion token is a simple +// callback the operation commences before the initiating function returns. +// However, if the completion token's delivery mechanism uses a future, we +// might instead want to defer initiation of the operation until the returned +// future object is waited upon. +// +// To enable this, when implementing an asynchronous operation we must package +// the initiation step as a function object. +struct async_write_message_initiation +{ + // The initiation function object's call operator is passed the concrete + // completion handler produced by the completion token. This completion + // handler matches the asynchronous operation's completion handler signature, + // which in this example is: + // + // void(std::error_code error, std::size_t) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments as members in the initiaton function object. However, we should + // prefer to propagate them as function call arguments as this allows the + // completion token to optimise how they are passed. For example, a lazy + // future which defers initiation would need to make a decay-copy of the + // arguments, but when using a simple callback the arguments can be trivially + // forwarded straight through.) + template <typename CompletionHandler> + void operator()(CompletionHandler&& completion_handler, tcp::socket& socket, + const char* message, bool allow_partial_write) const + { + if (allow_partial_write) + { + // When delegating to an underlying operation we must take care to + // perfectly forward the completion handler. This ensures that our + // operation works correctly with move-only function objects as + // callbacks. + return socket.async_write_some( + asio::buffer(message, std::strlen(message)), + std::forward<CompletionHandler>(completion_handler)); + } + else + { + // As above, we must perfectly forward the completion handler when calling + // the alternate underlying operation. + return asio::async_write(socket, + asio::buffer(message, std::strlen(message)), + std::forward<CompletionHandler>(completion_handler)); + } + } +}; + +template <typename CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, bool allow_partial_write, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is void. + // However, when the completion token is asio::yield_context (used for + // stackful coroutines) the return type would be std::size_t, and when the + // completion token is asio::use_future it would be std::future<std::size_t>. + // When the completion token is asio::deferred, the return type differs for + // each asynchronous operation. + // + // In C++11 we deduce the type from the call to asio::async_initiate. + -> decltype( + asio::async_initiate< + CompletionToken, void(std::error_code, std::size_t)>( + async_write_message_initiation(), + token, std::ref(socket), message, allow_partial_write)) +{ + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code, std::size_t)>( + async_write_message_initiation(), + token, std::ref(socket), message, allow_partial_write); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "Testing callback\r\n", false, + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation and its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_message(socket, + "Testing deferred\r\n", false, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<std::size_t> f = async_write_message( + socket, "Testing future\r\n", false, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + std::size_t n = f.get(); + std::cout << n << " bytes transferred\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp11/operations/composed_3.cpp b/3rdparty/asio/src/examples/cpp11/operations/composed_3.cpp new file mode 100644 index 00000000000..e0b5ddca85b --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/operations/composed_3.cpp @@ -0,0 +1,238 @@ +// +// composed_3.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/bind_executor.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <functional> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// In this composed operation we repackage an existing operation, but with a +// different completion handler signature. The asynchronous operation +// requirements are met by delegating responsibility to the underlying +// operation. + +// In addition to determining the mechanism by which an asynchronous operation +// delivers its result, a completion token also determines the time when the +// operation commences. For example, when the completion token is a simple +// callback the operation commences before the initiating function returns. +// However, if the completion token's delivery mechanism uses a future, we +// might instead want to defer initiation of the operation until the returned +// future object is waited upon. +// +// To enable this, when implementing an asynchronous operation we must package +// the initiation step as a function object. +struct async_write_message_initiation +{ + // The initiation function object's call operator is passed the concrete + // completion handler produced by the completion token. This completion + // handler matches the asynchronous operation's completion handler signature, + // which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments as members in the initiaton function object. However, we should + // prefer to propagate them as function call arguments as this allows the + // completion token to optimise how they are passed. For example, a lazy + // future which defers initiation would need to make a decay-copy of the + // arguments, but when using a simple callback the arguments can be trivially + // forwarded straight through.) + template <typename CompletionHandler> + void operator()(CompletionHandler&& completion_handler, + tcp::socket& socket, const char* message) const + { + // The async_write operation has a completion handler signature of: + // + // void(std::error_code error, std::size n) + // + // This differs from our operation's signature in that it is also passed + // the number of bytes transferred as an argument of type std::size_t. We + // will adapt our completion handler to async_write's completion handler + // signature by using std::bind, which drops the additional argument. + // + // However, it is essential to the correctness of our composed operation + // that we preserve the executor of the user-supplied completion handler. + // The std::bind function will not do this for us, so we must do this by + // first obtaining the completion handler's associated executor (defaulting + // to the I/O executor - in this case the executor of the socket - if the + // completion handler does not have its own) ... + auto executor = asio::get_associated_executor( + completion_handler, socket.get_executor()); + + // ... and then binding this executor to our adapted completion handler + // using the asio::bind_executor function. + asio::async_write(socket, + asio::buffer(message, std::strlen(message)), + asio::bind_executor(executor, + std::bind(std::forward<CompletionHandler>( + completion_handler), std::placeholders::_1))); + } +}; + +template <typename CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++11 we deduce the type from the call to asio::async_initiate. + -> decltype( + asio::async_initiate< + CompletionToken, void(std::error_code)>( + async_write_message_initiation(), + token, std::ref(socket), message)) +{ + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + async_write_message_initiation(), + token, std::ref(socket), message); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "Testing callback\r\n", + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation and its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_message(socket, + "Testing deferred\r\n", asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_message( + socket, "Testing future\r\n", asio::use_future); + + io_context.run(); + + // Get the result of the operation. + try + { + // Get the result of the operation. + f.get(); + std::cout << "Message sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp11/operations/composed_4.cpp b/3rdparty/asio/src/examples/cpp11/operations/composed_4.cpp new file mode 100644 index 00000000000..29fe26966e5 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/operations/composed_4.cpp @@ -0,0 +1,252 @@ +// +// composed_4.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/bind_executor.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <functional> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// In this composed operation we repackage an existing operation, but with a +// different completion handler signature. We will also intercept an empty +// message as an invalid argument, and propagate the corresponding error to the +// user. The asynchronous operation requirements are met by delegating +// responsibility to the underlying operation. + +// In addition to determining the mechanism by which an asynchronous operation +// delivers its result, a completion token also determines the time when the +// operation commences. For example, when the completion token is a simple +// callback the operation commences before the initiating function returns. +// However, if the completion token's delivery mechanism uses a future, we +// might instead want to defer initiation of the operation until the returned +// future object is waited upon. +// +// To enable this, when implementing an asynchronous operation we must package +// the initiation step as a function object. +struct async_write_message_initiation +{ + // The initiation function object's call operator is passed the concrete + // completion handler produced by the completion token. This completion + // handler matches the asynchronous operation's completion handler signature, + // which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments as members in the initiaton function object. However, we should + // prefer to propagate them as function call arguments as this allows the + // completion token to optimise how they are passed. For example, a lazy + // future which defers initiation would need to make a decay-copy of the + // arguments, but when using a simple callback the arguments can be trivially + // forwarded straight through.) + template <typename CompletionHandler> + void operator()(CompletionHandler&& completion_handler, + tcp::socket& socket, const char* message) const + { + // The post operation has a completion handler signature of: + // + // void() + // + // and the async_write operation has a completion handler signature of: + // + // void(std::error_code error, std::size n) + // + // Both of these operations' completion handler signatures differ from our + // operation's completion handler signature. We will adapt our completion + // handler to these signatures by using std::bind, which drops the + // additional arguments. + // + // However, it is essential to the correctness of our composed operation + // that we preserve the executor of the user-supplied completion handler. + // The std::bind function will not do this for us, so we must do this by + // first obtaining the completion handler's associated executor (defaulting + // to the I/O executor - in this case the executor of the socket - if the + // completion handler does not have its own) ... + auto executor = asio::get_associated_executor( + completion_handler, socket.get_executor()); + + // ... and then binding this executor to our adapted completion handler + // using the asio::bind_executor function. + std::size_t length = std::strlen(message); + if (length == 0) + { + asio::post( + asio::bind_executor(executor, + std::bind(std::forward<CompletionHandler>(completion_handler), + asio::error::invalid_argument))); + } + else + { + asio::async_write(socket, + asio::buffer(message, length), + asio::bind_executor(executor, + std::bind(std::forward<CompletionHandler>(completion_handler), + std::placeholders::_1))); + } + } +}; + +template <typename CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++11 we deduce the type from the call to asio::async_initiate. + -> decltype( + asio::async_initiate< + CompletionToken, void(std::error_code)>( + async_write_message_initiation(), + token, std::ref(socket), message)) +{ + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + async_write_message_initiation(), + token, std::ref(socket), message); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "", + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation and its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_message(socket, "", asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_message( + socket, "", asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Message sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Exception: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp11/operations/composed_5.cpp b/3rdparty/asio/src/examples/cpp11/operations/composed_5.cpp new file mode 100644 index 00000000000..06a7af40f41 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/operations/composed_5.cpp @@ -0,0 +1,289 @@ +// +// composed_5.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation automatically serialises a message, using its I/O +// streams insertion operator, before sending it on the socket. To do this, it +// must allocate a buffer for the encoded message and ensure this buffer's +// validity until the underlying async_write operation completes. + +// In addition to determining the mechanism by which an asynchronous operation +// delivers its result, a completion token also determines the time when the +// operation commences. For example, when the completion token is a simple +// callback the operation commences before the initiating function returns. +// However, if the completion token's delivery mechanism uses a future, we +// might instead want to defer initiation of the operation until the returned +// future object is waited upon. +// +// To enable this, when implementing an asynchronous operation we must package +// the initiation step as a function object. +struct async_write_message_initiation +{ + // The initiation function object's call operator is passed the concrete + // completion handler produced by the completion token. This completion + // handler matches the asynchronous operation's completion handler signature, + // which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments as members in the initiaton function object. However, we should + // prefer to propagate them as function call arguments as this allows the + // completion token to optimise how they are passed. For example, a lazy + // future which defers initiation would need to make a decay-copy of the + // arguments, but when using a simple callback the arguments can be trivially + // forwarded straight through.) + template <typename CompletionHandler> + void operator()(CompletionHandler&& completion_handler, + tcp::socket& socket, std::unique_ptr<std::string> encoded_message) const + { + // In this example, the composed operation's intermediate completion + // handler is implemented as a hand-crafted function object, rather than + // using a lambda or std::bind. + struct intermediate_completion_handler + { + // The intermediate completion handler holds a reference to the socket so + // that it can obtain the I/O executor (see get_executor below). + tcp::socket& socket_; + + // The allocated buffer for the encoded message. The std::unique_ptr + // smart pointer is move-only, and as a consequence our intermediate + // completion handler is also move-only. + std::unique_ptr<std::string> encoded_message_; + + // The user-supplied completion handler. + typename std::decay<CompletionHandler>::type handler_; + + // The function call operator matches the completion signature of the + // async_write operation. + void operator()(const std::error_code& error, std::size_t /*n*/) + { + // Deallocate the encoded message before calling the user-supplied + // completion handler. + encoded_message_.reset(); + + // Call the user-supplied handler with the result of the operation. + // The arguments must match the completion signature of our composed + // operation. + handler_(error); + } + + // It is essential to the correctness of our composed operation that we + // preserve the executor of the user-supplied completion handler. With a + // hand-crafted function object we can do this by defining a nested type + // executor_type and member function get_executor. These obtain the + // completion handler's associated executor, and default to the I/O + // executor - in this case the executor of the socket - if the completion + // handler does not have its own. + using executor_type = asio::associated_executor_t< + typename std::decay<CompletionHandler>::type, + tcp::socket::executor_type>; + + executor_type get_executor() const noexcept + { + return asio::get_associated_executor( + handler_, socket_.get_executor()); + } + + // Although not necessary for correctness, we may also preserve the + // allocator of the user-supplied completion handler. This is achieved by + // defining a nested type allocator_type and member function + // get_allocator. These obtain the completion handler's associated + // allocator, and default to std::allocator<void> if the completion + // handler does not have its own. + using allocator_type = asio::associated_allocator_t< + typename std::decay<CompletionHandler>::type, + std::allocator<void>>; + + allocator_type get_allocator() const noexcept + { + return asio::get_associated_allocator( + handler_, std::allocator<void>{}); + } + }; + + // Initiate the underlying async_write operation using our intermediate + // completion handler. + auto encoded_message_buffer = asio::buffer(*encoded_message); + asio::async_write(socket, encoded_message_buffer, + intermediate_completion_handler{socket, std::move(encoded_message), + std::forward<CompletionHandler>(completion_handler)}); + } +}; + +template <typename T, typename CompletionToken> +auto async_write_message(tcp::socket& socket, + const T& message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++11 we deduce the type from the call to asio::async_initiate. + -> decltype( + asio::async_initiate< + CompletionToken, void(std::error_code)>( + async_write_message_initiation(), token, + std::ref(socket), std::declval<std::unique_ptr<std::string>>())) +{ + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + async_write_message_initiation(), token, + std::ref(socket), std::move(encoded_message)); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, 123456, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation and its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_message(socket, + std::string("abcdef"), asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_message( + socket, 654.321, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Message sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Exception: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp11/operations/composed_6.cpp b/3rdparty/asio/src/examples/cpp11/operations/composed_6.cpp new file mode 100644 index 00000000000..b948758d83a --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/operations/composed_6.cpp @@ -0,0 +1,349 @@ +// +// composed_6.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/executor_work_guard.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation shows composition of multiple underlying operations. +// It automatically serialises a message, using its I/O streams insertion +// operator, before sending it N times on the socket. To do this, it must +// allocate a buffer for the encoded message and ensure this buffer's validity +// until all underlying async_write operation complete. A one second delay is +// inserted prior to each write operation, using a steady_timer. + +// In addition to determining the mechanism by which an asynchronous operation +// delivers its result, a completion token also determines the time when the +// operation commences. For example, when the completion token is a simple +// callback the operation commences before the initiating function returns. +// However, if the completion token's delivery mechanism uses a future, we +// might instead want to defer initiation of the operation until the returned +// future object is waited upon. +// +// To enable this, when implementing an asynchronous operation we must package +// the initiation step as a function object. +struct async_write_message_initiation +{ + // The initiation function object's call operator is passed the concrete + // completion handler produced by the completion token. This completion + // handler matches the asynchronous operation's completion handler signature, + // which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments as members in the initiaton function object. However, we should + // prefer to propagate them as function call arguments as this allows the + // completion token to optimise how they are passed. For example, a lazy + // future which defers initiation would need to make a decay-copy of the + // arguments, but when using a simple callback the arguments can be trivially + // forwarded straight through.) + template <typename CompletionHandler> + void operator()(CompletionHandler&& completion_handler, tcp::socket& socket, + std::unique_ptr<std::string> encoded_message, std::size_t repeat_count, + std::unique_ptr<asio::steady_timer> delay_timer) const + { + // In this example, the composed operation's intermediate completion + // handler is implemented as a hand-crafted function object. + struct intermediate_completion_handler + { + // The intermediate completion handler holds a reference to the socket as + // it is used for multiple async_write operations, as well as for + // obtaining the I/O executor (see get_executor below). + tcp::socket& socket_; + + // The allocated buffer for the encoded message. The std::unique_ptr + // smart pointer is move-only, and as a consequence our intermediate + // completion handler is also move-only. + std::unique_ptr<std::string> encoded_message_; + + // The repeat count remaining. + std::size_t repeat_count_; + + // A steady timer used for introducing a delay. + std::unique_ptr<asio::steady_timer> delay_timer_; + + // To manage the cycle between the multiple underlying asychronous + // operations, our intermediate completion handler is implemented as a + // state machine. + enum { starting, waiting, writing } state_; + + // As our composed operation performs multiple underlying I/O operations, + // we should maintain a work object against the I/O executor. This tells + // the I/O executor that there is still more work to come in the future. + asio::executor_work_guard<tcp::socket::executor_type> io_work_; + + // The user-supplied completion handler, called once only on completion + // of the entire composed operation. + typename std::decay<CompletionHandler>::type handler_; + + // By having a default value for the second argument, this function call + // operator matches the completion signature of both the async_write and + // steady_timer::async_wait operations. + void operator()(const std::error_code& error, std::size_t = 0) + { + if (!error) + { + switch (state_) + { + case starting: + case writing: + if (repeat_count_ > 0) + { + --repeat_count_; + state_ = waiting; + delay_timer_->expires_after(std::chrono::seconds(1)); + delay_timer_->async_wait(std::move(*this)); + return; // Composed operation not yet complete. + } + break; // Composed operation complete, continue below. + case waiting: + state_ = writing; + asio::async_write(socket_, + asio::buffer(*encoded_message_), std::move(*this)); + return; // Composed operation not yet complete. + } + } + + // This point is reached only on completion of the entire composed + // operation. + + // We no longer have any future work coming for the I/O executor. + io_work_.reset(); + + // Deallocate the encoded message before calling the user-supplied + // completion handler. + encoded_message_.reset(); + + // Call the user-supplied handler with the result of the operation. + handler_(error); + } + + // It is essential to the correctness of our composed operation that we + // preserve the executor of the user-supplied completion handler. With a + // hand-crafted function object we can do this by defining a nested type + // executor_type and member function get_executor. These obtain the + // completion handler's associated executor, and default to the I/O + // executor - in this case the executor of the socket - if the completion + // handler does not have its own. + using executor_type = asio::associated_executor_t< + typename std::decay<CompletionHandler>::type, + tcp::socket::executor_type>; + + executor_type get_executor() const noexcept + { + return asio::get_associated_executor( + handler_, socket_.get_executor()); + } + + // Although not necessary for correctness, we may also preserve the + // allocator of the user-supplied completion handler. This is achieved by + // defining a nested type allocator_type and member function + // get_allocator. These obtain the completion handler's associated + // allocator, and default to std::allocator<void> if the completion + // handler does not have its own. + using allocator_type = asio::associated_allocator_t< + typename std::decay<CompletionHandler>::type, + std::allocator<void>>; + + allocator_type get_allocator() const noexcept + { + return asio::get_associated_allocator( + handler_, std::allocator<void>{}); + } + }; + + // Initiate the underlying async_write operation using our intermediate + // completion handler. + auto encoded_message_buffer = asio::buffer(*encoded_message); + asio::async_write(socket, encoded_message_buffer, + intermediate_completion_handler{ + socket, std::move(encoded_message), + repeat_count, std::move(delay_timer), + intermediate_completion_handler::starting, + asio::make_work_guard(socket.get_executor()), + std::forward<CompletionHandler>(completion_handler)}); + } +}; + +template <typename T, typename CompletionToken> +auto async_write_messages(tcp::socket& socket, + const T& message, std::size_t repeat_count, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++11 we deduce the type from the call to asio::async_initiate. + -> decltype( + asio::async_initiate< + CompletionToken, void(std::error_code)>( + async_write_message_initiation(), token, std::ref(socket), + std::declval<std::unique_ptr<std::string>>(), repeat_count, + std::declval<std::unique_ptr<asio::steady_timer>>())) +{ + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the composed asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // Create a steady_timer to be used for the delay between messages. + std::unique_ptr<asio::steady_timer> delay_timer( + new asio::steady_timer(socket.get_executor())); + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + async_write_message_initiation(), token, std::ref(socket), + std::move(encoded_message), repeat_count, std::move(delay_timer)); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_messages(socket, "Testing callback\r\n", 5, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation and its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_messages(socket, + "Testing deferred\r\n", 5, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_messages( + socket, "Testing future\r\n", 5, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Messages sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp11/operations/composed_7.cpp b/3rdparty/asio/src/examples/cpp11/operations/composed_7.cpp new file mode 100644 index 00000000000..8eb83dc7679 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/operations/composed_7.cpp @@ -0,0 +1,268 @@ +// +// composed_7.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/compose.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_compose function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation shows composition of multiple underlying operations. +// It automatically serialises a message, using its I/O streams insertion +// operator, before sending it N times on the socket. To do this, it must +// allocate a buffer for the encoded message and ensure this buffer's validity +// until all underlying async_write operation complete. A one second delay is +// inserted prior to each write operation, using a steady_timer. + +// In this example, the composed operation's logic is implemented as a state +// machine within a hand-crafted function object. +struct async_write_messages_implementation +{ + // The implementation holds a reference to the socket as it is used for + // multiple async_write operations. + tcp::socket& socket_; + + // The allocated buffer for the encoded message. The std::unique_ptr smart + // pointer is move-only, and as a consequence our implementation is also + // move-only. + std::unique_ptr<std::string> encoded_message_; + + // The repeat count remaining. + std::size_t repeat_count_; + + // A steady timer used for introducing a delay. + std::unique_ptr<asio::steady_timer> delay_timer_; + + // To manage the cycle between the multiple underlying asychronous + // operations, our implementation is a state machine. + enum { starting, waiting, writing } state_; + + // The first argument to our function object's call operator is a reference + // to the enclosing intermediate completion handler. This intermediate + // completion handler is provided for us by the asio::async_compose + // function, and takes care of all the details required to implement a + // conforming asynchronous operation. When calling an underlying asynchronous + // operation, we pass it this enclosing intermediate completion handler + // as the completion token. + // + // All arguments after the first must be defaulted to allow the state machine + // to be started, as well as to allow the completion handler to match the + // completion signature of both the async_write and steady_timer::async_wait + // operations. + template <typename Self> + void operator()(Self& self, + const std::error_code& error = std::error_code(), + std::size_t = 0) + { + if (!error) + { + switch (state_) + { + case starting: + case writing: + if (repeat_count_ > 0) + { + --repeat_count_; + state_ = waiting; + delay_timer_->expires_after(std::chrono::seconds(1)); + delay_timer_->async_wait(std::move(self)); + return; // Composed operation not yet complete. + } + break; // Composed operation complete, continue below. + case waiting: + state_ = writing; + asio::async_write(socket_, + asio::buffer(*encoded_message_), std::move(self)); + return; // Composed operation not yet complete. + } + } + + // This point is reached only on completion of the entire composed + // operation. + + // Deallocate the encoded message and delay timer before calling the + // user-supplied completion handler. + encoded_message_.reset(); + delay_timer_.reset(); + + // Call the user-supplied handler with the result of the operation. + self.complete(error); + } +}; + +template <typename T, typename CompletionToken> +auto async_write_messages(tcp::socket& socket, + const T& message, std::size_t repeat_count, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++11 we deduce the type from the call to asio::async_compose. + -> decltype( + asio::async_compose< + CompletionToken, void(std::error_code)>( + std::declval<async_write_messages_implementation>(), + token, socket)) +{ + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the composed asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // Create a steady_timer to be used for the delay between messages. + std::unique_ptr<asio::steady_timer> delay_timer( + new asio::steady_timer(socket.get_executor())); + + // The asio::async_compose function takes: + // + // - our asynchronous operation implementation, + // - the completion token, + // - the completion handler signature, and + // - any I/O objects (or executors) used by the operation + // + // It then wraps our implementation in an intermediate completion handler + // that meets the requirements of a conforming asynchronous operation. This + // includes tracking outstanding work against the I/O executors associated + // with the operation (in this example, this is the socket's executor). + return asio::async_compose< + CompletionToken, void(std::error_code)>( + async_write_messages_implementation{ + socket, std::move(encoded_message), + repeat_count, std::move(delay_timer), + async_write_messages_implementation::starting}, + token, socket); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_messages(socket, "Testing callback\r\n", 5, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation and its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_messages(socket, + "Testing deferred\r\n", 5, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_messages( + socket, "Testing future\r\n", 5, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Messages sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp11/operations/composed_8.cpp b/3rdparty/asio/src/examples/cpp11/operations/composed_8.cpp new file mode 100644 index 00000000000..ce22a5b418d --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/operations/composed_8.cpp @@ -0,0 +1,263 @@ +// +// composed_8.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/compose.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_compose function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation shows composition of multiple underlying operations, +// using asio's stackless coroutines support to express the flow of control. It +// automatically serialises a message, using its I/O streams insertion +// operator, before sending it N times on the socket. To do this, it must +// allocate a buffer for the encoded message and ensure this buffer's validity +// until all underlying async_write operation complete. A one second delay is +// inserted prior to each write operation, using a steady_timer. + +#include <asio/yield.hpp> + +// In this example, the composed operation's logic is implemented as a state +// machine within a hand-crafted function object. +struct async_write_messages_implementation +{ + // The implementation holds a reference to the socket as it is used for + // multiple async_write operations. + tcp::socket& socket_; + + // The allocated buffer for the encoded message. The std::unique_ptr smart + // pointer is move-only, and as a consequence our implementation is also + // move-only. + std::unique_ptr<std::string> encoded_message_; + + // The repeat count remaining. + std::size_t repeat_count_; + + // A steady timer used for introducing a delay. + std::unique_ptr<asio::steady_timer> delay_timer_; + + // The coroutine state. + asio::coroutine coro_; + + // The first argument to our function object's call operator is a reference + // to the enclosing intermediate completion handler. This intermediate + // completion handler is provided for us by the asio::async_compose + // function, and takes care of all the details required to implement a + // conforming asynchronous operation. When calling an underlying asynchronous + // operation, we pass it this enclosing intermediate completion handler + // as the completion token. + // + // All arguments after the first must be defaulted to allow the state machine + // to be started, as well as to allow the completion handler to match the + // completion signature of both the async_write and steady_timer::async_wait + // operations. + template <typename Self> + void operator()(Self& self, + const std::error_code& error = std::error_code(), + std::size_t = 0) + { + reenter (coro_) + { + while (repeat_count_ > 0) + { + --repeat_count_; + + delay_timer_->expires_after(std::chrono::seconds(1)); + yield delay_timer_->async_wait(std::move(self)); + if (error) + break; + + yield asio::async_write(socket_, + asio::buffer(*encoded_message_), std::move(self)); + if (error) + break; + } + + // Deallocate the encoded message and delay timer before calling the + // user-supplied completion handler. + encoded_message_.reset(); + delay_timer_.reset(); + + // Call the user-supplied handler with the result of the operation. + self.complete(error); + } + } +}; + +#include <asio/unyield.hpp> + +template <typename T, typename CompletionToken> +auto async_write_messages(tcp::socket& socket, + const T& message, std::size_t repeat_count, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++11 we deduce the type from the call to asio::async_compose. + -> decltype( + asio::async_compose< + CompletionToken, void(std::error_code)>( + std::declval<async_write_messages_implementation>(), + token, socket)) +{ + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the composed asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // Create a steady_timer to be used for the delay between messages. + std::unique_ptr<asio::steady_timer> delay_timer( + new asio::steady_timer(socket.get_executor())); + + // The asio::async_compose function takes: + // + // - our asynchronous operation implementation, + // - the completion token, + // - the completion handler signature, and + // - any I/O objects (or executors) used by the operation + // + // It then wraps our implementation in an intermediate completion handler + // that meets the requirements of a conforming asynchronous operation. This + // includes tracking outstanding work against the I/O executors associated + // with the operation (in this example, this is the socket's executor). + return asio::async_compose< + CompletionToken, void(std::error_code)>( + async_write_messages_implementation{socket, + std::move(encoded_message), repeat_count, + std::move(delay_timer), asio::coroutine()}, + token, socket); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_messages(socket, "Testing callback\r\n", 5, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation and its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_messages(socket, + "Testing deferred\r\n", 5, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_messages( + socket, "Testing future\r\n", 5, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Messages sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp11/parallel_group/ranged_wait_for_all.cpp b/3rdparty/asio/src/examples/cpp11/parallel_group/ranged_wait_for_all.cpp new file mode 100644 index 00000000000..18772884072 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/parallel_group/ranged_wait_for_all.cpp @@ -0,0 +1,70 @@ +// +// ranged_wait_for_all.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/parallel_group.hpp> +#include <iostream> +#include <vector> + +#ifdef ASIO_HAS_POSIX_STREAM_DESCRIPTOR + +int main() +{ + asio::io_context ctx; + + asio::posix::stream_descriptor out(ctx, ::dup(STDOUT_FILENO)); + asio::posix::stream_descriptor err(ctx, ::dup(STDERR_FILENO)); + + using op_type = decltype( + out.async_write_some( + asio::buffer("", 0), + asio::deferred + ) + ); + + std::vector<op_type> ops; + + ops.push_back( + out.async_write_some( + asio::buffer("first\r\n", 7), + asio::deferred + ) + ); + + ops.push_back( + err.async_write_some( + asio::buffer("second\r\n", 8), + asio::deferred + ) + ); + + asio::experimental::make_parallel_group(ops).async_wait( + asio::experimental::wait_for_all(), + []( + std::vector<std::size_t> completion_order, + std::vector<std::error_code> ec, + std::vector<std::size_t> n + ) + { + for (std::size_t i = 0; i < completion_order.size(); ++i) + { + std::size_t idx = completion_order[i]; + std::cout << "operation " << idx << " finished: "; + std::cout << ec[idx] << ", " << n[idx] << "\n"; + } + } + ); + + ctx.run(); +} + +#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +int main() {} +#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_all.cpp b/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_all.cpp new file mode 100644 index 00000000000..a489a2966da --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_all.cpp @@ -0,0 +1,62 @@ +// +// wait_for_all.cpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/deferred.hpp> +#include <asio/experimental/parallel_group.hpp> +#include <iostream> + +#ifdef ASIO_HAS_POSIX_STREAM_DESCRIPTOR + +int main() +{ + asio::io_context ctx; + + asio::posix::stream_descriptor in(ctx, ::dup(STDIN_FILENO)); + asio::steady_timer timer(ctx, std::chrono::seconds(5)); + + char data[1024]; + + asio::experimental::make_parallel_group( + in.async_read_some( + asio::buffer(data), + asio::deferred), + timer.async_wait( + asio::deferred) + ).async_wait( + asio::experimental::wait_for_all(), + []( + std::array<std::size_t, 2> completion_order, + std::error_code ec1, std::size_t n1, + std::error_code ec2 + ) + { + switch (completion_order[0]) + { + case 0: + { + std::cout << "descriptor finished: " << ec1 << ", " << n1 << "\n"; + } + break; + case 1: + { + std::cout << "timer finished: " << ec2 << "\n"; + } + break; + } + } + ); + + ctx.run(); +} + +#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +int main() {} +#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_one.cpp b/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_one.cpp new file mode 100644 index 00000000000..499684af69f --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_one.cpp @@ -0,0 +1,62 @@ +// +// wait_for_one.cpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/deferred.hpp> +#include <asio/experimental/parallel_group.hpp> +#include <iostream> + +#if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) + +int main() +{ + asio::io_context ctx; + + asio::posix::stream_descriptor in(ctx, ::dup(STDIN_FILENO)); + asio::steady_timer timer(ctx, std::chrono::seconds(5)); + + char data[1024]; + + asio::experimental::make_parallel_group( + in.async_read_some( + asio::buffer(data), + asio::deferred), + timer.async_wait( + asio::deferred) + ).async_wait( + asio::experimental::wait_for_one(), + []( + std::array<std::size_t, 2> completion_order, + std::error_code ec1, std::size_t n1, + std::error_code ec2 + ) + { + switch (completion_order[0]) + { + case 0: + { + std::cout << "descriptor finished: " << ec1 << ", " << n1 << "\n"; + } + break; + case 1: + { + std::cout << "timer finished: " << ec2 << "\n"; + } + break; + } + } + ); + + ctx.run(); +} + +#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +int main() {} +#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_one_error.cpp b/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_one_error.cpp new file mode 100644 index 00000000000..f6e52d6ca0e --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_one_error.cpp @@ -0,0 +1,62 @@ +// +// wait_for_one_error.cpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/deferred.hpp> +#include <asio/experimental/parallel_group.hpp> +#include <iostream> + +#if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) + +int main() +{ + asio::io_context ctx; + + asio::posix::stream_descriptor in(ctx, ::dup(STDIN_FILENO)); + asio::steady_timer timer(ctx, std::chrono::seconds(5)); + + char data[1024]; + + asio::experimental::make_parallel_group( + in.async_read_some( + asio::buffer(data), + asio::deferred), + timer.async_wait( + asio::deferred) + ).async_wait( + asio::experimental::wait_for_one_error(), + []( + std::array<std::size_t, 2> completion_order, + std::error_code ec1, std::size_t n1, + std::error_code ec2 + ) + { + switch (completion_order[0]) + { + case 0: + { + std::cout << "descriptor finished: " << ec1 << ", " << n1 << "\n"; + } + break; + case 1: + { + std::cout << "timer finished: " << ec2 << "\n"; + } + break; + } + } + ); + + ctx.run(); +} + +#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +int main() {} +#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_one_success.cpp b/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_one_success.cpp new file mode 100644 index 00000000000..16fd2130ab8 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/parallel_group/wait_for_one_success.cpp @@ -0,0 +1,62 @@ +// +// wait_for_one_error.cpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/deferred.hpp> +#include <asio/experimental/parallel_group.hpp> +#include <iostream> + +#if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) + +int main() +{ + asio::io_context ctx; + + asio::posix::stream_descriptor in(ctx, ::dup(STDIN_FILENO)); + asio::steady_timer timer(ctx, std::chrono::seconds(5)); + + char data[1024]; + + asio::experimental::make_parallel_group( + in.async_read_some( + asio::buffer(data), + asio::deferred), + timer.async_wait( + asio::deferred) + ).async_wait( + asio::experimental::wait_for_one_success(), + []( + std::array<std::size_t, 2> completion_order, + std::error_code ec1, std::size_t n1, + std::error_code ec2 + ) + { + switch (completion_order[0]) + { + case 0: + { + std::cout << "descriptor finished: " << ec1 << ", " << n1 << "\n"; + } + break; + case 1: + { + std::cout << "timer finished: " << ec2 << "\n"; + } + break; + } + } + ); + + ctx.run(); +} + +#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +int main() {} +#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp03/porthopper/client.cpp b/3rdparty/asio/src/examples/cpp11/porthopper/client.cpp index 15d8e4803c1..e0936128d72 100644 --- a/3rdparty/asio/src/examples/cpp03/porthopper/client.cpp +++ b/3rdparty/asio/src/examples/cpp11/porthopper/client.cpp @@ -2,25 +2,22 @@ // client.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include <asio.hpp> -#include <boost/lambda/lambda.hpp> -#include <boost/lambda/bind.hpp> -#include <boost/lambda/if.hpp> -#include <boost/shared_ptr.hpp> #include <algorithm> #include <cstdlib> #include <exception> #include <iostream> +#include <memory> #include <string> +#include <utility> #include "protocol.hpp" -using namespace boost; using asio::ip::tcp; using asio::ip::udp; @@ -48,11 +45,10 @@ int main(int argc, char* argv[]) control_socket.connect(remote_endpoint); // Create a datagram socket to receive data from the server. - boost::shared_ptr<udp::socket> data_socket( - new udp::socket(io_context, udp::endpoint(udp::v4(), 0))); + udp::socket data_socket(io_context, udp::endpoint(udp::v4(), 0)); // Determine what port we will receive data on. - udp::endpoint data_endpoint = data_socket->local_endpoint(); + udp::endpoint data_endpoint = data_socket.local_endpoint(); // Ask the server to start sending us data. control_request start = control_request::start(data_endpoint.port()); @@ -66,7 +62,7 @@ int main(int argc, char* argv[]) { // Receive a frame from the server. frame f; - data_socket->receive(f.to_buffers(), 0); + data_socket.receive(f.to_buffers(), 0); if (f.number() > last_frame_number) { last_frame_number = f.number(); @@ -80,20 +76,20 @@ int main(int argc, char* argv[]) std::cout << " Starting renegotiation"; // Create the new data socket. - boost::shared_ptr<udp::socket> new_data_socket( - new udp::socket(io_context, udp::endpoint(udp::v4(), 0))); + udp::socket new_data_socket(io_context, udp::endpoint(udp::v4(), 0)); // Determine the new port we will use to receive data. - udp::endpoint new_data_endpoint = new_data_socket->local_endpoint(); + udp::endpoint new_data_endpoint = new_data_socket.local_endpoint(); // Ask the server to switch over to the new port. control_request change = control_request::change( data_endpoint.port(), new_data_endpoint.port()); - asio::error_code control_result; + std::error_code control_result; asio::async_write(control_socket, change.to_buffers(), - ( - lambda::var(control_result) = lambda::_1 - )); + [&](std::error_code ec, std::size_t /*length*/) + { + control_result = ec; + }); // Try to receive a frame from the server on the new data socket. If we // successfully receive a frame on this new data socket we can consider @@ -101,20 +97,19 @@ int main(int argc, char* argv[]) // socket, which will cause any outstanding receive operation on it to be // cancelled. frame f1; - asio::error_code new_data_socket_result; - new_data_socket->async_receive(f1.to_buffers(), - ( - // Note: lambda::_1 is the first argument to the callback handler, - // which in this case is the error code for the operation. - lambda::var(new_data_socket_result) = lambda::_1, - lambda::if_(!lambda::_1) - [ + std::error_code new_data_socket_result; + new_data_socket.async_receive(f1.to_buffers(), + [&](std::error_code ec, std::size_t /*length*/) + { + new_data_socket_result = ec; + if (!ec) + { // We have successfully received a frame on the new data socket, // so we can close the old data socket. This will cancel any // outstanding receive operation on the old data socket. - lambda::var(data_socket) = boost::shared_ptr<udp::socket>() - ] - )); + data_socket.close(); + } + }); // This loop will continue until we have successfully completed the // renegotiation (i.e. received a frame on the new data socket), or some @@ -130,18 +125,19 @@ int main(int argc, char* argv[]) // complete. frame f2; done = true; // Let's be optimistic. - if (data_socket) // Might have been closed by new_data_socket's handler. + if (data_socket.is_open()) // May have been closed by receive handler. { - data_socket->async_receive(f2.to_buffers(), 0, - ( - lambda::if_(!lambda::_1) - [ + data_socket.async_receive(f2.to_buffers(), 0, + [&](std::error_code ec, std::size_t /*length*/) + { + if (!ec) + { // We have successfully received a frame on the old data // socket. Stop the io_context so that we can print it. - lambda::bind(&asio::io_context::stop, &io_context), - lambda::var(done) = false - ] - )); + io_context.stop(); + done = false; + } + }); } // Run the operations in parallel. This will block until all operations @@ -166,15 +162,15 @@ int main(int argc, char* argv[]) // the renegotation, or an error has occurred. First we'll check for // errors. if (control_result) - throw asio::system_error(control_result); + throw std::system_error(control_result); if (new_data_socket_result) - throw asio::system_error(new_data_socket_result); + throw std::system_error(new_data_socket_result); // If we get here it means we have successfully started receiving data on // the new data socket. This new data socket will be used from now on // (until the next time we renegotiate). std::cout << " Renegotiation complete"; - data_socket = new_data_socket; + data_socket = std::move(new_data_socket); data_endpoint = new_data_endpoint; if (f1.number() > last_frame_number) { diff --git a/3rdparty/asio/src/examples/cpp03/porthopper/protocol.hpp b/3rdparty/asio/src/examples/cpp11/porthopper/protocol.hpp index c79bc6b49f4..46f9938cad5 100644 --- a/3rdparty/asio/src/examples/cpp03/porthopper/protocol.hpp +++ b/3rdparty/asio/src/examples/cpp11/porthopper/protocol.hpp @@ -2,7 +2,7 @@ // protocol.hpp // ~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,8 +11,8 @@ #ifndef PORTHOPPER_PROTOCOL_HPP #define PORTHOPPER_PROTOCOL_HPP -#include <boost/array.hpp> #include <asio.hpp> +#include <array> #include <cstring> #include <iomanip> #include <string> @@ -69,9 +69,9 @@ public: } // Obtain buffers for reading from or writing to a socket. - boost::array<asio::mutable_buffer, 1> to_buffers() + std::array<asio::mutable_buffer, 1> to_buffers() { - boost::array<asio::mutable_buffer, 1> buffers + std::array<asio::mutable_buffer, 1> buffers = { { asio::buffer(data_) } }; return buffers; } @@ -134,9 +134,9 @@ public: } // Obtain buffers for reading from or writing to a socket. - boost::array<asio::mutable_buffer, 1> to_buffers() + std::array<asio::mutable_buffer, 1> to_buffers() { - boost::array<asio::mutable_buffer, 1> buffers + std::array<asio::mutable_buffer, 1> buffers = { { asio::buffer(data_) } }; return buffers; } diff --git a/3rdparty/asio/src/examples/cpp03/porthopper/server.cpp b/3rdparty/asio/src/examples/cpp11/porthopper/server.cpp index b98a7d4b24d..4a77622e593 100644 --- a/3rdparty/asio/src/examples/cpp03/porthopper/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/porthopper/server.cpp @@ -2,28 +2,28 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include <asio.hpp> -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> #include <cmath> #include <cstdlib> #include <exception> +#include <functional> #include <iostream> +#include <memory> #include <set> #include "protocol.hpp" using asio::ip::tcp; using asio::ip::udp; -typedef boost::shared_ptr<tcp::socket> tcp_socket_ptr; -typedef boost::shared_ptr<asio::deadline_timer> timer_ptr; -typedef boost::shared_ptr<control_request> control_request_ptr; +typedef std::shared_ptr<tcp::socket> tcp_socket_ptr; +typedef std::shared_ptr<asio::steady_timer> timer_ptr; +typedef std::shared_ptr<control_request> control_request_ptr; class server { @@ -36,49 +36,47 @@ public: next_frame_number_(1) { // Start waiting for a new control connection. - tcp_socket_ptr new_socket( - new tcp::socket(acceptor_.get_executor().context())); + tcp_socket_ptr new_socket(new tcp::socket(acceptor_.get_executor())); acceptor_.async_accept(*new_socket, - boost::bind(&server::handle_accept, this, + std::bind(&server::handle_accept, this, asio::placeholders::error, new_socket)); // Start the timer used to generate outgoing frames. - timer_.expires_from_now(boost::posix_time::milliseconds(100)); - timer_.async_wait(boost::bind(&server::handle_timer, this)); + timer_.expires_after(asio::chrono::milliseconds(100)); + timer_.async_wait(std::bind(&server::handle_timer, this)); } // Handle a new control connection. - void handle_accept(const asio::error_code& ec, tcp_socket_ptr socket) + void handle_accept(const std::error_code& ec, tcp_socket_ptr socket) { if (!ec) { // Start receiving control requests on the connection. control_request_ptr request(new control_request); asio::async_read(*socket, request->to_buffers(), - boost::bind(&server::handle_control_request, this, + std::bind(&server::handle_control_request, this, asio::placeholders::error, socket, request)); } // Start waiting for a new control connection. - tcp_socket_ptr new_socket( - new tcp::socket(acceptor_.get_executor().context())); + tcp_socket_ptr new_socket(new tcp::socket(acceptor_.get_executor())); acceptor_.async_accept(*new_socket, - boost::bind(&server::handle_accept, this, + std::bind(&server::handle_accept, this, asio::placeholders::error, new_socket)); } // Handle a new control request. - void handle_control_request(const asio::error_code& ec, + void handle_control_request(const std::error_code& ec, tcp_socket_ptr socket, control_request_ptr request) { if (!ec) { // Delay handling of the control request to simulate network latency. timer_ptr delay_timer( - new asio::deadline_timer(acceptor_.get_executor().context())); - delay_timer->expires_from_now(boost::posix_time::seconds(2)); + new asio::steady_timer(acceptor_.get_executor())); + delay_timer->expires_after(asio::chrono::seconds(2)); delay_timer->async_wait( - boost::bind(&server::handle_control_request_timer, this, + std::bind(&server::handle_control_request_timer, this, socket, request, delay_timer)); } } @@ -90,7 +88,7 @@ public: // subscriptions must be stored on the server as a complete endpoint, not // just a port. We use the non-throwing overload of remote_endpoint() since // it may fail if the socket is no longer connected. - asio::error_code ec; + std::error_code ec; tcp::endpoint remote_endpoint = socket->remote_endpoint(ec); if (!ec) { @@ -113,7 +111,7 @@ public: // Wait for next control request on this connection. asio::async_read(*socket, request->to_buffers(), - boost::bind(&server::handle_control_request, this, + std::bind(&server::handle_control_request, this, asio::placeholders::error, socket, request)); } @@ -137,13 +135,13 @@ public: std::set<udp::endpoint>::iterator j; for (j = subscribers_.begin(); j != subscribers_.end(); ++j) { - asio::error_code ec; + std::error_code ec; udp_socket_.send_to(f.to_buffers(), *j, 0, ec); } // Wait for next timeout. - timer_.expires_from_now(boost::posix_time::milliseconds(100)); - timer_.async_wait(boost::bind(&server::handle_timer, this)); + timer_.expires_after(asio::chrono::milliseconds(100)); + timer_.async_wait(std::bind(&server::handle_timer, this)); } private: @@ -151,7 +149,7 @@ private: tcp::acceptor acceptor_; // The timer used for generating data. - asio::deadline_timer timer_; + asio::steady_timer timer_; // The socket used to send data to subscribers. udp::socket udp_socket_; diff --git a/3rdparty/asio/src/examples/cpp03/serialization/client.cpp b/3rdparty/asio/src/examples/cpp11/serialization/client.cpp index 8b83de284f4..10ec87f6da4 100644 --- a/3rdparty/asio/src/examples/cpp03/serialization/client.cpp +++ b/3rdparty/asio/src/examples/cpp11/serialization/client.cpp @@ -2,14 +2,14 @@ // client.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include <asio.hpp> -#include <boost/bind.hpp> +#include <functional> #include <iostream> #include <vector> #include "connection.hpp" // Must come before boost/serialization headers. @@ -25,7 +25,7 @@ public: /// Constructor starts the asynchronous connect operation. client(asio::io_context& io_context, const std::string& host, const std::string& service) - : connection_(io_context) + : connection_(io_context.get_executor()) { // Resolve the host name into an IP address. asio::ip::tcp::resolver resolver(io_context); @@ -35,7 +35,7 @@ public: // Start an asynchronous connect operation. asio::async_connect(connection_.socket(), endpoint_iterator, - boost::bind(&client::handle_connect, this, + std::bind(&client::handle_connect, this, asio::placeholders::error)); } @@ -48,7 +48,7 @@ public: // of stocks. The connection::async_read() function will automatically // decode the data that is read from the underlying socket. connection_.async_read(stocks_, - boost::bind(&client::handle_read, this, + std::bind(&client::handle_read, this, asio::placeholders::error)); } else diff --git a/3rdparty/asio/src/examples/cpp03/serialization/connection.hpp b/3rdparty/asio/src/examples/cpp11/serialization/connection.hpp index a1fa2a19e8e..14d96f7597b 100644 --- a/3rdparty/asio/src/examples/cpp03/serialization/connection.hpp +++ b/3rdparty/asio/src/examples/cpp11/serialization/connection.hpp @@ -2,7 +2,7 @@ // connection.hpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -14,12 +14,12 @@ #include <asio.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/tuple/tuple.hpp> +#include <functional> #include <iomanip> +#include <memory> #include <string> #include <sstream> +#include <tuple> #include <vector> namespace s11n_example { @@ -35,8 +35,8 @@ class connection { public: /// Constructor. - connection(asio::io_context& io_context) - : socket_(io_context) + connection(const asio::any_io_executor& ex) + : socket_(ex) { } @@ -64,8 +64,8 @@ public: if (!header_stream || header_stream.str().size() != header_length) { // Something went wrong, inform the caller. - asio::error_code error(asio::error::invalid_argument); - socket_.get_io_context().post(boost::bind(handler, error)); + std::error_code error(asio::error::invalid_argument); + asio::post(socket_.get_executor(), std::bind(handler, error)); return; } outbound_header_ = header_stream.str(); @@ -83,26 +83,22 @@ public: void async_read(T& t, Handler handler) { // Issue a read operation to read exactly the number of bytes in a header. - void (connection::*f)( - const asio::error_code&, - T&, boost::tuple<Handler>) + void (connection::*f)(const std::error_code&, T&, std::tuple<Handler>) = &connection::handle_read_header<T, Handler>; asio::async_read(socket_, asio::buffer(inbound_header_), - boost::bind(f, - this, asio::placeholders::error, boost::ref(t), - boost::make_tuple(handler))); + std::bind(f, + this, asio::placeholders::error, std::ref(t), + std::make_tuple(handler))); } - /// Handle a completed read of a message header. The handler is passed using - /// a tuple since boost::bind seems to have trouble binding a function object - /// created using boost::bind as a parameter. + /// Handle a completed read of a message header. template <typename T, typename Handler> - void handle_read_header(const asio::error_code& e, - T& t, boost::tuple<Handler> handler) + void handle_read_header(const std::error_code& e, + T& t, std::tuple<Handler> handler) { if (e) { - boost::get<0>(handler)(e); + std::get<0>(handler)(e); } else { @@ -112,31 +108,31 @@ public: if (!(is >> std::hex >> inbound_data_size)) { // Header doesn't seem to be valid. Inform the caller. - asio::error_code error(asio::error::invalid_argument); - boost::get<0>(handler)(error); + std::error_code error(asio::error::invalid_argument); + std::get<0>(handler)(error); return; } // Start an asynchronous call to receive the data. inbound_data_.resize(inbound_data_size); void (connection::*f)( - const asio::error_code&, - T&, boost::tuple<Handler>) + const std::error_code&, + T&, std::tuple<Handler>) = &connection::handle_read_data<T, Handler>; asio::async_read(socket_, asio::buffer(inbound_data_), - boost::bind(f, this, - asio::placeholders::error, boost::ref(t), handler)); + std::bind(f, this, + asio::placeholders::error, std::ref(t), handler)); } } /// Handle a completed read of message data. template <typename T, typename Handler> - void handle_read_data(const asio::error_code& e, - T& t, boost::tuple<Handler> handler) + void handle_read_data(const std::error_code& e, + T& t, std::tuple<Handler> handler) { if (e) { - boost::get<0>(handler)(e); + std::get<0>(handler)(e); } else { @@ -151,13 +147,13 @@ public: catch (std::exception& e) { // Unable to decode data. - asio::error_code error(asio::error::invalid_argument); - boost::get<0>(handler)(error); + std::error_code error(asio::error::invalid_argument); + std::get<0>(handler)(error); return; } // Inform caller that data has been received ok. - boost::get<0>(handler)(e); + std::get<0>(handler)(e); } } @@ -181,7 +177,7 @@ private: std::vector<char> inbound_data_; }; -typedef boost::shared_ptr<connection> connection_ptr; +typedef std::shared_ptr<connection> connection_ptr; } // namespace s11n_example diff --git a/3rdparty/asio/src/examples/cpp03/serialization/server.cpp b/3rdparty/asio/src/examples/cpp11/serialization/server.cpp index b81b1a424da..a032e86dc78 100644 --- a/3rdparty/asio/src/examples/cpp03/serialization/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/serialization/server.cpp @@ -2,15 +2,14 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include <asio.hpp> -#include <boost/bind.hpp> -#include <boost/lexical_cast.hpp> +#include <functional> #include <iostream> #include <vector> #include "connection.hpp" // Must come before boost/serialization headers. @@ -55,14 +54,14 @@ public: stocks_.push_back(s); // Start an accept operation for a new connection. - connection_ptr new_conn(new connection(acceptor_.get_io_context())); + connection_ptr new_conn(new connection(acceptor_.get_executor())); acceptor_.async_accept(new_conn->socket(), - boost::bind(&server::handle_accept, this, + std::bind(&server::handle_accept, this, asio::placeholders::error, new_conn)); } /// Handle completion of a accept operation. - void handle_accept(const asio::error_code& e, connection_ptr conn) + void handle_accept(const std::error_code& e, connection_ptr conn) { if (!e) { @@ -70,19 +69,19 @@ public: // client. The connection::async_write() function will automatically // serialize the data structure for us. conn->async_write(stocks_, - boost::bind(&server::handle_write, this, + std::bind(&server::handle_write, this, asio::placeholders::error, conn)); } // Start an accept operation for a new connection. - connection_ptr new_conn(new connection(acceptor_.get_io_context())); + connection_ptr new_conn(new connection(acceptor_.get_executor())); acceptor_.async_accept(new_conn->socket(), - boost::bind(&server::handle_accept, this, + std::bind(&server::handle_accept, this, asio::placeholders::error, new_conn)); } /// Handle completion of a write operation. - void handle_write(const asio::error_code& e, connection_ptr conn) + void handle_write(const std::error_code& e, connection_ptr conn) { // Nothing to do. The socket will be closed automatically when the last // reference to the connection object goes away. @@ -108,7 +107,7 @@ int main(int argc, char* argv[]) std::cerr << "Usage: server <port>" << std::endl; return 1; } - unsigned short port = boost::lexical_cast<unsigned short>(argv[1]); + unsigned short port = std::stoi(argv[1]); asio::io_context io_context; s11n_example::server server(io_context, port); diff --git a/3rdparty/asio/src/examples/cpp03/serialization/stock.hpp b/3rdparty/asio/src/examples/cpp11/serialization/stock.hpp index 1acbca5a7a6..bb305518cae 100644 --- a/3rdparty/asio/src/examples/cpp03/serialization/stock.hpp +++ b/3rdparty/asio/src/examples/cpp11/serialization/stock.hpp @@ -2,7 +2,7 @@ // stock.hpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/services/basic_logger.hpp b/3rdparty/asio/src/examples/cpp11/services/basic_logger.hpp index 876086a2ecf..6e4d7a0b05d 100644 --- a/3rdparty/asio/src/examples/cpp03/services/basic_logger.hpp +++ b/3rdparty/asio/src/examples/cpp11/services/basic_logger.hpp @@ -2,7 +2,7 @@ // basic_logger.hpp // ~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,7 +12,6 @@ #define SERVICES_BASIC_LOGGER_HPP #include <asio.hpp> -#include <boost/noncopyable.hpp> #include <string> namespace services { @@ -21,7 +20,6 @@ namespace services { /// typedef. template <typename Service> class basic_logger - : private boost::noncopyable { public: /// The type of the service that will be used to provide timer operations. @@ -34,30 +32,27 @@ public: /** * This constructor creates a logger. * - * @param io_context The io_context object used to locate the logger service. + * @param context The execution context used to locate the logger service. * * @param identifier An identifier for this logger. */ - explicit basic_logger(asio::io_context& io_context, + explicit basic_logger(asio::execution_context& context, const std::string& identifier) - : service_(asio::use_service<Service>(io_context)), + : service_(asio::use_service<Service>(context)), impl_(service_.null()) { service_.create(impl_, identifier); } + basic_logger(const basic_logger&) = delete; + basic_logger& operator=(basic_logger&) = delete; + /// Destructor. ~basic_logger() { service_.destroy(impl_); } - /// Get the io_context associated with the object. - asio::io_context& get_io_context() - { - return service_.get_io_context(); - } - /// Set the output file for all logger instances. void use_file(const std::string& file) { diff --git a/3rdparty/asio/src/examples/cpp03/services/daytime_client.cpp b/3rdparty/asio/src/examples/cpp11/services/daytime_client.cpp index e0a6af9df6f..360134f64c2 100644 --- a/3rdparty/asio/src/examples/cpp03/services/daytime_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/services/daytime_client.cpp @@ -2,14 +2,14 @@ // daytime_client.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include <asio.hpp> -#include <boost/bind.hpp> +#include <functional> #include <iostream> #include "logger.hpp" @@ -25,12 +25,14 @@ void read_handler(const asio::error_code& e, std::cout.write(read_buffer, bytes_transferred); s->async_read_some(asio::buffer(read_buffer), - boost::bind(read_handler, asio::placeholders::error, + std::bind(read_handler, asio::placeholders::error, asio::placeholders::bytes_transferred, s)); } else { - services::logger logger(s->get_executor().context(), "read_handler"); + asio::execution_context& context = asio::query( + s->get_executor(), asio::execution::context); + services::logger logger(context, "read_handler"); std::string msg = "Read error: "; msg += e.message(); @@ -40,14 +42,16 @@ void read_handler(const asio::error_code& e, void connect_handler(const asio::error_code& e, tcp::socket* s) { - services::logger logger(s->get_executor().context(), "connect_handler"); + asio::execution_context& context = asio::query( + s->get_executor(), asio::execution::context); + services::logger logger(context, "connect_handler"); if (!e) { logger.log("Connection established"); s->async_read_some(asio::buffer(read_buffer), - boost::bind(read_handler, asio::placeholders::error, + std::bind(read_handler, asio::placeholders::error, asio::placeholders::bytes_transferred, s)); } else @@ -82,7 +86,7 @@ int main(int argc, char* argv[]) // Start an asynchronous connect. tcp::socket socket(io_context); asio::async_connect(socket, endpoints, - boost::bind(connect_handler, + std::bind(connect_handler, asio::placeholders::error, &socket)); // Run the io_context until all operations have finished. diff --git a/3rdparty/asio/src/examples/cpp03/services/logger.hpp b/3rdparty/asio/src/examples/cpp11/services/logger.hpp index 41d17e6de10..2ab366c83c6 100644 --- a/3rdparty/asio/src/examples/cpp03/services/logger.hpp +++ b/3rdparty/asio/src/examples/cpp11/services/logger.hpp @@ -2,7 +2,7 @@ // logger.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp03/services/logger_service.cpp b/3rdparty/asio/src/examples/cpp11/services/logger_service.cpp index c3543e47f5a..74d67c75241 100644 --- a/3rdparty/asio/src/examples/cpp03/services/logger_service.cpp +++ b/3rdparty/asio/src/examples/cpp11/services/logger_service.cpp @@ -2,16 +2,10 @@ // logger_service.cpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "logger_service.hpp" - -namespace services { - -asio::io_context::id logger_service::id; - -} // namespace services diff --git a/3rdparty/asio/src/examples/cpp03/services/logger_service.hpp b/3rdparty/asio/src/examples/cpp11/services/logger_service.hpp index 9f175dffba3..d0beaf1d6c2 100644 --- a/3rdparty/asio/src/examples/cpp03/services/logger_service.hpp +++ b/3rdparty/asio/src/examples/cpp11/services/logger_service.hpp @@ -2,7 +2,7 @@ // logger_service.hpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,23 +12,21 @@ #define SERVICES_LOGGER_SERVICE_HPP #include <asio.hpp> -#include <boost/bind.hpp> -#include <boost/date_time/posix_time/posix_time.hpp> -#include <boost/noncopyable.hpp> -#include <boost/scoped_ptr.hpp> +#include <functional> #include <fstream> #include <sstream> #include <string> +#include <thread> namespace services { /// Service implementation for the logger. class logger_service - : public asio::io_context::service + : public asio::execution_context::service { public: - /// The unique service identifier. - static asio::io_context::id id; + /// The type used to identify this service in the execution context. + typedef logger_service key_type; /// The backend implementation of a logger. struct logger_impl @@ -41,27 +39,29 @@ public: typedef logger_impl* impl_type; /// Constructor creates a thread to run a private io_context. - logger_service(asio::io_context& io_context) - : asio::io_context::service(io_context), + logger_service(asio::execution_context& context) + : asio::execution_context::service(context), work_io_context_(), work_(asio::make_work_guard(work_io_context_)), - work_thread_(new asio::thread( - boost::bind(&asio::io_context::run, &work_io_context_))) + work_thread_([this]{ work_io_context_.run(); }) { } + logger_service(const logger_service&) = delete; + logger_service& operator=(const logger_service&) = delete;; + /// Destructor shuts down the private io_context. ~logger_service() { /// Indicate that we have finished with the private io_context. Its /// io_context::run() function will exit once all other work has completed. work_.reset(); - if (work_thread_) - work_thread_->join(); + if (work_thread_.joinable()) + work_thread_.join(); } /// Destroy all user-defined handler objects owned by the service. - void shutdown_service() + void shutdown() { } @@ -91,8 +91,8 @@ public: void use_file(impl_type& /*impl*/, const std::string& file) { // Pass the work of opening the file to the background thread. - asio::post(work_io_context_, boost::bind( - &logger_service::use_file_impl, this, file)); + asio::post(work_io_context_, + std::bind(&logger_service::use_file_impl, this, file)); } /// Log a message. @@ -102,9 +102,9 @@ public: std::ostringstream os; os << impl->identifier << ": " << message; - // Pass the work of opening the file to the background thread. - asio::post(work_io_context_, boost::bind( - &logger_service::log_impl, this, os.str())); + // Pass the work of writing to the file to the background thread. + asio::post(work_io_context_, + std::bind(&logger_service::log_impl, this, os.str())); } private: @@ -134,7 +134,7 @@ private: asio::io_context::executor_type> work_; /// Thread used for running the work io_context's run loop. - boost::scoped_ptr<asio::thread> work_thread_; + std::thread work_thread_; /// The file to which log messages will be written. std::ofstream ofstream_; diff --git a/3rdparty/asio/src/examples/cpp03/socks4/socks4.hpp b/3rdparty/asio/src/examples/cpp11/socks4/socks4.hpp index c5558756558..ed7994021fc 100644 --- a/3rdparty/asio/src/examples/cpp03/socks4/socks4.hpp +++ b/3rdparty/asio/src/examples/cpp11/socks4/socks4.hpp @@ -2,7 +2,7 @@ // socks4.hpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -11,9 +11,10 @@ #ifndef SOCKS4_HPP #define SOCKS4_HPP +#include <array> #include <string> -#include <asio.hpp> -#include <boost/array.hpp> +#include <asio/buffer.hpp> +#include <asio/ip/tcp.hpp> namespace socks4 { @@ -38,7 +39,7 @@ public: // Only IPv4 is supported by the SOCKS 4 protocol. if (endpoint.protocol() != asio::ip::tcp::v4()) { - throw asio::system_error( + throw std::system_error( asio::error::address_family_not_supported); } @@ -51,9 +52,9 @@ public: address_ = endpoint.address().to_v4().to_bytes(); } - boost::array<asio::const_buffer, 7> buffers() const + std::array<asio::const_buffer, 7> buffers() const { - boost::array<asio::const_buffer, 7> bufs = + return { { asio::buffer(&version_, 1), @@ -65,7 +66,6 @@ public: asio::buffer(&null_byte_, 1) } }; - return bufs; } private: @@ -95,9 +95,9 @@ public: { } - boost::array<asio::mutable_buffer, 5> buffers() + std::array<asio::mutable_buffer, 5> buffers() { - boost::array<asio::mutable_buffer, 5> bufs = + return { { asio::buffer(&null_byte_, 1), @@ -107,7 +107,6 @@ public: asio::buffer(address_) } }; - return bufs; } bool success() const diff --git a/3rdparty/asio/src/examples/cpp03/socks4/sync_client.cpp b/3rdparty/asio/src/examples/cpp11/socks4/sync_client.cpp index 7b82564ab53..f661aca8da5 100644 --- a/3rdparty/asio/src/examples/cpp03/socks4/sync_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/socks4/sync_client.cpp @@ -2,18 +2,18 @@ // sync_client.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <array> #include <iostream> #include <iomanip> #include <ostream> #include <string> #include <asio.hpp> -#include <boost/array.hpp> #include "socks4.hpp" using asio::ip::tcp; @@ -35,7 +35,7 @@ int main(int argc, char* argv[]) // Get a list of endpoints corresponding to the SOCKS 4 server name. tcp::resolver resolver(io_context); - tcp::resolver::results_type endpoints = resolver.resolve(argv[1], argv[2]); + auto endpoints = resolver.resolve(argv[1], argv[2]); // Try each endpoint until we successfully establish a connection to the // SOCKS 4 server. @@ -44,7 +44,7 @@ int main(int argc, char* argv[]) // Get an endpoint for the Boost website. This will be passed to the SOCKS // 4 server. Explicitly specify IPv4 since SOCKS 4 does not support IPv6. - tcp::endpoint http_endpoint = + auto http_endpoint = *resolver.resolve(tcp::v4(), "www.boost.org", "http").begin(); // Send the request to the SOCKS 4 server. @@ -77,13 +77,13 @@ int main(int argc, char* argv[]) asio::write(socket, asio::buffer(request)); // Read until EOF, writing data to output as we go. - boost::array<char, 512> response; - asio::error_code error; + std::array<char, 512> response; + std::error_code error; while (std::size_t s = socket.read_some( asio::buffer(response), error)) std::cout.write(response.data(), s); if (error != asio::error::eof) - throw asio::system_error(error); + throw std::system_error(error); } catch (std::exception& e) { diff --git a/3rdparty/asio/src/examples/cpp11/spawn/.gitignore b/3rdparty/asio/src/examples/cpp11/spawn/.gitignore deleted file mode 100644 index 6b8a121e099..00000000000 --- a/3rdparty/asio/src/examples/cpp11/spawn/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -.deps -.dirstamp -parallel_grep -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp11/spawn/echo_server.cpp b/3rdparty/asio/src/examples/cpp11/spawn/echo_server.cpp index 5397a4efe22..ae949d60bef 100644 --- a/3rdparty/asio/src/examples/cpp11/spawn/echo_server.cpp +++ b/3rdparty/asio/src/examples/cpp11/spawn/echo_server.cpp @@ -2,12 +2,13 @@ // echo_server.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <asio/detached.hpp> #include <asio/io_context.hpp> #include <asio/ip/tcp.hpp> #include <asio/spawn.hpp> @@ -21,10 +22,10 @@ using asio::ip::tcp; class session : public std::enable_shared_from_this<session> { public: - explicit session(tcp::socket socket) + explicit session(asio::io_context& io_context, tcp::socket socket) : socket_(std::move(socket)), - timer_(socket_.get_io_context()), - strand_(socket_.get_io_context()) + timer_(io_context), + strand_(io_context.get_executor()) { } @@ -39,7 +40,7 @@ public: char data[128]; for (;;) { - timer_.expires_from_now(std::chrono::seconds(10)); + timer_.expires_after(std::chrono::seconds(10)); std::size_t n = socket_.async_read_some(asio::buffer(data), yield); asio::async_write(socket_, asio::buffer(data, n), yield); } @@ -49,25 +50,25 @@ public: socket_.close(); timer_.cancel(); } - }); + }, asio::detached); asio::spawn(strand_, [this, self](asio::yield_context yield) { while (socket_.is_open()) { - asio::error_code ignored_ec; + std::error_code ignored_ec; timer_.async_wait(yield[ignored_ec]); - if (timer_.expires_from_now() <= std::chrono::seconds(0)) + if (timer_.expiry() <= asio::steady_timer::clock_type::now()) socket_.close(); } - }); + }, asio::detached); } private: tcp::socket socket_; asio::steady_timer timer_; - asio::io_context::strand strand_; + asio::strand<asio::io_context::executor_type> strand_; }; int main(int argc, char* argv[]) @@ -90,11 +91,19 @@ int main(int argc, char* argv[]) for (;;) { - asio::error_code ec; + std::error_code ec; tcp::socket socket(io_context); acceptor.async_accept(socket, yield[ec]); - if (!ec) std::make_shared<session>(std::move(socket))->go(); + if (!ec) + { + std::make_shared<session>(io_context, std::move(socket))->go(); + } } + }, + [](std::exception_ptr e) + { + if (e) + std::rethrow_exception(e); }); io_context.run(); diff --git a/3rdparty/asio/src/examples/cpp11/spawn/parallel_grep.cpp b/3rdparty/asio/src/examples/cpp11/spawn/parallel_grep.cpp index 954d9472bbe..f4a5b1136dc 100644 --- a/3rdparty/asio/src/examples/cpp11/spawn/parallel_grep.cpp +++ b/3rdparty/asio/src/examples/cpp11/spawn/parallel_grep.cpp @@ -2,12 +2,13 @@ // parallel_grep.cpp // ~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <asio/detached.hpp> #include <asio/dispatch.hpp> #include <asio/post.hpp> #include <asio/spawn.hpp> @@ -17,6 +18,7 @@ #include <iostream> #include <string> +using asio::detached; using asio::dispatch; using asio::spawn; using asio::strand; @@ -69,7 +71,7 @@ int main(int argc, char* argv[]) if (++line_num % 10 == 0) post(yield); } - }); + }, detached); } // Join the thread pool to wait for all the spawned tasks to complete. diff --git a/3rdparty/asio/src/examples/cpp03/ssl/README b/3rdparty/asio/src/examples/cpp11/ssl/README index 8d94105be5b..8304d0603b6 100644 --- a/3rdparty/asio/src/examples/cpp03/ssl/README +++ b/3rdparty/asio/src/examples/cpp11/ssl/README @@ -2,7 +2,7 @@ The passphrase for both the CA and server private keys is "test". ------------------------------------------------------------------------------- -Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp11/ssl/ca.pem b/3rdparty/asio/src/examples/cpp11/ssl/ca.pem new file mode 100644 index 00000000000..4580bc11bcf --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/ssl/ca.pem @@ -0,0 +1,50 @@ +-----BEGIN CERTIFICATE----- +MIIDVDCCAjygAwIBAgIUX3cVQ47QyJp7SOy0RPzP743W9MwwDQYJKoZIhvcNAQEL +BQAwOzELMAkGA1UEBhMCQVUxDDAKBgNVBAgMA05TVzEPMA0GA1UEBwwGU3lkbmV5 +MQ0wCwYDVQQKDARhc2lvMB4XDTIxMTExMTIxMTA1MloXDTI2MTExMDIxMTA1Mlow +OzELMAkGA1UEBhMCQVUxDDAKBgNVBAgMA05TVzEPMA0GA1UEBwwGU3lkbmV5MQ0w +CwYDVQQKDARhc2lvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyURD +LjKxTCkapmWhY0bP1NaaOPzIJTTB0dzREOlmRmBmiHpW7DaRx7qBm6jYDKQ7OCbz +30/j8K4TjHOLIwxzXhXMYTJOcN2giPHNUBvm9oEuDAhYgltArJQnBBEH+3C1hCIv +1+uhTWo0HpGXTeJnvboTZ1YgmbOgr6lMhNiu9QmPX885DxWf6sDq8mRgCDX2x8sk +Ls0HuLSo88Osjx532yEhnrZgexsByhoRD3yrKHV5mWpaunk5BMsP/XMuQHayFmbO +siqnHJoL1znGVH003PcBGmEDmoIUqhLiBi2gWGu1pmckP9loqQUTEn0aLOVclHf4 +slWq344zh4tJCpQMfQIDAQABo1AwTjAdBgNVHQ4EFgQUfiX1CMQrGDi9mIBAg9cg +m0RwLJUwHwYDVR0jBBgwFoAUfiX1CMQrGDi9mIBAg9cgm0RwLJUwDAYDVR0TBAUw +AwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAnDnVNSb8z/pNFaZ6YAZ+ukfNT3jjbGm1 +10BOLqJj8s5A8/JkwjaWhky/DuGXDywgEvzXC18aNAxASeqO8h9pAZtszu6NWB4s +h3r+dEQakMacxrZ+jBL/cYLrUv9r3KMPKxaDnplkamqFA/9eNmoV7vDyGtGPZuD6 +oTROtQqqDSrxthCkqnibAfusi7RmlCdvJa0kVK7krKJZAhi8W9f32+lBPv9oq3Ns +dAxnOj/D3UnhNoIt0EdjqUdLo2U39dt5s5Syj2rFUAgfbc02Rwx65kq8AjTRlW/M +KDpGsifwIB8b7wActMUO8c3GptptNVWmFm5+Mmk54P//P3tIAx9KXw== +-----END CERTIFICATE----- +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIPcVUeQ7ZElgCAggA +MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECGKlFVN6/gIlBIIEyJPeknsA5dvV +WK27AZzs4wM6WrsD6ba+kPJyZTpon5pn4eoTiw4UCvo7C+21G9jCqbIbDrgTWHwH +zu6YrBFTZgRUpdLkLsyUsp4UJrZ8xJ7N/jWlG763CyluFE5oBFLz2Vt/DSDSaWdA +sKdxua/1kvw+KYoDqlObMFIspM5TrndcMnWkOgyvQAvnH0NZXFFBa4QGFrwWDrCo +m12CzMLwaPMrNFBffCTqZnL1AajT+EYqPTi+cQ5mkRpZ2cuzhdug2eki1KkD12ZN +3d8Ehl8bfbLEqRE/HnggleRRt7ia1xkzruqQp14JA2UsrioGMF5nvWgWrbyHfpui +KrCsDwDelrArW/GCki53QBQMuH8Q1YmoNrRZwlG257eA1LiJvmxRyIjKYu0RP+Q8 +EOldycy51VsPVPApUbv9r4IJldrIJiwlmRxxM36uKtFhfojnsWzJORDYI8C37uKi +UEPiD4GSEH6C0lGO94IoZPjl9z/rZ0qZx1VRHl3nxZc0AQvvj9bWMbyRwsgb6wod +P8JSy6uEib9UxuenNHzTd48GcNhJbhOqd4IV0XKhi8W1Kil3mMdc3QAwKaLTx12/ +1GrbMui061uyeM6Rf6Xao0PApDnUNmxcFSTsoarG0yH7Q0WZMgKTDCCGhhtZKlE6 +x7pRsnxiFaIpoh32EVIRI+ZXh2rXBcwa2ew0aEccRXtPFvcmdjevkrHuCggc+M+Y +seFqTHVGWf8eS6o08w095DboD0vFpZXZMRfycTbA7BiE4NYE/uc7v5cH3Ax9l2ef +zG7o9idDt+/RX7OcetxDFw4eQbq7PfjvrfXS1DcRUEyJ04emh7oxlkAUUNsFtabN +T0ggvHxcQWkYRE5oPlkbgpwKpK4LDcApXKFwCDKPur2W5Q7KHRfDLtSvZvYarJum +8j2pGpEis/bdTih29ofNsX6a0Yo5Tlj+9+1c/6/Xi7XvRk/Vbgkoa3iVQ3ckdCuZ +vO7cRYZBBs6W/Ti3hWFzPEX9FfcnSUp9bEnH4ASnmUcp8PDBJYeaI6HqpO3XbkbF +l70eDNakd2cDNjQzkFpBT7HO+HtqU3xNt9K0z2gMB7iTDVFyIzh26joCR2O8tiqS +wUJFkoLPb74GSB7WzE+gb4jXX6n9609PUoR3f896mM34uX3CsY8lA+/0ZGpHnFDA +ToKdmz6WKIAw0E20nyzLuLwPZgj7HLcR7zza4raipe9QxIdyJr5O+jzGt+OjSM9b +K1agibRE5DChqQ+P+ikOc6nG7UNyn+lKSjGEbwuzi8F0iugMgcTc/vYO8OWDNGpd +D1euA5OuVPdfatFa16Fyr4MJJIfE83C4/kSj05fdoyb6pJkOjHhUppVMe+ES5kwl +YI8RES2XVJzUSxnWsIM613YlMgIZ9xgcuIADnO7gaKJ4RQG+9wJ853Uo4+n89K7F +Y6KzihuYAUkbAw1pPo1TODom7A/gB9stqRUSQlZWmIgtnJ8wPjt/we0gzPM8LQzb +ye4KOLjH5iquFc4MU4TtN3gvp9P5R9UFrGeMImS5eMUmBQHckDNdIAtMj7M1wUpR +JVrzDXWDjC21sLn95NtNMPb+FRlt/biTV3IE3ZmX0kbuCRoH7b7hhR41Zpoajwl0 +FqYigB5gnVodGUWuBgDUqA== +-----END ENCRYPTED PRIVATE KEY----- diff --git a/3rdparty/asio/src/examples/cpp11/ssl/client.cpp b/3rdparty/asio/src/examples/cpp11/ssl/client.cpp new file mode 100644 index 00000000000..6799d2a98e1 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/ssl/client.cpp @@ -0,0 +1,165 @@ +// +// client.cpp +// ~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <cstdlib> +#include <cstring> +#include <functional> +#include <iostream> +#include "asio.hpp" +#include "asio/ssl.hpp" + +using asio::ip::tcp; +using std::placeholders::_1; +using std::placeholders::_2; + +enum { max_length = 1024 }; + +class client +{ +public: + client(asio::io_context& io_context, + asio::ssl::context& context, + const tcp::resolver::results_type& endpoints) + : socket_(io_context, context) + { + socket_.set_verify_mode(asio::ssl::verify_peer); + socket_.set_verify_callback( + std::bind(&client::verify_certificate, this, _1, _2)); + + connect(endpoints); + } + +private: + bool verify_certificate(bool preverified, + asio::ssl::verify_context& ctx) + { + // The verify callback can be used to check whether the certificate that is + // being presented is valid for the peer. For example, RFC 2818 describes + // the steps involved in doing this for HTTPS. Consult the OpenSSL + // documentation for more details. Note that the callback is called once + // for each certificate in the certificate chain, starting from the root + // certificate authority. + + // In this example we will simply print the certificate's subject name. + char subject_name[256]; + X509* cert = X509_STORE_CTX_get_current_cert(ctx.native_handle()); + X509_NAME_oneline(X509_get_subject_name(cert), subject_name, 256); + std::cout << "Verifying " << subject_name << "\n"; + + return preverified; + } + + void connect(const tcp::resolver::results_type& endpoints) + { + asio::async_connect(socket_.lowest_layer(), endpoints, + [this](const std::error_code& error, + const tcp::endpoint& /*endpoint*/) + { + if (!error) + { + handshake(); + } + else + { + std::cout << "Connect failed: " << error.message() << "\n"; + } + }); + } + + void handshake() + { + socket_.async_handshake(asio::ssl::stream_base::client, + [this](const std::error_code& error) + { + if (!error) + { + send_request(); + } + else + { + std::cout << "Handshake failed: " << error.message() << "\n"; + } + }); + } + + void send_request() + { + std::cout << "Enter message: "; + std::cin.getline(request_, max_length); + size_t request_length = std::strlen(request_); + + asio::async_write(socket_, + asio::buffer(request_, request_length), + [this](const std::error_code& error, std::size_t length) + { + if (!error) + { + receive_response(length); + } + else + { + std::cout << "Write failed: " << error.message() << "\n"; + } + }); + } + + void receive_response(std::size_t length) + { + asio::async_read(socket_, + asio::buffer(reply_, length), + [this](const std::error_code& error, std::size_t length) + { + if (!error) + { + std::cout << "Reply: "; + std::cout.write(reply_, length); + std::cout << "\n"; + } + else + { + std::cout << "Read failed: " << error.message() << "\n"; + } + }); + } + + asio::ssl::stream<tcp::socket> socket_; + char request_[max_length]; + char reply_[max_length]; +}; + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 3) + { + std::cerr << "Usage: client <host> <port>\n"; + return 1; + } + + asio::io_context io_context; + + tcp::resolver resolver(io_context); + auto endpoints = resolver.resolve(argv[1], argv[2]); + + asio::ssl::context ctx(asio::ssl::context::sslv23); + ctx.load_verify_file("ca.pem"); + + client c(io_context, ctx, endpoints); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp11/ssl/dh4096.pem b/3rdparty/asio/src/examples/cpp11/ssl/dh4096.pem new file mode 100644 index 00000000000..dc2559c5f82 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/ssl/dh4096.pem @@ -0,0 +1,25 @@ +-----BEGIN X9.42 DH PARAMETERS----- +MIIELQKCAgEA8eEBgatlTk0QKIwUqHsteHJXzEr0xAW7RLeNid8DdGjTnFw68eV+ +s1YbipEqQVTFG+VZPaof9v0CH2KOdbgWD0KRPC49HB8O/wARFKpy5eJltVe1r07w ++V1Vjciqkh/vGq/yFQsbqwyWJy6AelsbHdSC9Bg9pmu4+pbVGW15zK7PkfjfoO9V +JYbhdqFIPg+9NRRWsl/U9UoyeeIGImI9I4k3fqtv311C6VVErFZylCj7nn45L7IY +GfPcCO5E8FD6EqBv5WnhMNYHMJu9brRvOoAyAyWprqR+aVzHd+DFamDQdsuQjKTk +3+r07znWJfjp6FVTzR5SvjrKg1knK5TibIksoKOlsFZ06bGkFWHjqXNAKhnSpCiU +GJd0qe7pTD+TGQJGWskJpoph+tkICUa+6MyzP9+U6T9hISIY/BpVuWn/iwdLqsvV +s5bg2RjRraww/4Rjm0NyEOTk2MxaLB9gcyu6zcrhX5XRiMgt+jhKwEMwJCEJYkxn +C0yv08A5v6RceFm1jY+8FT0IzRqsWIGV7beNdqtE0B4LBTuN1yQ6x8CKEb6mbIHG +d0XLGppELhD8QUwAr5HiVGTAsS9JlMGgXVkyDtxrVSeS1zHWt77skRQ9UlfJfYMm +5wxHj5QCdQ7ma3oMMZBZutNlkevMzYHIxwqhZstf4ud0j0VMftwZ3GMCggIBAJL7 +cU6/YSxzYDGUcPc6WGT+FAghR0LdhT3Q3Xz1rQRBwSSMPm9NZhyJC3fb+hBl/44X +AHOu1/3dYIWlXPMuHZZdtlt+hkD/sIob16By20Z0p81Kvh3HQglVDJGlFzTmQbTd +CM/EP8eJFiNeMcJB0RgeKyzikRsV4r/acZZM56swTlsRvSDFMh3v9YyYTZbCTwxm +PIVOsxI8uBoWRCzY3yWzjmlZ2u5TR+Z0IVonmNqk6XAKRgxV12YfQVXzzpPZQA9S +GHoD/NQoMdBAi3p4pLEYJ5qMRLYPQbBfSNu5eP9e5uZOiBp/28bVnzEelDGuFupr +lvywkZEVL1KaYtZ/dGkPFXt+A7mNsw5xeDTRjgL4uUJvCNIkjgVEfIrLdUf5IVsU +V8BgunAvgfH+Hy6Tx89v/QGsUWJPhjkSZnXwJ7Ipcsm+Zg0zAZwKDZEQtDLXVPRL +OfCfXMXvlw2u6OHlhSbqO69zZG3dJTlcnjy06n4JYcUim7Mj3Kduige6VWofeEk9 +M/kHrPqNdFE5tHLh2nHcw9yExKHN+l/OUGAvNDfOVS+S+fNSKT0RfC9dMpHLN+Ok +fGuskGzLQAVYF+DYEcnJ++0LEFtd0J381ndSc0iJuH60rKDTqxoRqv7lcdwLFlEV +sQSRoas8s+y+b3FfSu7j0p44qLG9oxZ/WFcWnuUyAiEAjvAD9p3bw8AH0s7dUrX/ +RT1Ge+J/n0tlsgw+LY3zafE= +-----END X9.42 DH PARAMETERS----- diff --git a/3rdparty/asio/src/examples/cpp11/ssl/server.cpp b/3rdparty/asio/src/examples/cpp11/ssl/server.cpp new file mode 100644 index 00000000000..15e0d9eaf03 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/ssl/server.cpp @@ -0,0 +1,145 @@ +// +// server.cpp +// ~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <cstdlib> +#include <functional> +#include <iostream> +#include "asio.hpp" +#include "asio/ssl.hpp" + +using asio::ip::tcp; + +class session : public std::enable_shared_from_this<session> +{ +public: + session(asio::ssl::stream<tcp::socket> socket) + : socket_(std::move(socket)) + { + } + + void start() + { + do_handshake(); + } + +private: + void do_handshake() + { + auto self(shared_from_this()); + socket_.async_handshake(asio::ssl::stream_base::server, + [this, self](const std::error_code& error) + { + if (!error) + { + do_read(); + } + }); + } + + void do_read() + { + auto self(shared_from_this()); + socket_.async_read_some(asio::buffer(data_), + [this, self](const std::error_code& ec, std::size_t length) + { + if (!ec) + { + do_write(length); + } + }); + } + + void do_write(std::size_t length) + { + auto self(shared_from_this()); + asio::async_write(socket_, asio::buffer(data_, length), + [this, self](const std::error_code& ec, + std::size_t /*length*/) + { + if (!ec) + { + do_read(); + } + }); + } + + asio::ssl::stream<tcp::socket> socket_; + char data_[1024]; +}; + +class server +{ +public: + server(asio::io_context& io_context, unsigned short port) + : acceptor_(io_context, tcp::endpoint(tcp::v4(), port)), + context_(asio::ssl::context::sslv23) + { + context_.set_options( + asio::ssl::context::default_workarounds + | asio::ssl::context::no_sslv2 + | asio::ssl::context::single_dh_use); + context_.set_password_callback(std::bind(&server::get_password, this)); + context_.use_certificate_chain_file("server.pem"); + context_.use_private_key_file("server.pem", asio::ssl::context::pem); + context_.use_tmp_dh_file("dh4096.pem"); + + do_accept(); + } + +private: + std::string get_password() const + { + return "test"; + } + + void do_accept() + { + acceptor_.async_accept( + [this](const std::error_code& error, tcp::socket socket) + { + if (!error) + { + std::make_shared<session>( + asio::ssl::stream<tcp::socket>( + std::move(socket), context_))->start(); + } + + do_accept(); + }); + } + + tcp::acceptor acceptor_; + asio::ssl::context context_; +}; + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 2) + { + std::cerr << "Usage: server <port>\n"; + return 1; + } + + asio::io_context io_context; + + using namespace std; // For atoi. + server s(io_context, atoi(argv[1])); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp11/ssl/server.pem b/3rdparty/asio/src/examples/cpp11/ssl/server.pem new file mode 100644 index 00000000000..a7bcba738a0 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/ssl/server.pem @@ -0,0 +1,99 @@ +-----BEGIN CERTIFICATE----- +MIIDDjCCAfYCFGGcJXlIeQHiq/qOakbISU5cihPvMA0GCSqGSIb3DQEBCwUAMDsx +CzAJBgNVBAYTAkFVMQwwCgYDVQQIDANOU1cxDzANBgNVBAcMBlN5ZG5leTENMAsG +A1UECgwEYXNpbzAeFw0yMTExMTEyMTExNDRaFw0yNjExMTAyMTExNDRaMEwxCzAJ +BgNVBAYTAkFVMQwwCgYDVQQIDANOU1cxDzANBgNVBAcMBlN5ZG5leTENMAsGA1UE +CgwEYXNpbzEPMA0GA1UECwwGc2VydmVyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A +MIIBCgKCAQEAu67TzZCFNTZ5c1gKwXfdTH3bP0OB5n6dqXGK6jkPb699dyM4oPtY +2f+OyxJspk8D5pX6HuZ+hLGAsHxfCN+A3RegVZJCR/gXrrMPl/6PfDxtkeFXWy+6 +NAPxqppMj8gbX/czTdNFwgW4J8/RLyH53utjAGQtCRr97EbBOsTSeOmyAxbw4mRt +EvHjacKFcSZzJDlyxCia37791MulZ4lwOZZlke5NzoOqkBIAusQgg7fMWDvH27PD +T+taIyBsYTVJWHf5kMklAlWYXZvNjZp/QGt13lDORg2aSc/P2pE4iLyhbZcpuW+W +nHB7IY1wjDL55/ORCjz3VlNIAMXHP5YQxwIDAQABMA0GCSqGSIb3DQEBCwUAA4IB +AQC3iiwQTgDP4ixulisYIGlJb8iuhxH9G41hm8dF/1qlIfXWxsbjb+g7M5U/3JCb +fwCGoz7uBdj/CKkIb5wx83GVC1yVLbNSvCIS827qxic4GACEYGGAy4Ub5tUCQrLr +JUQTP1WVJcgiKvk7OAcXdA+k/CcNXH153gUPDZz+/BedXe2VbM6LDsqPeSxXfbZN +AWXARAuly7cQk/xkYkPldRRhx4htNCbnkG1qyEqNcYQN1SY9Qhbrm2HkAUntzQ7G +umo4JdbIX6MJ5fYNs+yN/lJB7PiJP8Mz1AtOz4x9JxcLyuB6sapT8Tj53n9g/+m1 +Tqd8lHpWe6oM0sgdWfzdBNir +-----END CERTIFICATE----- +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,9E0E6B9970E055F1 + +oFvN3t50B2TSeNsRo1vwhVYlMmt0w3MD3Ar75fti4fRhBrWoH4rBPrSouWK4OMDK +CakfVhzJIEvaMav843grS4V+ooAsfnAtiQiQj+5xjZ8PlCuWir5gyjgqeN4zN6ZT +2s/oEy5Kx7Ru5AWMkv+NPW5l3iS3c+Hupfb/auITwECSCCsCBxgNtJ8z0iXjv9Dr +hqvqcI+4F5DSiol3QhitbpQ/k2PKu92AZhPcr9e5HrqeUD7aqfX2q3i+tnJvxC93 +0mvy133bX2ZAGAKMheW/GuzcETfwU80wvmrwHXI9rnuAUaJhrDiIZQ79gubZ0Pcm +w4Y6Z5xxeErb7zKBi+pHKst8MJ7rfSz/N878su6cpESRC/w1paVX7m8/q61kzBkj ++h2qe9DupXBejQkriN+Z858nFtBKbWlFsmAg1FLZonworTUfV2c7S9yzMV/29VOE +T0Bt8BU1Hp+bCjreF4JGbnUJnRQoASpisfUkrD6Ar4GI56Edkkx6hkF0cXdcvfCN +qyhxzcvf/aV1M2kcpBRX9mIfjoFMFNz7uRIxyqPLaDkigwJemoaBo3n9/W5F7N7B +AGNEZ3QhUlc8EyWpGRZRzMevu5wdz1b2+MqItOhPXUo2XcLEj2iFkVDdbj/d9jQH +9ZIe4hQTSf784tAzt2Jp2RHmm22390GB1jdzG/CzbGlAKmaTTEe4FJcd/eLOEZuD +4+iFsEb/bWcCyXkBKkdEoDDMJW8xi5d/1ezJM03nqhvkekDqyhJUJPCbmY1SCX1X +4AO40jJmWQxwj26Pnnncacz4tuecZNqovz+POpKQSIctrQSV4wgf35137KBt7/O7 +EU0N7Qj4xTigyGkEHCZt7BgD8fFrxiP1OkUmFRHEE7Dxiagz6omJV8ien+p9wIgS +QcqkJlgKMwVepjuCuEyvg5oIkAPvp24yhePSJkEvvoDLvM2Kub/CM+UkN8dSgsZk ++ZBE9Oi62AWWow8/ib8Um5DNIEZsq+5CQLeBG7f5kTIBAoA9UceaEgbxzOVUCBcX +L7QsJ3pZ/ei1qx/9tChO/OXa9tleXcjGg7/q/6i6pUyZuqZlt+hk+3HtFmTXIjsM +chbUSMEJ2isv9MDamTtunt9N92A6OxUkAs68kCO/bzotldXMKZVjOohNnML5q/3U +vpsuN8NNwaNHCAM7pjols4V7ebX1lDZFR1hbj+szKMhVKzFfig1lRHafgRrR6H6P +mUK16lKzUbmvwv2IU/3wck+4UNeB/+lRmfAfBasQytnbt+5fwwNkVSrDY2Kxe0nz +2k3eIYST+ygxGuNrW9rnFbBpTJb0OE5cpgun8xxDE91AmL550AcZff+9ulDBhZg1 +eMoKUALlEdDNPffVTH8Iupn0jMnJsjXynztcEVhx4h2aA5X6/2i035uEybCn33qP +J7g30oe2C69BSC0YmkT3MjF6Wrhy+M8dU0dDggRhY6JSS8wESvwGenaPi7SZlbxb +Elmc44bHros1YfGl/xDdhju134/aMBG1GlZlReI+Rwnp9DCp04xiiJb9YKyUNaGY +7BTGWyie/WYYKbX1ZlxqWA9jxow8PM1XYHuanau1/aYT16L7E83HG3qkyuFIlLJh +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIDVDCCAjygAwIBAgIUX3cVQ47QyJp7SOy0RPzP743W9MwwDQYJKoZIhvcNAQEL +BQAwOzELMAkGA1UEBhMCQVUxDDAKBgNVBAgMA05TVzEPMA0GA1UEBwwGU3lkbmV5 +MQ0wCwYDVQQKDARhc2lvMB4XDTIxMTExMTIxMTA1MloXDTI2MTExMDIxMTA1Mlow +OzELMAkGA1UEBhMCQVUxDDAKBgNVBAgMA05TVzEPMA0GA1UEBwwGU3lkbmV5MQ0w +CwYDVQQKDARhc2lvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyURD +LjKxTCkapmWhY0bP1NaaOPzIJTTB0dzREOlmRmBmiHpW7DaRx7qBm6jYDKQ7OCbz +30/j8K4TjHOLIwxzXhXMYTJOcN2giPHNUBvm9oEuDAhYgltArJQnBBEH+3C1hCIv +1+uhTWo0HpGXTeJnvboTZ1YgmbOgr6lMhNiu9QmPX885DxWf6sDq8mRgCDX2x8sk +Ls0HuLSo88Osjx532yEhnrZgexsByhoRD3yrKHV5mWpaunk5BMsP/XMuQHayFmbO +siqnHJoL1znGVH003PcBGmEDmoIUqhLiBi2gWGu1pmckP9loqQUTEn0aLOVclHf4 +slWq344zh4tJCpQMfQIDAQABo1AwTjAdBgNVHQ4EFgQUfiX1CMQrGDi9mIBAg9cg +m0RwLJUwHwYDVR0jBBgwFoAUfiX1CMQrGDi9mIBAg9cgm0RwLJUwDAYDVR0TBAUw +AwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAnDnVNSb8z/pNFaZ6YAZ+ukfNT3jjbGm1 +10BOLqJj8s5A8/JkwjaWhky/DuGXDywgEvzXC18aNAxASeqO8h9pAZtszu6NWB4s +h3r+dEQakMacxrZ+jBL/cYLrUv9r3KMPKxaDnplkamqFA/9eNmoV7vDyGtGPZuD6 +oTROtQqqDSrxthCkqnibAfusi7RmlCdvJa0kVK7krKJZAhi8W9f32+lBPv9oq3Ns +dAxnOj/D3UnhNoIt0EdjqUdLo2U39dt5s5Syj2rFUAgfbc02Rwx65kq8AjTRlW/M +KDpGsifwIB8b7wActMUO8c3GptptNVWmFm5+Mmk54P//P3tIAx9KXw== +-----END CERTIFICATE----- +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIPcVUeQ7ZElgCAggA +MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECGKlFVN6/gIlBIIEyJPeknsA5dvV +WK27AZzs4wM6WrsD6ba+kPJyZTpon5pn4eoTiw4UCvo7C+21G9jCqbIbDrgTWHwH +zu6YrBFTZgRUpdLkLsyUsp4UJrZ8xJ7N/jWlG763CyluFE5oBFLz2Vt/DSDSaWdA +sKdxua/1kvw+KYoDqlObMFIspM5TrndcMnWkOgyvQAvnH0NZXFFBa4QGFrwWDrCo +m12CzMLwaPMrNFBffCTqZnL1AajT+EYqPTi+cQ5mkRpZ2cuzhdug2eki1KkD12ZN +3d8Ehl8bfbLEqRE/HnggleRRt7ia1xkzruqQp14JA2UsrioGMF5nvWgWrbyHfpui +KrCsDwDelrArW/GCki53QBQMuH8Q1YmoNrRZwlG257eA1LiJvmxRyIjKYu0RP+Q8 +EOldycy51VsPVPApUbv9r4IJldrIJiwlmRxxM36uKtFhfojnsWzJORDYI8C37uKi +UEPiD4GSEH6C0lGO94IoZPjl9z/rZ0qZx1VRHl3nxZc0AQvvj9bWMbyRwsgb6wod +P8JSy6uEib9UxuenNHzTd48GcNhJbhOqd4IV0XKhi8W1Kil3mMdc3QAwKaLTx12/ +1GrbMui061uyeM6Rf6Xao0PApDnUNmxcFSTsoarG0yH7Q0WZMgKTDCCGhhtZKlE6 +x7pRsnxiFaIpoh32EVIRI+ZXh2rXBcwa2ew0aEccRXtPFvcmdjevkrHuCggc+M+Y +seFqTHVGWf8eS6o08w095DboD0vFpZXZMRfycTbA7BiE4NYE/uc7v5cH3Ax9l2ef +zG7o9idDt+/RX7OcetxDFw4eQbq7PfjvrfXS1DcRUEyJ04emh7oxlkAUUNsFtabN +T0ggvHxcQWkYRE5oPlkbgpwKpK4LDcApXKFwCDKPur2W5Q7KHRfDLtSvZvYarJum +8j2pGpEis/bdTih29ofNsX6a0Yo5Tlj+9+1c/6/Xi7XvRk/Vbgkoa3iVQ3ckdCuZ +vO7cRYZBBs6W/Ti3hWFzPEX9FfcnSUp9bEnH4ASnmUcp8PDBJYeaI6HqpO3XbkbF +l70eDNakd2cDNjQzkFpBT7HO+HtqU3xNt9K0z2gMB7iTDVFyIzh26joCR2O8tiqS +wUJFkoLPb74GSB7WzE+gb4jXX6n9609PUoR3f896mM34uX3CsY8lA+/0ZGpHnFDA +ToKdmz6WKIAw0E20nyzLuLwPZgj7HLcR7zza4raipe9QxIdyJr5O+jzGt+OjSM9b +K1agibRE5DChqQ+P+ikOc6nG7UNyn+lKSjGEbwuzi8F0iugMgcTc/vYO8OWDNGpd +D1euA5OuVPdfatFa16Fyr4MJJIfE83C4/kSj05fdoyb6pJkOjHhUppVMe+ES5kwl +YI8RES2XVJzUSxnWsIM613YlMgIZ9xgcuIADnO7gaKJ4RQG+9wJ853Uo4+n89K7F +Y6KzihuYAUkbAw1pPo1TODom7A/gB9stqRUSQlZWmIgtnJ8wPjt/we0gzPM8LQzb +ye4KOLjH5iquFc4MU4TtN3gvp9P5R9UFrGeMImS5eMUmBQHckDNdIAtMj7M1wUpR +JVrzDXWDjC21sLn95NtNMPb+FRlt/biTV3IE3ZmX0kbuCRoH7b7hhR41Zpoajwl0 +FqYigB5gnVodGUWuBgDUqA== +-----END ENCRYPTED PRIVATE KEY----- diff --git a/3rdparty/asio/src/examples/cpp03/timeouts/async_tcp_client.cpp b/3rdparty/asio/src/examples/cpp11/timeouts/async_tcp_client.cpp index 98b90e9a1b3..b8f2cbe77d2 100644 --- a/3rdparty/asio/src/examples/cpp03/timeouts/async_tcp_client.cpp +++ b/3rdparty/asio/src/examples/cpp11/timeouts/async_tcp_client.cpp @@ -2,23 +2,26 @@ // async_tcp_client.cpp // ~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "asio/deadline_timer.hpp" +#include "asio/buffer.hpp" #include "asio/io_context.hpp" #include "asio/ip/tcp.hpp" #include "asio/read_until.hpp" -#include "asio/streambuf.hpp" +#include "asio/steady_timer.hpp" #include "asio/write.hpp" -#include <boost/bind.hpp> +#include <functional> #include <iostream> +#include <string> -using asio::deadline_timer; +using asio::steady_timer; using asio::ip::tcp; +using std::placeholders::_1; +using std::placeholders::_2; // // This class manages socket timeouts by applying the concept of a deadline. @@ -78,14 +81,13 @@ using asio::ip::tcp; // // The heartbeat actor sends a heartbeat (a message that consists of a single // newline character) every 10 seconds. In this example, no deadline is applied -// message sending. +// to message sending. // class client { public: client(asio::io_context& io_context) - : stopped_(false), - socket_(io_context), + : socket_(io_context), deadline_(io_context), heartbeat_timer_(io_context) { @@ -102,7 +104,7 @@ public: // Start the deadline actor. You will note that we're not setting any // particular deadline here. Instead, the connect and input actors will // update the deadline prior to each asynchronous operation. - deadline_.async_wait(boost::bind(&client::check_deadline, this)); + deadline_.async_wait(std::bind(&client::check_deadline, this)); } // This function terminates all the actors to shut down the connection. It @@ -111,8 +113,8 @@ public: void stop() { stopped_ = true; - asio::error_code ignored_ec; - socket_.close(ignored_ec); + std::error_code ignored_error; + socket_.close(ignored_error); deadline_.cancel(); heartbeat_timer_.cancel(); } @@ -125,11 +127,11 @@ private: std::cout << "Trying " << endpoint_iter->endpoint() << "...\n"; // Set a deadline for the connect operation. - deadline_.expires_from_now(boost::posix_time::seconds(60)); + deadline_.expires_after(std::chrono::seconds(60)); // Start the asynchronous connect operation. socket_.async_connect(endpoint_iter->endpoint(), - boost::bind(&client::handle_connect, + std::bind(&client::handle_connect, this, _1, endpoint_iter)); } else @@ -139,7 +141,7 @@ private: } } - void handle_connect(const asio::error_code& ec, + void handle_connect(const std::error_code& error, tcp::resolver::results_type::iterator endpoint_iter) { if (stopped_) @@ -157,9 +159,9 @@ private: } // Check if the connect operation failed before the deadline expired. - else if (ec) + else if (error) { - std::cout << "Connect error: " << ec.message() << "\n"; + std::cout << "Connect error: " << error.message() << "\n"; // We need to close the socket used in the previous connection attempt // before starting a new one. @@ -185,24 +187,24 @@ private: void start_read() { // Set a deadline for the read operation. - deadline_.expires_from_now(boost::posix_time::seconds(30)); + deadline_.expires_after(std::chrono::seconds(30)); // Start an asynchronous operation to read a newline-delimited message. - asio::async_read_until(socket_, input_buffer_, '\n', - boost::bind(&client::handle_read, this, _1)); + asio::async_read_until(socket_, + asio::dynamic_buffer(input_buffer_), '\n', + std::bind(&client::handle_read, this, _1, _2)); } - void handle_read(const asio::error_code& ec) + void handle_read(const std::error_code& error, std::size_t n) { if (stopped_) return; - if (!ec) + if (!error) { // Extract the newline-delimited message from the buffer. - std::string line; - std::istream is(&input_buffer_); - std::getline(is, line); + std::string line(input_buffer_.substr(0, n - 1)); + input_buffer_.erase(0, n); // Empty messages are heartbeats and so ignored. if (!line.empty()) @@ -214,7 +216,7 @@ private: } else { - std::cout << "Error on receive: " << ec.message() << "\n"; + std::cout << "Error on receive: " << error.message() << "\n"; stop(); } @@ -227,23 +229,23 @@ private: // Start an asynchronous operation to send a heartbeat message. asio::async_write(socket_, asio::buffer("\n", 1), - boost::bind(&client::handle_write, this, _1)); + std::bind(&client::handle_write, this, _1)); } - void handle_write(const asio::error_code& ec) + void handle_write(const std::error_code& error) { if (stopped_) return; - if (!ec) + if (!error) { // Wait 10 seconds before sending the next heartbeat. - heartbeat_timer_.expires_from_now(boost::posix_time::seconds(10)); - heartbeat_timer_.async_wait(boost::bind(&client::start_write, this)); + heartbeat_timer_.expires_after(std::chrono::seconds(10)); + heartbeat_timer_.async_wait(std::bind(&client::start_write, this)); } else { - std::cout << "Error on heartbeat: " << ec.message() << "\n"; + std::cout << "Error on heartbeat: " << error.message() << "\n"; stop(); } @@ -257,28 +259,29 @@ private: // Check whether the deadline has passed. We compare the deadline against // the current time since a new asynchronous operation may have moved the // deadline before this actor had a chance to run. - if (deadline_.expires_at() <= deadline_timer::traits_type::now()) + if (deadline_.expiry() <= steady_timer::clock_type::now()) { // The deadline has passed. The socket is closed so that any outstanding // asynchronous operations are cancelled. socket_.close(); - // There is no longer an active deadline. The expiry is set to positive - // infinity so that the actor takes no action until a new deadline is set. - deadline_.expires_at(boost::posix_time::pos_infin); + // There is no longer an active deadline. The expiry is set to the + // maximum time point so that the actor takes no action until a new + // deadline is set. + deadline_.expires_at(steady_timer::time_point::max()); } // Put the actor back to sleep. - deadline_.async_wait(boost::bind(&client::check_deadline, this)); + deadline_.async_wait(std::bind(&client::check_deadline, this)); } private: - bool stopped_; + bool stopped_ = false; tcp::resolver::results_type endpoints_; tcp::socket socket_; - asio::streambuf input_buffer_; - deadline_timer deadline_; - deadline_timer heartbeat_timer_; + std::string input_buffer_; + steady_timer deadline_; + steady_timer heartbeat_timer_; }; int main(int argc, char* argv[]) diff --git a/3rdparty/asio/src/examples/cpp11/timeouts/blocking_tcp_client.cpp b/3rdparty/asio/src/examples/cpp11/timeouts/blocking_tcp_client.cpp new file mode 100644 index 00000000000..e29edc2895f --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/timeouts/blocking_tcp_client.cpp @@ -0,0 +1,192 @@ +// +// blocking_tcp_client.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "asio/buffer.hpp" +#include "asio/connect.hpp" +#include "asio/io_context.hpp" +#include "asio/ip/tcp.hpp" +#include "asio/read_until.hpp" +#include "asio/system_error.hpp" +#include "asio/write.hpp" +#include <cstdlib> +#include <iostream> +#include <string> + +using asio::ip::tcp; + +//---------------------------------------------------------------------- + +// +// This class manages socket timeouts by running the io_context using the timed +// io_context::run_for() member function. Each asynchronous operation is given +// a timeout within which it must complete. The socket operations themselves +// use lambdas as completion handlers. For a given socket operation, the client +// object runs the io_context to block thread execution until the operation +// completes or the timeout is reached. If the io_context::run_for() function +// times out, the socket is closed and the outstanding asynchronous operation +// is cancelled. +// +class client +{ +public: + void connect(const std::string& host, const std::string& service, + std::chrono::steady_clock::duration timeout) + { + // Resolve the host name and service to a list of endpoints. + auto endpoints = tcp::resolver(io_context_).resolve(host, service); + + // Start the asynchronous operation itself. The lambda that is used as a + // callback will update the error variable when the operation completes. + // The blocking_udp_client.cpp example shows how you can use std::bind + // rather than a lambda. + std::error_code error; + asio::async_connect(socket_, endpoints, + [&](const std::error_code& result_error, + const tcp::endpoint& /*result_endpoint*/) + { + error = result_error; + }); + + // Run the operation until it completes, or until the timeout. + run(timeout); + + // Determine whether a connection was successfully established. + if (error) + throw std::system_error(error); + } + + std::string read_line(std::chrono::steady_clock::duration timeout) + { + // Start the asynchronous operation. The lambda that is used as a callback + // will update the error and n variables when the operation completes. The + // blocking_udp_client.cpp example shows how you can use std::bind rather + // than a lambda. + std::error_code error; + std::size_t n = 0; + asio::async_read_until(socket_, + asio::dynamic_buffer(input_buffer_), '\n', + [&](const std::error_code& result_error, + std::size_t result_n) + { + error = result_error; + n = result_n; + }); + + // Run the operation until it completes, or until the timeout. + run(timeout); + + // Determine whether the read completed successfully. + if (error) + throw std::system_error(error); + + std::string line(input_buffer_.substr(0, n - 1)); + input_buffer_.erase(0, n); + return line; + } + + void write_line(const std::string& line, + std::chrono::steady_clock::duration timeout) + { + std::string data = line + "\n"; + + // Start the asynchronous operation itself. The lambda that is used as a + // callback will update the error variable when the operation completes. + // The blocking_udp_client.cpp example shows how you can use std::bind + // rather than a lambda. + std::error_code error; + asio::async_write(socket_, asio::buffer(data), + [&](const std::error_code& result_error, + std::size_t /*result_n*/) + { + error = result_error; + }); + + // Run the operation until it completes, or until the timeout. + run(timeout); + + // Determine whether the read completed successfully. + if (error) + throw std::system_error(error); + } + +private: + void run(std::chrono::steady_clock::duration timeout) + { + // Restart the io_context, as it may have been left in the "stopped" state + // by a previous operation. + io_context_.restart(); + + // Block until the asynchronous operation has completed, or timed out. If + // the pending asynchronous operation is a composed operation, the deadline + // applies to the entire operation, rather than individual operations on + // the socket. + io_context_.run_for(timeout); + + // If the asynchronous operation completed successfully then the io_context + // would have been stopped due to running out of work. If it was not + // stopped, then the io_context::run_for call must have timed out. + if (!io_context_.stopped()) + { + // Close the socket to cancel the outstanding asynchronous operation. + socket_.close(); + + // Run the io_context again until the operation completes. + io_context_.run(); + } + } + + asio::io_context io_context_; + tcp::socket socket_{io_context_}; + std::string input_buffer_; +}; + +//---------------------------------------------------------------------- + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 4) + { + std::cerr << "Usage: blocking_tcp_client <host> <port> <message>\n"; + return 1; + } + + client c; + c.connect(argv[1], argv[2], std::chrono::seconds(10)); + + auto time_sent = std::chrono::steady_clock::now(); + + c.write_line(argv[3], std::chrono::seconds(10)); + + for (;;) + { + std::string line = c.read_line(std::chrono::seconds(10)); + + // Keep going until we get back the line that was sent. + if (line == argv[3]) + break; + } + + auto time_received = std::chrono::steady_clock::now(); + + std::cout << "Round trip time: "; + std::cout << std::chrono::duration_cast< + std::chrono::microseconds>( + time_received - time_sent).count(); + std::cout << " microseconds\n"; + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp11/timeouts/blocking_token_tcp_client.cpp b/3rdparty/asio/src/examples/cpp11/timeouts/blocking_token_tcp_client.cpp new file mode 100644 index 00000000000..085570d8b78 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/timeouts/blocking_token_tcp_client.cpp @@ -0,0 +1,171 @@ +// +// blocking_token_tcp_client.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "asio/connect.hpp" +#include "asio/io_context.hpp" +#include "asio/ip/tcp.hpp" +#include "asio/read_until.hpp" +#include "asio/streambuf.hpp" +#include "asio/system_error.hpp" +#include "asio/write.hpp" +#include <cstdlib> +#include <iostream> +#include <memory> +#include <string> + +using asio::ip::tcp; + +// NOTE: This example uses the new form of the asio::async_result trait. +// For an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +// We will use our sockets only with an io_context. +using tcp_socket = asio::basic_stream_socket< + tcp, asio::io_context::executor_type>; + +//---------------------------------------------------------------------- + +// A custom completion token that makes asynchronous operations behave as +// though they are blocking calls with a timeout. +struct close_after +{ + close_after(std::chrono::steady_clock::duration t, tcp_socket& s) + : timeout_(t), socket_(s) + { + } + + // The maximum time to wait for an asynchronous operation to complete. + std::chrono::steady_clock::duration timeout_; + + // The socket to be closed if the operation does not complete in time. + tcp_socket& socket_; +}; + +namespace asio { + +// The async_result template is specialised to allow the close_after token to +// be used with asynchronous operations that have a completion signature of +// void(error_code, T). Generalising this for all completion signature forms is +// left as an exercise for the reader. +template <typename T> +class async_result<close_after, void(std::error_code, T)> +{ +public: + // The initiate() function is used to launch the asynchronous operation by + // calling the operation's initiation function object. For the close_after + // completion token, we use this function to run the io_context until the + // operation is complete. + template <typename Init, typename... Args> + static T initiate(Init init, close_after token, Args&&... args) + { + asio::io_context& io_context = asio::query( + token.socket_.get_executor(), asio::execution::context); + + // Call the operation's initiation function object to start the operation. + // A lambda is supplied as the completion handler, to be called when the + // operation completes. + std::error_code error; + T result; + init([&](std::error_code e, T t) + { + error = e; + result = t; + }, std::forward<Args>(args)...); + + // Restart the io_context, as it may have been left in the "stopped" state + // by a previous operation. + io_context.restart(); + + // Block until the asynchronous operation has completed, or timed out. If + // the pending asynchronous operation is a composed operation, the deadline + // applies to the entire operation, rather than individual operations on + // the socket. + io_context.run_for(token.timeout_); + + // If the asynchronous operation completed successfully then the io_context + // would have been stopped due to running out of work. If it was not + // stopped, then the io_context::run_for call must have timed out and the + // operation is still incomplete. + if (!io_context.stopped()) + { + // Close the socket to cancel the outstanding asynchronous operation. + token.socket_.close(); + + // Run the io_context again until the operation completes. + io_context.run(); + } + + // If the operation failed, throw an exception. Otherwise return the result. + return error ? throw std::system_error(error) : result; + } +}; + +} // namespace asio + +//---------------------------------------------------------------------- + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 4) + { + std::cerr << "Usage: blocking_tcp_client <host> <port> <message>\n"; + return 1; + } + + asio::io_context io_context; + + // Resolve the host name and service to a list of endpoints. + auto endpoints = tcp::resolver(io_context).resolve(argv[1], argv[2]); + + tcp_socket socket(io_context); + + // Run an asynchronous connect operation with a timeout. + asio::async_connect(socket, endpoints, + close_after(std::chrono::seconds(10), socket)); + + auto time_sent = std::chrono::steady_clock::now(); + + // Run an asynchronous write operation with a timeout. + std::string msg = argv[3] + std::string("\n"); + asio::async_write(socket, asio::buffer(msg), + close_after(std::chrono::seconds(10), socket)); + + for (std::string input_buffer;;) + { + // Run an asynchronous read operation with a timeout. + std::size_t n = asio::async_read_until(socket, + asio::dynamic_buffer(input_buffer), '\n', + close_after(std::chrono::seconds(10), socket)); + + std::string line(input_buffer.substr(0, n - 1)); + input_buffer.erase(0, n); + + // Keep going until we get back the line that was sent. + if (line == argv[3]) + break; + } + + auto time_received = std::chrono::steady_clock::now(); + + std::cout << "Round trip time: "; + std::cout << std::chrono::duration_cast< + std::chrono::microseconds>( + time_received - time_sent).count(); + std::cout << " microseconds\n"; + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp11/timeouts/blocking_udp_client.cpp b/3rdparty/asio/src/examples/cpp11/timeouts/blocking_udp_client.cpp new file mode 100644 index 00000000000..312f21ab656 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/timeouts/blocking_udp_client.cpp @@ -0,0 +1,155 @@ +// +// blocking_udp_client.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "asio/buffer.hpp" +#include "asio/io_context.hpp" +#include "asio/ip/udp.hpp" +#include <cstdlib> +#include <functional> +#include <iostream> + +using asio::ip::udp; +using std::placeholders::_1; +using std::placeholders::_2; + +//---------------------------------------------------------------------- + +// +// This class manages socket timeouts by running the io_context using the timed +// io_context::run_for() member function. Each asynchronous operation is given +// a timeout within which it must complete. The socket operations themselves +// use std::bind to specify the completion handler: +// +// +---------------+ +// | | +// | receive | +// | | +// +---------------+ +// | +// async_- | +----------------+ +// receive() | | | +// +--->| handle_receive | +// | | +// +----------------+ +// +// For a given socket operation, the client object runs the io_context to block +// thread execution until the operation completes or the timeout is reached. If +// the io_context::run_for() function times out, the socket is closed and the +// outstanding asynchronous operation is cancelled. +// +class client +{ +public: + client(const udp::endpoint& listen_endpoint) + : socket_(io_context_, listen_endpoint) + { + } + + std::size_t receive(const asio::mutable_buffer& buffer, + std::chrono::steady_clock::duration timeout, + std::error_code& error) + { + // Start the asynchronous operation. The handle_receive function used as a + // callback will update the error and length variables. + std::size_t length = 0; + socket_.async_receive(asio::buffer(buffer), + std::bind(&client::handle_receive, _1, _2, &error, &length)); + + // Run the operation until it completes, or until the timeout. + run(timeout); + + return length; + } + +private: + void run(std::chrono::steady_clock::duration timeout) + { + // Restart the io_context, as it may have been left in the "stopped" state + // by a previous operation. + io_context_.restart(); + + // Block until the asynchronous operation has completed, or timed out. If + // the pending asynchronous operation is a composed operation, the deadline + // applies to the entire operation, rather than individual operations on + // the socket. + io_context_.run_for(timeout); + + // If the asynchronous operation completed successfully then the io_context + // would have been stopped due to running out of work. If it was not + // stopped, then the io_context::run_for call must have timed out. + if (!io_context_.stopped()) + { + // Cancel the outstanding asynchronous operation. + socket_.cancel(); + + // Run the io_context again until the operation completes. + io_context_.run(); + } + } + + static void handle_receive( + const std::error_code& error, std::size_t length, + std::error_code* out_error, std::size_t* out_length) + { + *out_error = error; + *out_length = length; + } + +private: + asio::io_context io_context_; + udp::socket socket_; +}; + +//---------------------------------------------------------------------- + +int main(int argc, char* argv[]) +{ + try + { + using namespace std; // For atoi. + + if (argc != 3) + { + std::cerr << "Usage: blocking_udp_client <listen_addr> <listen_port>\n"; + return 1; + } + + udp::endpoint listen_endpoint( + asio::ip::make_address(argv[1]), + std::atoi(argv[2])); + + client c(listen_endpoint); + + for (;;) + { + char data[1024]; + std::error_code error; + std::size_t n = c.receive(asio::buffer(data), + std::chrono::seconds(10), error); + + if (error) + { + std::cout << "Receive error: " << error.message() << "\n"; + } + else + { + std::cout << "Received: "; + std::cout.write(data, n); + std::cout << "\n"; + } + } + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp11/timeouts/server.cpp b/3rdparty/asio/src/examples/cpp11/timeouts/server.cpp new file mode 100644 index 00000000000..6e18fc60c2b --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/timeouts/server.cpp @@ -0,0 +1,433 @@ +// +// server.cpp +// ~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <algorithm> +#include <cstdlib> +#include <deque> +#include <iostream> +#include <memory> +#include <set> +#include <string> +#include "asio/buffer.hpp" +#include "asio/io_context.hpp" +#include "asio/ip/tcp.hpp" +#include "asio/ip/udp.hpp" +#include "asio/read_until.hpp" +#include "asio/steady_timer.hpp" +#include "asio/write.hpp" + +using asio::steady_timer; +using asio::ip::tcp; +using asio::ip::udp; + +//---------------------------------------------------------------------- + +class subscriber +{ +public: + virtual ~subscriber() = default; + virtual void deliver(const std::string& msg) = 0; +}; + +typedef std::shared_ptr<subscriber> subscriber_ptr; + +//---------------------------------------------------------------------- + +class channel +{ +public: + void join(subscriber_ptr subscriber) + { + subscribers_.insert(subscriber); + } + + void leave(subscriber_ptr subscriber) + { + subscribers_.erase(subscriber); + } + + void deliver(const std::string& msg) + { + for (const auto& s : subscribers_) + { + s->deliver(msg); + } + } + +private: + std::set<subscriber_ptr> subscribers_; +}; + +//---------------------------------------------------------------------- + +// +// This class manages socket timeouts by applying the concept of a deadline. +// Some asynchronous operations are given deadlines by which they must complete. +// Deadlines are enforced by two "actors" that persist for the lifetime of the +// session object, one for input and one for output: +// +// +----------------+ +----------------+ +// | | | | +// | check_deadline |<-------+ | check_deadline |<-------+ +// | | | | | | +// +----------------+ | +----------------+ | +// | | | | +// async_wait() | +----------------+ async_wait() | +----------------+ +// on input | | lambda | on output | | lambda | +// deadline +--->| in | deadline +--->| in | +// | check_deadline | | check_deadline | +// +----------------+ +----------------+ +// +// If either deadline actor determines that the corresponding deadline has +// expired, the socket is closed and any outstanding operations are cancelled. +// +// The input actor reads messages from the socket, where messages are delimited +// by the newline character: +// +// +-------------+ +// | | +// | read_line |<----+ +// | | | +// +-------------+ | +// | | +// async_- | +-------------+ +// read_- | | lambda | +// until() +--->| in | +// | read_line | +// +-------------+ +// +// The deadline for receiving a complete message is 30 seconds. If a non-empty +// message is received, it is delivered to all subscribers. If a heartbeat (a +// message that consists of a single newline character) is received, a heartbeat +// is enqueued for the client, provided there are no other messages waiting to +// be sent. +// +// The output actor is responsible for sending messages to the client: +// +// +----------------+ +// | |<---------------------+ +// | await_output | | +// | |<-------+ | +// +----------------+ | | +// | | | | +// | async_- | +----------------+ | +// | wait() | | lambda | | +// | +->| in | | +// | | await_output | | +// | +----------------+ | +// V | +// +--------------+ +--------------+ +// | | async_write() | lambda | +// | write_line |-------------->| in | +// | | | write_line | +// +--------------+ +--------------+ +// +// The output actor first waits for an output message to be enqueued. It does +// this by using a steady_timer as an asynchronous condition variable. The +// steady_timer will be signalled whenever the output queue is non-empty. +// +// Once a message is available, it is sent to the client. The deadline for +// sending a complete message is 30 seconds. After the message is successfully +// sent, the output actor again waits for the output queue to become non-empty. +// +class tcp_session + : public subscriber, + public std::enable_shared_from_this<tcp_session> +{ +public: + tcp_session(tcp::socket socket, channel& ch) + : channel_(ch), + socket_(std::move(socket)) + { + input_deadline_.expires_at(steady_timer::time_point::max()); + output_deadline_.expires_at(steady_timer::time_point::max()); + + // The non_empty_output_queue_ steady_timer is set to the maximum time + // point whenever the output queue is empty. This ensures that the output + // actor stays asleep until a message is put into the queue. + non_empty_output_queue_.expires_at(steady_timer::time_point::max()); + } + + // Called by the server object to initiate the four actors. + void start() + { + channel_.join(shared_from_this()); + + read_line(); + check_deadline(input_deadline_); + + await_output(); + check_deadline(output_deadline_); + } + +private: + void stop() + { + channel_.leave(shared_from_this()); + + std::error_code ignored_error; + socket_.close(ignored_error); + input_deadline_.cancel(); + non_empty_output_queue_.cancel(); + output_deadline_.cancel(); + } + + bool stopped() const + { + return !socket_.is_open(); + } + + void deliver(const std::string& msg) override + { + output_queue_.push_back(msg + "\n"); + + // Signal that the output queue contains messages. Modifying the expiry + // will wake the output actor, if it is waiting on the timer. + non_empty_output_queue_.expires_at(steady_timer::time_point::min()); + } + + void read_line() + { + // Set a deadline for the read operation. + input_deadline_.expires_after(std::chrono::seconds(30)); + + // Start an asynchronous operation to read a newline-delimited message. + auto self(shared_from_this()); + asio::async_read_until(socket_, + asio::dynamic_buffer(input_buffer_), '\n', + [this, self](const std::error_code& error, std::size_t n) + { + // Check if the session was stopped while the operation was pending. + if (stopped()) + return; + + if (!error) + { + // Extract the newline-delimited message from the buffer. + std::string msg(input_buffer_.substr(0, n - 1)); + input_buffer_.erase(0, n); + + if (!msg.empty()) + { + channel_.deliver(msg); + } + else + { + + // We received a heartbeat message from the client. If there's + // nothing else being sent or ready to be sent, send a heartbeat + // right back. + if (output_queue_.empty()) + { + output_queue_.push_back("\n"); + + // Signal that the output queue contains messages. Modifying + // the expiry will wake the output actor, if it is waiting on + // the timer. + non_empty_output_queue_.expires_at( + steady_timer::time_point::min()); + } + } + + read_line(); + } + else + { + stop(); + } + }); + } + + void await_output() + { + auto self(shared_from_this()); + non_empty_output_queue_.async_wait( + [this, self](const std::error_code& /*error*/) + { + // Check if the session was stopped while the operation was pending. + if (stopped()) + return; + + if (output_queue_.empty()) + { + // There are no messages that are ready to be sent. The actor goes + // to sleep by waiting on the non_empty_output_queue_ timer. When a + // new message is added, the timer will be modified and the actor + // will wake. + non_empty_output_queue_.expires_at(steady_timer::time_point::max()); + await_output(); + } + else + { + write_line(); + } + }); + } + + void write_line() + { + // Set a deadline for the write operation. + output_deadline_.expires_after(std::chrono::seconds(30)); + + // Start an asynchronous operation to send a message. + auto self(shared_from_this()); + asio::async_write(socket_, + asio::buffer(output_queue_.front()), + [this, self](const std::error_code& error, std::size_t /*n*/) + { + // Check if the session was stopped while the operation was pending. + if (stopped()) + return; + + if (!error) + { + output_queue_.pop_front(); + + await_output(); + } + else + { + stop(); + } + }); + } + + void check_deadline(steady_timer& deadline) + { + auto self(shared_from_this()); + deadline.async_wait( + [this, self, &deadline](const std::error_code& /*error*/) + { + // Check if the session was stopped while the operation was pending. + if (stopped()) + return; + + // Check whether the deadline has passed. We compare the deadline + // against the current time since a new asynchronous operation may + // have moved the deadline before this actor had a chance to run. + if (deadline.expiry() <= steady_timer::clock_type::now()) + { + // The deadline has passed. Stop the session. The other actors will + // terminate as soon as possible. + stop(); + } + else + { + // Put the actor back to sleep. + check_deadline(deadline); + } + }); + } + + channel& channel_; + tcp::socket socket_; + std::string input_buffer_; + steady_timer input_deadline_{socket_.get_executor()}; + std::deque<std::string> output_queue_; + steady_timer non_empty_output_queue_{socket_.get_executor()}; + steady_timer output_deadline_{socket_.get_executor()}; +}; + +typedef std::shared_ptr<tcp_session> tcp_session_ptr; + +//---------------------------------------------------------------------- + +class udp_broadcaster + : public subscriber +{ +public: + udp_broadcaster(asio::io_context& io_context, + const udp::endpoint& broadcast_endpoint) + : socket_(io_context) + { + socket_.connect(broadcast_endpoint); + socket_.set_option(udp::socket::broadcast(true)); + } + +private: + void deliver(const std::string& msg) + { + std::error_code ignored_error; + socket_.send(asio::buffer(msg), 0, ignored_error); + } + + udp::socket socket_; +}; + +//---------------------------------------------------------------------- + +class server +{ +public: + server(asio::io_context& io_context, + const tcp::endpoint& listen_endpoint, + const udp::endpoint& broadcast_endpoint) + : io_context_(io_context), + acceptor_(io_context, listen_endpoint) + { + channel_.join( + std::make_shared<udp_broadcaster>( + io_context_, broadcast_endpoint)); + + accept(); + } + +private: + void accept() + { + acceptor_.async_accept( + [this](const std::error_code& error, tcp::socket socket) + { + if (!error) + { + std::make_shared<tcp_session>(std::move(socket), channel_)->start(); + } + + accept(); + }); + } + + asio::io_context& io_context_; + tcp::acceptor acceptor_; + channel channel_; +}; + +//---------------------------------------------------------------------- + +int main(int argc, char* argv[]) +{ + try + { + using namespace std; // For atoi. + + if (argc != 4) + { + std::cerr << "Usage: server <listen_port> <bcast_address> <bcast_port>\n"; + return 1; + } + + asio::io_context io_context; + + tcp::endpoint listen_endpoint(tcp::v4(), atoi(argv[1])); + + udp::endpoint broadcast_endpoint( + asio::ip::make_address(argv[2]), atoi(argv[3])); + + server s(io_context, listen_endpoint, broadcast_endpoint); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp11/timers/time_t_timer.cpp b/3rdparty/asio/src/examples/cpp11/timers/time_t_timer.cpp new file mode 100644 index 00000000000..bca436d31e7 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/timers/time_t_timer.cpp @@ -0,0 +1,106 @@ +// +// time_t_timer.cpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <ctime> +#include <chrono> +#include <iostream> + +// A custom implementation of the Clock concept from the standard C++ library. +struct time_t_clock +{ + // The duration type. + typedef std::chrono::steady_clock::duration duration; + + // The duration's underlying arithmetic representation. + typedef duration::rep rep; + + // The ratio representing the duration's tick period. + typedef duration::period period; + + // An absolute time point represented using the clock. + typedef std::chrono::time_point<time_t_clock> time_point; + + // The clock is not monotonically increasing. + static constexpr bool is_steady = false; + + // Get the current time. + static time_point now() noexcept + { + return time_point() + std::chrono::seconds(std::time(0)); + } +}; + +// The asio::basic_waitable_timer template accepts an optional WaitTraits +// template parameter. The underlying time_t clock has one-second granularity, +// so these traits may be customised to reduce the latency between the clock +// ticking over and a wait operation's completion. When the timeout is near +// (less than one second away) we poll the clock more frequently to detect the +// time change closer to when it occurs. The user can select the appropriate +// trade off between accuracy and the increased CPU cost of polling. In extreme +// cases, a zero duration may be returned to make the timers as accurate as +// possible, albeit with 100% CPU usage. +struct time_t_wait_traits +{ + // Determine how long until the clock should be next polled to determine + // whether the duration has elapsed. + static time_t_clock::duration to_wait_duration( + const time_t_clock::duration& d) + { + if (d > std::chrono::seconds(1)) + return d - std::chrono::seconds(1); + else if (d > std::chrono::seconds(0)) + return std::chrono::milliseconds(10); + else + return std::chrono::seconds(0); + } + + // Determine how long until the clock should be next polled to determine + // whether the absoluate time has been reached. + static time_t_clock::duration to_wait_duration( + const time_t_clock::time_point& t) + { + return to_wait_duration(t - time_t_clock::now()); + } +}; + +typedef asio::basic_waitable_timer< + time_t_clock, time_t_wait_traits> time_t_timer; + +int main() +{ + try + { + asio::io_context io_context; + + time_t_timer timer(io_context); + + timer.expires_after(std::chrono::seconds(5)); + std::cout << "Starting synchronous wait\n"; + timer.wait(); + std::cout << "Finished synchronous wait\n"; + + timer.expires_after(std::chrono::seconds(5)); + std::cout << "Starting asynchronous wait\n"; + timer.async_wait( + [](const std::error_code& /*error*/) + { + std::cout << "timeout\n"; + }); + io_context.run(); + std::cout << "Finished asynchronous wait\n"; + } + catch (std::exception& e) + { + std::cout << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime1/client.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/daytime1/client.cpp index 9784d48a6fb..9d927759f5c 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime1/client.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/daytime1/client.cpp @@ -2,14 +2,14 @@ // client.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <array> #include <iostream> -#include <boost/array.hpp> #include <asio.hpp> using asio::ip::tcp; @@ -35,15 +35,15 @@ int main(int argc, char* argv[]) for (;;) { - boost::array<char, 128> buf; - asio::error_code error; + std::array<char, 128> buf; + std::error_code error; size_t len = socket.read_some(asio::buffer(buf), error); if (error == asio::error::eof) break; // Connection closed cleanly by peer. else if (error) - throw asio::system_error(error); // Some other error. + throw std::system_error(error); // Some other error. std::cout.write(buf.data(), len); } diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime2/server.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/daytime2/server.cpp index f662ed246c4..971149d6e8d 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime2/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/daytime2/server.cpp @@ -2,7 +2,7 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -37,7 +37,7 @@ int main() std::string message = make_daytime_string(); - asio::error_code ignored_error; + std::error_code ignored_error; asio::write(socket, asio::buffer(message), ignored_error); } } diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime3/server.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/daytime3/server.cpp index cb2c9480594..339de72d4a7 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime3/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/daytime3/server.cpp @@ -2,18 +2,17 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include <ctime> +#include <functional> #include <iostream> +#include <memory> #include <string> -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> #include <asio.hpp> using asio::ip::tcp; @@ -26,10 +25,10 @@ std::string make_daytime_string() } class tcp_connection - : public boost::enable_shared_from_this<tcp_connection> + : public std::enable_shared_from_this<tcp_connection> { public: - typedef boost::shared_ptr<tcp_connection> pointer; + typedef std::shared_ptr<tcp_connection> pointer; static pointer create(asio::io_context& io_context) { @@ -46,7 +45,7 @@ public: message_ = make_daytime_string(); asio::async_write(socket_, asio::buffer(message_), - boost::bind(&tcp_connection::handle_write, shared_from_this(), + std::bind(&tcp_connection::handle_write, shared_from_this(), asio::placeholders::error, asio::placeholders::bytes_transferred)); } @@ -57,7 +56,7 @@ private: { } - void handle_write(const asio::error_code& /*error*/, + void handle_write(const std::error_code& /*error*/, size_t /*bytes_transferred*/) { } @@ -70,7 +69,8 @@ class tcp_server { public: tcp_server(asio::io_context& io_context) - : acceptor_(io_context, tcp::endpoint(tcp::v4(), 13)) + : io_context_(io_context), + acceptor_(io_context, tcp::endpoint(tcp::v4(), 13)) { start_accept(); } @@ -79,15 +79,15 @@ private: void start_accept() { tcp_connection::pointer new_connection = - tcp_connection::create(acceptor_.get_executor().context()); + tcp_connection::create(io_context_); acceptor_.async_accept(new_connection->socket(), - boost::bind(&tcp_server::handle_accept, this, new_connection, + std::bind(&tcp_server::handle_accept, this, new_connection, asio::placeholders::error)); } void handle_accept(tcp_connection::pointer new_connection, - const asio::error_code& error) + const std::error_code& error) { if (!error) { @@ -97,6 +97,7 @@ private: start_accept(); } + asio::io_context& io_context_; tcp::acceptor acceptor_; }; diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime4/client.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/daytime4/client.cpp index da3b651d56d..15f3d5d4e98 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime4/client.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/daytime4/client.cpp @@ -2,14 +2,14 @@ // client.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <array> #include <iostream> -#include <boost/array.hpp> #include <asio.hpp> using asio::ip::udp; @@ -33,10 +33,10 @@ int main(int argc, char* argv[]) udp::socket socket(io_context); socket.open(udp::v4()); - boost::array<char, 1> send_buf = {{ 0 }}; + std::array<char, 1> send_buf = {{ 0 }}; socket.send_to(asio::buffer(send_buf), receiver_endpoint); - boost::array<char, 128> recv_buf; + std::array<char, 128> recv_buf; udp::endpoint sender_endpoint; size_t len = socket.receive_from( asio::buffer(recv_buf), sender_endpoint); diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime5/server.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/daytime5/server.cpp index fdf452562d2..f47c9fa713b 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime5/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/daytime5/server.cpp @@ -2,16 +2,16 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <array> #include <ctime> #include <iostream> #include <string> -#include <boost/array.hpp> #include <asio.hpp> using asio::ip::udp; @@ -33,18 +33,13 @@ int main() for (;;) { - boost::array<char, 1> recv_buf; + std::array<char, 1> recv_buf; udp::endpoint remote_endpoint; - asio::error_code error; - socket.receive_from(asio::buffer(recv_buf), - remote_endpoint, 0, error); - - if (error && error != asio::error::message_size) - throw asio::system_error(error); + socket.receive_from(asio::buffer(recv_buf), remote_endpoint); std::string message = make_daytime_string(); - asio::error_code ignored_error; + std::error_code ignored_error; socket.send_to(asio::buffer(message), remote_endpoint, 0, ignored_error); } diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime6/server.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/daytime6/server.cpp index d67045ff990..42c80795a9e 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime6/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/daytime6/server.cpp @@ -2,18 +2,18 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <array> #include <ctime> +#include <functional> #include <iostream> +#include <memory> #include <string> -#include <boost/array.hpp> -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> #include <asio.hpp> using asio::ip::udp; @@ -39,21 +39,21 @@ private: { socket_.async_receive_from( asio::buffer(recv_buffer_), remote_endpoint_, - boost::bind(&udp_server::handle_receive, this, + std::bind(&udp_server::handle_receive, this, asio::placeholders::error, asio::placeholders::bytes_transferred)); } - void handle_receive(const asio::error_code& error, + void handle_receive(const std::error_code& error, std::size_t /*bytes_transferred*/) { - if (!error || error == asio::error::message_size) + if (!error) { - boost::shared_ptr<std::string> message( + std::shared_ptr<std::string> message( new std::string(make_daytime_string())); socket_.async_send_to(asio::buffer(*message), remote_endpoint_, - boost::bind(&udp_server::handle_send, this, message, + std::bind(&udp_server::handle_send, this, message, asio::placeholders::error, asio::placeholders::bytes_transferred)); @@ -61,15 +61,15 @@ private: } } - void handle_send(boost::shared_ptr<std::string> /*message*/, - const asio::error_code& /*error*/, + void handle_send(std::shared_ptr<std::string> /*message*/, + const std::error_code& /*error*/, std::size_t /*bytes_transferred*/) { } udp::socket socket_; udp::endpoint remote_endpoint_; - boost::array<char, 1> recv_buffer_; + std::array<char, 1> recv_buffer_; }; int main() diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/daytime7/server.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/daytime7/server.cpp index b9dc60558c9..9c9c22edeb2 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/daytime7/server.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/daytime7/server.cpp @@ -2,19 +2,18 @@ // server.cpp // ~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <array> #include <ctime> +#include <functional> #include <iostream> +#include <memory> #include <string> -#include <boost/array.hpp> -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> #include <asio.hpp> using asio::ip::tcp; @@ -28,10 +27,10 @@ std::string make_daytime_string() } class tcp_connection - : public boost::enable_shared_from_this<tcp_connection> + : public std::enable_shared_from_this<tcp_connection> { public: - typedef boost::shared_ptr<tcp_connection> pointer; + typedef std::shared_ptr<tcp_connection> pointer; static pointer create(asio::io_context& io_context) { @@ -48,7 +47,7 @@ public: message_ = make_daytime_string(); asio::async_write(socket_, asio::buffer(message_), - boost::bind(&tcp_connection::handle_write, shared_from_this())); + std::bind(&tcp_connection::handle_write, shared_from_this())); } private: @@ -69,7 +68,8 @@ class tcp_server { public: tcp_server(asio::io_context& io_context) - : acceptor_(io_context, tcp::endpoint(tcp::v4(), 13)) + : io_context_(io_context), + acceptor_(io_context, tcp::endpoint(tcp::v4(), 13)) { start_accept(); } @@ -78,15 +78,15 @@ private: void start_accept() { tcp_connection::pointer new_connection = - tcp_connection::create(acceptor_.get_executor().context()); + tcp_connection::create(io_context_); acceptor_.async_accept(new_connection->socket(), - boost::bind(&tcp_server::handle_accept, this, new_connection, + std::bind(&tcp_server::handle_accept, this, new_connection, asio::placeholders::error)); } void handle_accept(tcp_connection::pointer new_connection, - const asio::error_code& error) + const std::error_code& error) { if (!error) { @@ -96,6 +96,7 @@ private: start_accept(); } + asio::io_context& io_context_; tcp::acceptor acceptor_; }; @@ -113,31 +114,31 @@ private: { socket_.async_receive_from( asio::buffer(recv_buffer_), remote_endpoint_, - boost::bind(&udp_server::handle_receive, this, + std::bind(&udp_server::handle_receive, this, asio::placeholders::error)); } - void handle_receive(const asio::error_code& error) + void handle_receive(const std::error_code& error) { - if (!error || error == asio::error::message_size) + if (!error) { - boost::shared_ptr<std::string> message( + std::shared_ptr<std::string> message( new std::string(make_daytime_string())); socket_.async_send_to(asio::buffer(*message), remote_endpoint_, - boost::bind(&udp_server::handle_send, this, message)); + std::bind(&udp_server::handle_send, this, message)); start_receive(); } } - void handle_send(boost::shared_ptr<std::string> /*message*/) + void handle_send(std::shared_ptr<std::string> /*message*/) { } udp::socket socket_; udp::endpoint remote_endpoint_; - boost::array<char, 1> recv_buffer_; + std::array<char, 1> recv_buffer_; }; int main() diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/timer1/timer.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/timer1/timer.cpp index 79ddf918261..37577dcb65f 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/timer1/timer.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/timer1/timer.cpp @@ -2,7 +2,7 @@ // timer.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,13 +10,12 @@ #include <iostream> #include <asio.hpp> -#include <boost/date_time/posix_time/posix_time.hpp> int main() { asio::io_context io; - asio::deadline_timer t(io, boost::posix_time::seconds(5)); + asio::steady_timer t(io, asio::chrono::seconds(5)); t.wait(); std::cout << "Hello, world!" << std::endl; diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/timer2/timer.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/timer2/timer.cpp index 3275c22c2f6..c1620d78fa5 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/timer2/timer.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/timer2/timer.cpp @@ -2,7 +2,7 @@ // timer.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,9 +10,8 @@ #include <iostream> #include <asio.hpp> -#include <boost/date_time/posix_time/posix_time.hpp> -void print(const asio::error_code& /*e*/) +void print(const std::error_code& /*e*/) { std::cout << "Hello, world!" << std::endl; } @@ -21,7 +20,7 @@ int main() { asio::io_context io; - asio::deadline_timer t(io, boost::posix_time::seconds(5)); + asio::steady_timer t(io, asio::chrono::seconds(5)); t.async_wait(&print); io.run(); diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/timer3/timer.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/timer3/timer.cpp index dfbf7d660a0..990ea069739 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/timer3/timer.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/timer3/timer.cpp @@ -2,27 +2,26 @@ // timer.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <functional> #include <iostream> #include <asio.hpp> -#include <boost/bind.hpp> -#include <boost/date_time/posix_time/posix_time.hpp> -void print(const asio::error_code& /*e*/, - asio::deadline_timer* t, int* count) +void print(const std::error_code& /*e*/, + asio::steady_timer* t, int* count) { if (*count < 5) { std::cout << *count << std::endl; ++(*count); - t->expires_at(t->expires_at() + boost::posix_time::seconds(1)); - t->async_wait(boost::bind(print, + t->expires_at(t->expiry() + asio::chrono::seconds(1)); + t->async_wait(std::bind(print, asio::placeholders::error, t, count)); } } @@ -32,8 +31,8 @@ int main() asio::io_context io; int count = 0; - asio::deadline_timer t(io, boost::posix_time::seconds(1)); - t.async_wait(boost::bind(print, + asio::steady_timer t(io, asio::chrono::seconds(1)); + t.async_wait(std::bind(print, asio::placeholders::error, &t, &count)); io.run(); diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/timer4/timer.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/timer4/timer.cpp index cbea70d26fa..7bfdd3e43a8 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/timer4/timer.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/timer4/timer.cpp @@ -2,25 +2,24 @@ // timer.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <functional> #include <iostream> #include <asio.hpp> -#include <boost/bind.hpp> -#include <boost/date_time/posix_time/posix_time.hpp> class printer { public: printer(asio::io_context& io) - : timer_(io, boost::posix_time::seconds(1)), + : timer_(io, asio::chrono::seconds(1)), count_(0) { - timer_.async_wait(boost::bind(&printer::print, this)); + timer_.async_wait(std::bind(&printer::print, this)); } ~printer() @@ -35,13 +34,13 @@ public: std::cout << count_ << std::endl; ++count_; - timer_.expires_at(timer_.expires_at() + boost::posix_time::seconds(1)); - timer_.async_wait(boost::bind(&printer::print, this)); + timer_.expires_at(timer_.expiry() + asio::chrono::seconds(1)); + timer_.async_wait(std::bind(&printer::print, this)); } } private: - asio::deadline_timer timer_; + asio::steady_timer timer_; int count_; }; diff --git a/3rdparty/asio/src/examples/cpp03/tutorial/timer5/timer.cpp b/3rdparty/asio/src/examples/cpp11/tutorial/timer5/timer.cpp index a798e85aacf..61830691e7a 100644 --- a/3rdparty/asio/src/examples/cpp03/tutorial/timer5/timer.cpp +++ b/3rdparty/asio/src/examples/cpp11/tutorial/timer5/timer.cpp @@ -2,31 +2,31 @@ // timer.cpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // +#include <functional> #include <iostream> +#include <thread> #include <asio.hpp> -#include <boost/bind.hpp> -#include <boost/date_time/posix_time/posix_time.hpp> class printer { public: printer(asio::io_context& io) - : strand_(io), - timer1_(io, boost::posix_time::seconds(1)), - timer2_(io, boost::posix_time::seconds(1)), + : strand_(asio::make_strand(io)), + timer1_(io, asio::chrono::seconds(1)), + timer2_(io, asio::chrono::seconds(1)), count_(0) { timer1_.async_wait(asio::bind_executor(strand_, - boost::bind(&printer::print1, this))); + std::bind(&printer::print1, this))); timer2_.async_wait(asio::bind_executor(strand_, - boost::bind(&printer::print2, this))); + std::bind(&printer::print2, this))); } ~printer() @@ -41,10 +41,10 @@ public: std::cout << "Timer 1: " << count_ << std::endl; ++count_; - timer1_.expires_at(timer1_.expires_at() + boost::posix_time::seconds(1)); + timer1_.expires_at(timer1_.expiry() + asio::chrono::seconds(1)); timer1_.async_wait(asio::bind_executor(strand_, - boost::bind(&printer::print1, this))); + std::bind(&printer::print1, this))); } } @@ -55,17 +55,17 @@ public: std::cout << "Timer 2: " << count_ << std::endl; ++count_; - timer2_.expires_at(timer2_.expires_at() + boost::posix_time::seconds(1)); + timer2_.expires_at(timer2_.expiry() + asio::chrono::seconds(1)); timer2_.async_wait(asio::bind_executor(strand_, - boost::bind(&printer::print2, this))); + std::bind(&printer::print2, this))); } } private: - asio::io_context::strand strand_; - asio::deadline_timer timer1_; - asio::deadline_timer timer2_; + asio::strand<asio::io_context::executor_type> strand_; + asio::steady_timer timer1_; + asio::steady_timer timer2_; int count_; }; @@ -73,7 +73,7 @@ int main() { asio::io_context io; printer p(io); - asio::thread t(boost::bind(&asio::io_context::run, &io)); + std::thread t([&]{ io.run(); }); io.run(); t.join(); diff --git a/3rdparty/asio/src/examples/cpp11/type_erasure/line_reader.hpp b/3rdparty/asio/src/examples/cpp11/type_erasure/line_reader.hpp new file mode 100644 index 00000000000..87f05486b79 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/type_erasure/line_reader.hpp @@ -0,0 +1,48 @@ +// +// line_reader.hpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef LINE_READER_HPP +#define LINE_READER_HPP + +#include <asio/any_completion_handler.hpp> +#include <asio/async_result.hpp> +#include <asio/error.hpp> +#include <string> + +class line_reader +{ +private: + virtual void async_read_line_impl(std::string prompt, + asio::any_completion_handler<void(std::error_code, std::string)> handler) = 0; + + struct initiate_read_line + { + template <typename Handler> + void operator()(Handler handler, line_reader* self, std::string prompt) + { + self->async_read_line_impl(std::move(prompt), std::move(handler)); + } + }; + +public: + virtual ~line_reader() {} + + template <typename CompletionToken> + auto async_read_line(std::string prompt, CompletionToken&& token) + -> decltype( + asio::async_initiate<CompletionToken, void(std::error_code, std::string)>( + initiate_read_line(), token, this, prompt)) + { + return asio::async_initiate<CompletionToken, void(std::error_code, std::string)>( + initiate_read_line(), token, this, prompt); + } +}; + +#endif // LINE_READER_HPP diff --git a/3rdparty/asio/src/examples/cpp11/type_erasure/main.cpp b/3rdparty/asio/src/examples/cpp11/type_erasure/main.cpp new file mode 100644 index 00000000000..2111de6853b --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/type_erasure/main.cpp @@ -0,0 +1,60 @@ +// +// main.cpp +// ~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "line_reader.hpp" +#include "sleep.hpp" +#include "stdin_line_reader.hpp" +#include <asio/coroutine.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/use_awaitable.hpp> +#include <iostream> + +#include <asio/yield.hpp> + +class read_loop : asio::coroutine +{ +public: + read_loop(asio::any_io_executor e, line_reader& r) + : executor(std::move(e)), + reader(r) + { + } + + void operator()(std::error_code ec = {}, std::string line = {}) + { + reenter (this) + { + for (i = 0; i < 10; ++i) + { + yield reader.async_read_line("Enter something: ", *this); + if (ec) break; + std::cout << line; + yield async_sleep(executor, std::chrono::seconds(1), *this); + if (ec) break; + } + } + } + +private: + asio::any_io_executor executor; + line_reader& reader; + int i; +}; + +#include <asio/unyield.hpp> + +int main() +{ + asio::io_context ctx{1}; + stdin_line_reader reader{ctx.get_executor()}; + read_loop(ctx.get_executor(), reader)(); + ctx.run(); +} diff --git a/3rdparty/asio/src/examples/cpp11/type_erasure/sleep.cpp b/3rdparty/asio/src/examples/cpp11/type_erasure/sleep.cpp new file mode 100644 index 00000000000..b605866ebd7 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/type_erasure/sleep.cpp @@ -0,0 +1,22 @@ +// +// sleep.cpp +// ~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "sleep.hpp" +#include <asio/consign.hpp> +#include <asio/steady_timer.hpp> +#include <memory> + +void async_sleep_impl( + asio::any_completion_handler<void(std::error_code)> handler, + asio::any_io_executor ex, std::chrono::nanoseconds duration) +{ + auto timer = std::make_shared<asio::steady_timer>(ex, duration); + timer->async_wait(asio::consign(std::move(handler), timer)); +} diff --git a/3rdparty/asio/src/examples/cpp11/type_erasure/sleep.hpp b/3rdparty/asio/src/examples/cpp11/type_erasure/sleep.hpp new file mode 100644 index 00000000000..299397a833c --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/type_erasure/sleep.hpp @@ -0,0 +1,35 @@ +// +// sleep.hpp +// ~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SLEEP_HPP +#define SLEEP_HPP + +#include <asio/any_completion_handler.hpp> +#include <asio/any_io_executor.hpp> +#include <asio/async_result.hpp> +#include <asio/error.hpp> +#include <chrono> + +void async_sleep_impl( + asio::any_completion_handler<void(std::error_code)> handler, + asio::any_io_executor ex, std::chrono::nanoseconds duration); + +template <typename CompletionToken> +inline auto async_sleep(asio::any_io_executor ex, + std::chrono::nanoseconds duration, CompletionToken&& token) + -> decltype( + asio::async_initiate<CompletionToken, void(std::error_code)>( + async_sleep_impl, token, std::move(ex), duration)) +{ + return asio::async_initiate<CompletionToken, void(std::error_code)>( + async_sleep_impl, token, std::move(ex), duration); +} + +#endif // SLEEP_HPP diff --git a/3rdparty/asio/src/examples/cpp11/type_erasure/stdin_line_reader.cpp b/3rdparty/asio/src/examples/cpp11/type_erasure/stdin_line_reader.cpp new file mode 100644 index 00000000000..d2e25e437a6 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/type_erasure/stdin_line_reader.cpp @@ -0,0 +1,44 @@ +// +// stdin_line_reader.cpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "stdin_line_reader.hpp" +#include <asio/deferred.hpp> +#include <asio/read_until.hpp> +#include <iostream> + +stdin_line_reader::stdin_line_reader(asio::any_io_executor ex) + : stdin_(ex, ::dup(STDIN_FILENO)) +{ +} + +void stdin_line_reader::async_read_line_impl(std::string prompt, + asio::any_completion_handler<void(std::error_code, std::string)> handler) +{ + std::cout << prompt; + std::cout.flush(); + + asio::async_read_until(stdin_, asio::dynamic_buffer(buffer_), '\n', + asio::deferred( + [this](std::error_code ec, std::size_t n) + { + if (!ec) + { + std::string result = buffer_.substr(0, n); + buffer_.erase(0, n); + return asio::deferred.values(ec, std::move(result)); + } + else + { + return asio::deferred.values(ec, std::string{}); + } + } + ) + )(std::move(handler)); +} diff --git a/3rdparty/asio/src/examples/cpp11/type_erasure/stdin_line_reader.hpp b/3rdparty/asio/src/examples/cpp11/type_erasure/stdin_line_reader.hpp new file mode 100644 index 00000000000..43e67424367 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp11/type_erasure/stdin_line_reader.hpp @@ -0,0 +1,30 @@ +// +// stdin_line_reader.hpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef STDIN_LINE_READER_HPP +#define STDIN_LINE_READER_HPP + +#include "line_reader.hpp" +#include <asio/posix/stream_descriptor.hpp> + +class stdin_line_reader : public line_reader +{ +public: + explicit stdin_line_reader(asio::any_io_executor ex); + +private: + void async_read_line_impl(std::string prompt, + asio::any_completion_handler<void(std::error_code, std::string)> handler) override; + + asio::posix::stream_descriptor stdin_; + std::string buffer_; +}; + +#endif diff --git a/3rdparty/asio/src/examples/cpp03/windows/transmit_file.cpp b/3rdparty/asio/src/examples/cpp11/windows/transmit_file.cpp index 8ca9e1790fc..0ffd0486c43 100644 --- a/3rdparty/asio/src/examples/cpp03/windows/transmit_file.cpp +++ b/3rdparty/asio/src/examples/cpp11/windows/transmit_file.cpp @@ -2,18 +2,17 @@ // transmit_file.cpp // ~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include <ctime> +#include <functional> #include <iostream> +#include <memory> #include <string> -#include <boost/bind.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/enable_shared_from_this.hpp> #include "asio.hpp" #if defined(ASIO_HAS_WINDOWS_OVERLAPPED_PTR) @@ -22,9 +21,15 @@ using asio::ip::tcp; using asio::windows::overlapped_ptr; using asio::windows::random_access_handle; +typedef asio::basic_stream_socket<tcp, + asio::io_context::executor_type> tcp_socket; + +typedef asio::basic_socket_acceptor<tcp, + asio::io_context::executor_type> tcp_acceptor; + // A wrapper for the TransmitFile overlapped I/O operation. template <typename Handler> -void transmit_file(tcp::socket& socket, +void transmit_file(tcp_socket& socket, random_access_handle& file, Handler handler) { // Construct an OVERLAPPED-derived object to contain the handler. @@ -41,7 +46,7 @@ void transmit_file(tcp::socket& socket, // The operation completed immediately, so a completion notification needs // to be posted. When complete() is called, ownership of the OVERLAPPED- // derived object passes to the io_context. - asio::error_code ec(last_error, + std::error_code ec(last_error, asio::error::get_system_category()); overlapped.complete(ec, 0); } @@ -54,10 +59,10 @@ void transmit_file(tcp::socket& socket, } class connection - : public boost::enable_shared_from_this<connection> + : public std::enable_shared_from_this<connection> { public: - typedef boost::shared_ptr<connection> pointer; + typedef std::shared_ptr<connection> pointer; static pointer create(asio::io_context& io_context, const std::string& filename) @@ -65,20 +70,20 @@ public: return pointer(new connection(io_context, filename)); } - tcp::socket& socket() + tcp_socket& socket() { return socket_; } void start() { - asio::error_code ec; + std::error_code ec; file_.assign(::CreateFile(filename_.c_str(), GENERIC_READ, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, 0), ec); if (file_.is_open()) { transmit_file(socket_, file_, - boost::bind(&connection::handle_write, shared_from_this(), + std::bind(&connection::handle_write, shared_from_this(), asio::placeholders::error, asio::placeholders::bytes_transferred)); } @@ -92,14 +97,14 @@ private: { } - void handle_write(const asio::error_code& /*error*/, + void handle_write(const std::error_code& /*error*/, size_t /*bytes_transferred*/) { - asio::error_code ignored_ec; - socket_.shutdown(tcp::socket::shutdown_both, ignored_ec); + std::error_code ignored_ec; + socket_.shutdown(tcp_socket::shutdown_both, ignored_ec); } - tcp::socket socket_; + tcp_socket socket_; std::string filename_; random_access_handle file_; }; @@ -122,12 +127,12 @@ private: connection::create(acceptor_.get_executor().context(), filename_); acceptor_.async_accept(new_connection->socket(), - boost::bind(&server::handle_accept, this, new_connection, + std::bind(&server::handle_accept, this, new_connection, asio::placeholders::error)); } void handle_accept(connection::pointer new_connection, - const asio::error_code& error) + const std::error_code& error) { if (!error) { @@ -137,7 +142,7 @@ private: start_accept(); } - tcp::acceptor acceptor_; + tcp_acceptor acceptor_; std::string filename_; }; diff --git a/3rdparty/asio/src/examples/cpp14/Makefile.am b/3rdparty/asio/src/examples/cpp14/Makefile.am index fb8c35689c6..2ddf12a8a2f 100644 --- a/3rdparty/asio/src/examples/cpp14/Makefile.am +++ b/3rdparty/asio/src/examples/cpp14/Makefile.am @@ -10,6 +10,13 @@ LDADD = libasio.a endif noinst_PROGRAMS = \ + deferred/deferred_1 \ + deferred/deferred_2 \ + deferred/deferred_3 \ + deferred/deferred_4 \ + deferred/deferred_5 \ + deferred/deferred_6 \ + deferred/deferred_7 \ echo/async_tcp_echo_server \ echo/async_udp_echo_server \ echo/blocking_tcp_echo_client \ @@ -24,10 +31,34 @@ noinst_PROGRAMS = \ executors/fork_join \ executors/pipeline \ executors/priority_scheduler \ - iostreams/http_client + iostreams/http_client \ + operations/c_callback_wrapper \ + operations/callback_wrapper \ + operations/composed_1 \ + operations/composed_1 \ + operations/composed_2 \ + operations/composed_3 \ + operations/composed_4 \ + operations/composed_5 \ + operations/composed_6 \ + operations/composed_7 \ + operations/composed_8 \ + parallel_group/parallel_sort \ + parallel_group/ranged_wait_for_all \ + parallel_group/wait_for_all \ + parallel_group/wait_for_one \ + parallel_group/wait_for_one_error \ + parallel_group/wait_for_one_success AM_CXXFLAGS = -I$(srcdir)/../../../include +deferred_deferred_1_SOURCES = deferred/deferred_1.cpp +deferred_deferred_2_SOURCES = deferred/deferred_2.cpp +deferred_deferred_3_SOURCES = deferred/deferred_3.cpp +deferred_deferred_4_SOURCES = deferred/deferred_4.cpp +deferred_deferred_5_SOURCES = deferred/deferred_5.cpp +deferred_deferred_6_SOURCES = deferred/deferred_6.cpp +deferred_deferred_7_SOURCES = deferred/deferred_7.cpp echo_async_tcp_echo_server_SOURCES = echo/async_tcp_echo_server.cpp echo_async_udp_echo_server_SOURCES = echo/async_udp_echo_server.cpp echo_blocking_tcp_echo_client_SOURCES = echo/blocking_tcp_echo_client.cpp @@ -43,6 +74,22 @@ executors_fork_join_SOURCES = executors/fork_join.cpp executors_pipeline_SOURCES = executors/pipeline.cpp executors_priority_scheduler_SOURCES = executors/priority_scheduler.cpp iostreams_http_client_SOURCES = iostreams/http_client.cpp +operations_c_callback_wrapper_SOURCES = operations/c_callback_wrapper.cpp +operations_callback_wrapper_SOURCES = operations/callback_wrapper.cpp +operations_composed_1_SOURCES = operations/composed_1.cpp +operations_composed_2_SOURCES = operations/composed_2.cpp +operations_composed_3_SOURCES = operations/composed_3.cpp +operations_composed_4_SOURCES = operations/composed_4.cpp +operations_composed_5_SOURCES = operations/composed_5.cpp +operations_composed_6_SOURCES = operations/composed_6.cpp +operations_composed_7_SOURCES = operations/composed_7.cpp +operations_composed_8_SOURCES = operations/composed_8.cpp +parallel_group_parallel_sort_SOURCES = parallel_group/parallel_sort.cpp +parallel_group_ranged_wait_for_all_SOURCES = parallel_group/ranged_wait_for_all.cpp +parallel_group_wait_for_all_SOURCES = parallel_group/wait_for_all.cpp +parallel_group_wait_for_one_SOURCES = parallel_group/wait_for_one.cpp +parallel_group_wait_for_one_error_SOURCES = parallel_group/wait_for_one_error.cpp +parallel_group_wait_for_one_success_SOURCES = parallel_group/wait_for_one_success.cpp MAINTAINERCLEANFILES = \ $(srcdir)/Makefile.in diff --git a/3rdparty/asio/src/examples/cpp14/Makefile.in b/3rdparty/asio/src/examples/cpp14/Makefile.in new file mode 100644 index 00000000000..23fdb3fc1e2 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/Makefile.in @@ -0,0 +1,1378 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@HAVE_OPENSSL_TRUE@@SEPARATE_COMPILATION_TRUE@am__append_1 = ../../asio_ssl.cpp +noinst_PROGRAMS = deferred/deferred_1$(EXEEXT) \ + deferred/deferred_2$(EXEEXT) deferred/deferred_3$(EXEEXT) \ + deferred/deferred_4$(EXEEXT) deferred/deferred_5$(EXEEXT) \ + deferred/deferred_6$(EXEEXT) deferred/deferred_7$(EXEEXT) \ + echo/async_tcp_echo_server$(EXEEXT) \ + echo/async_udp_echo_server$(EXEEXT) \ + echo/blocking_tcp_echo_client$(EXEEXT) \ + echo/blocking_tcp_echo_server$(EXEEXT) \ + echo/blocking_udp_echo_client$(EXEEXT) \ + echo/blocking_udp_echo_server$(EXEEXT) \ + executors/actor$(EXEEXT) executors/async_1$(EXEEXT) \ + executors/async_2$(EXEEXT) executors/bank_account_1$(EXEEXT) \ + executors/bank_account_2$(EXEEXT) executors/fork_join$(EXEEXT) \ + executors/pipeline$(EXEEXT) \ + executors/priority_scheduler$(EXEEXT) \ + iostreams/http_client$(EXEEXT) \ + operations/c_callback_wrapper$(EXEEXT) \ + operations/callback_wrapper$(EXEEXT) \ + operations/composed_1$(EXEEXT) operations/composed_1$(EXEEXT) \ + operations/composed_2$(EXEEXT) operations/composed_3$(EXEEXT) \ + operations/composed_4$(EXEEXT) operations/composed_5$(EXEEXT) \ + operations/composed_6$(EXEEXT) operations/composed_7$(EXEEXT) \ + operations/composed_8$(EXEEXT) \ + parallel_group/parallel_sort$(EXEEXT) \ + parallel_group/ranged_wait_for_all$(EXEEXT) \ + parallel_group/wait_for_all$(EXEEXT) \ + parallel_group/wait_for_one$(EXEEXT) \ + parallel_group/wait_for_one_error$(EXEEXT) \ + parallel_group/wait_for_one_success$(EXEEXT) +subdir = src/examples/cpp14 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +AM_V_AR = $(am__v_AR_@AM_V@) +am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) +am__v_AR_0 = @echo " AR " $@; +am__v_AR_1 = +libasio_a_AR = $(AR) $(ARFLAGS) +libasio_a_LIBADD = +am__libasio_a_SOURCES_DIST = ../../asio.cpp ../../asio_ssl.cpp +am__dirstamp = $(am__leading_dot)dirstamp +@HAVE_OPENSSL_TRUE@@SEPARATE_COMPILATION_TRUE@am__objects_1 = ../../asio_ssl.$(OBJEXT) +@SEPARATE_COMPILATION_TRUE@am_libasio_a_OBJECTS = \ +@SEPARATE_COMPILATION_TRUE@ ../../asio.$(OBJEXT) \ +@SEPARATE_COMPILATION_TRUE@ $(am__objects_1) +libasio_a_OBJECTS = $(am_libasio_a_OBJECTS) +am_deferred_deferred_1_OBJECTS = deferred/deferred_1.$(OBJEXT) +deferred_deferred_1_OBJECTS = $(am_deferred_deferred_1_OBJECTS) +deferred_deferred_1_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@deferred_deferred_1_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_deferred_deferred_2_OBJECTS = deferred/deferred_2.$(OBJEXT) +deferred_deferred_2_OBJECTS = $(am_deferred_deferred_2_OBJECTS) +deferred_deferred_2_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@deferred_deferred_2_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_deferred_deferred_3_OBJECTS = deferred/deferred_3.$(OBJEXT) +deferred_deferred_3_OBJECTS = $(am_deferred_deferred_3_OBJECTS) +deferred_deferred_3_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@deferred_deferred_3_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_deferred_deferred_4_OBJECTS = deferred/deferred_4.$(OBJEXT) +deferred_deferred_4_OBJECTS = $(am_deferred_deferred_4_OBJECTS) +deferred_deferred_4_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@deferred_deferred_4_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_deferred_deferred_5_OBJECTS = deferred/deferred_5.$(OBJEXT) +deferred_deferred_5_OBJECTS = $(am_deferred_deferred_5_OBJECTS) +deferred_deferred_5_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@deferred_deferred_5_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_deferred_deferred_6_OBJECTS = deferred/deferred_6.$(OBJEXT) +deferred_deferred_6_OBJECTS = $(am_deferred_deferred_6_OBJECTS) +deferred_deferred_6_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@deferred_deferred_6_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_deferred_deferred_7_OBJECTS = deferred/deferred_7.$(OBJEXT) +deferred_deferred_7_OBJECTS = $(am_deferred_deferred_7_OBJECTS) +deferred_deferred_7_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@deferred_deferred_7_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_async_tcp_echo_server_OBJECTS = \ + echo/async_tcp_echo_server.$(OBJEXT) +echo_async_tcp_echo_server_OBJECTS = \ + $(am_echo_async_tcp_echo_server_OBJECTS) +echo_async_tcp_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_async_tcp_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_async_udp_echo_server_OBJECTS = \ + echo/async_udp_echo_server.$(OBJEXT) +echo_async_udp_echo_server_OBJECTS = \ + $(am_echo_async_udp_echo_server_OBJECTS) +echo_async_udp_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_async_udp_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_blocking_tcp_echo_client_OBJECTS = \ + echo/blocking_tcp_echo_client.$(OBJEXT) +echo_blocking_tcp_echo_client_OBJECTS = \ + $(am_echo_blocking_tcp_echo_client_OBJECTS) +echo_blocking_tcp_echo_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_blocking_tcp_echo_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_blocking_tcp_echo_server_OBJECTS = \ + echo/blocking_tcp_echo_server.$(OBJEXT) +echo_blocking_tcp_echo_server_OBJECTS = \ + $(am_echo_blocking_tcp_echo_server_OBJECTS) +echo_blocking_tcp_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_blocking_tcp_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_blocking_udp_echo_client_OBJECTS = \ + echo/blocking_udp_echo_client.$(OBJEXT) +echo_blocking_udp_echo_client_OBJECTS = \ + $(am_echo_blocking_udp_echo_client_OBJECTS) +echo_blocking_udp_echo_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_blocking_udp_echo_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_echo_blocking_udp_echo_server_OBJECTS = \ + echo/blocking_udp_echo_server.$(OBJEXT) +echo_blocking_udp_echo_server_OBJECTS = \ + $(am_echo_blocking_udp_echo_server_OBJECTS) +echo_blocking_udp_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@echo_blocking_udp_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_executors_actor_OBJECTS = executors/actor.$(OBJEXT) +executors_actor_OBJECTS = $(am_executors_actor_OBJECTS) +executors_actor_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_actor_DEPENDENCIES = libasio.a +am_executors_async_1_OBJECTS = executors/async_1.$(OBJEXT) +executors_async_1_OBJECTS = $(am_executors_async_1_OBJECTS) +executors_async_1_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_async_1_DEPENDENCIES = libasio.a +am_executors_async_2_OBJECTS = executors/async_2.$(OBJEXT) +executors_async_2_OBJECTS = $(am_executors_async_2_OBJECTS) +executors_async_2_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_async_2_DEPENDENCIES = libasio.a +am_executors_bank_account_1_OBJECTS = \ + executors/bank_account_1.$(OBJEXT) +executors_bank_account_1_OBJECTS = \ + $(am_executors_bank_account_1_OBJECTS) +executors_bank_account_1_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_bank_account_1_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_executors_bank_account_2_OBJECTS = \ + executors/bank_account_2.$(OBJEXT) +executors_bank_account_2_OBJECTS = \ + $(am_executors_bank_account_2_OBJECTS) +executors_bank_account_2_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_bank_account_2_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_executors_fork_join_OBJECTS = executors/fork_join.$(OBJEXT) +executors_fork_join_OBJECTS = $(am_executors_fork_join_OBJECTS) +executors_fork_join_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_fork_join_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_executors_pipeline_OBJECTS = executors/pipeline.$(OBJEXT) +executors_pipeline_OBJECTS = $(am_executors_pipeline_OBJECTS) +executors_pipeline_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_pipeline_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_executors_priority_scheduler_OBJECTS = \ + executors/priority_scheduler.$(OBJEXT) +executors_priority_scheduler_OBJECTS = \ + $(am_executors_priority_scheduler_OBJECTS) +executors_priority_scheduler_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@executors_priority_scheduler_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_iostreams_http_client_OBJECTS = iostreams/http_client.$(OBJEXT) +iostreams_http_client_OBJECTS = $(am_iostreams_http_client_OBJECTS) +iostreams_http_client_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@iostreams_http_client_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_c_callback_wrapper_OBJECTS = \ + operations/c_callback_wrapper.$(OBJEXT) +operations_c_callback_wrapper_OBJECTS = \ + $(am_operations_c_callback_wrapper_OBJECTS) +operations_c_callback_wrapper_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_c_callback_wrapper_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_callback_wrapper_OBJECTS = \ + operations/callback_wrapper.$(OBJEXT) +operations_callback_wrapper_OBJECTS = \ + $(am_operations_callback_wrapper_OBJECTS) +operations_callback_wrapper_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_callback_wrapper_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_1_OBJECTS = operations/composed_1.$(OBJEXT) +operations_composed_1_OBJECTS = $(am_operations_composed_1_OBJECTS) +operations_composed_1_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_1_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_2_OBJECTS = operations/composed_2.$(OBJEXT) +operations_composed_2_OBJECTS = $(am_operations_composed_2_OBJECTS) +operations_composed_2_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_2_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_3_OBJECTS = operations/composed_3.$(OBJEXT) +operations_composed_3_OBJECTS = $(am_operations_composed_3_OBJECTS) +operations_composed_3_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_3_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_4_OBJECTS = operations/composed_4.$(OBJEXT) +operations_composed_4_OBJECTS = $(am_operations_composed_4_OBJECTS) +operations_composed_4_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_4_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_5_OBJECTS = operations/composed_5.$(OBJEXT) +operations_composed_5_OBJECTS = $(am_operations_composed_5_OBJECTS) +operations_composed_5_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_5_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_6_OBJECTS = operations/composed_6.$(OBJEXT) +operations_composed_6_OBJECTS = $(am_operations_composed_6_OBJECTS) +operations_composed_6_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_6_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_7_OBJECTS = operations/composed_7.$(OBJEXT) +operations_composed_7_OBJECTS = $(am_operations_composed_7_OBJECTS) +operations_composed_7_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_7_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_8_OBJECTS = operations/composed_8.$(OBJEXT) +operations_composed_8_OBJECTS = $(am_operations_composed_8_OBJECTS) +operations_composed_8_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_8_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_parallel_group_parallel_sort_OBJECTS = \ + parallel_group/parallel_sort.$(OBJEXT) +parallel_group_parallel_sort_OBJECTS = \ + $(am_parallel_group_parallel_sort_OBJECTS) +parallel_group_parallel_sort_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@parallel_group_parallel_sort_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_parallel_group_ranged_wait_for_all_OBJECTS = \ + parallel_group/ranged_wait_for_all.$(OBJEXT) +parallel_group_ranged_wait_for_all_OBJECTS = \ + $(am_parallel_group_ranged_wait_for_all_OBJECTS) +parallel_group_ranged_wait_for_all_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@parallel_group_ranged_wait_for_all_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_parallel_group_wait_for_all_OBJECTS = \ + parallel_group/wait_for_all.$(OBJEXT) +parallel_group_wait_for_all_OBJECTS = \ + $(am_parallel_group_wait_for_all_OBJECTS) +parallel_group_wait_for_all_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@parallel_group_wait_for_all_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_parallel_group_wait_for_one_OBJECTS = \ + parallel_group/wait_for_one.$(OBJEXT) +parallel_group_wait_for_one_OBJECTS = \ + $(am_parallel_group_wait_for_one_OBJECTS) +parallel_group_wait_for_one_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@parallel_group_wait_for_one_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_parallel_group_wait_for_one_error_OBJECTS = \ + parallel_group/wait_for_one_error.$(OBJEXT) +parallel_group_wait_for_one_error_OBJECTS = \ + $(am_parallel_group_wait_for_one_error_OBJECTS) +parallel_group_wait_for_one_error_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@parallel_group_wait_for_one_error_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_parallel_group_wait_for_one_success_OBJECTS = \ + parallel_group/wait_for_one_success.$(OBJEXT) +parallel_group_wait_for_one_success_OBJECTS = \ + $(am_parallel_group_wait_for_one_success_OBJECTS) +parallel_group_wait_for_one_success_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@parallel_group_wait_for_one_success_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ../../$(DEPDIR)/asio.Po \ + ../../$(DEPDIR)/asio_ssl.Po deferred/$(DEPDIR)/deferred_1.Po \ + deferred/$(DEPDIR)/deferred_2.Po \ + deferred/$(DEPDIR)/deferred_3.Po \ + deferred/$(DEPDIR)/deferred_4.Po \ + deferred/$(DEPDIR)/deferred_5.Po \ + deferred/$(DEPDIR)/deferred_6.Po \ + deferred/$(DEPDIR)/deferred_7.Po \ + echo/$(DEPDIR)/async_tcp_echo_server.Po \ + echo/$(DEPDIR)/async_udp_echo_server.Po \ + echo/$(DEPDIR)/blocking_tcp_echo_client.Po \ + echo/$(DEPDIR)/blocking_tcp_echo_server.Po \ + echo/$(DEPDIR)/blocking_udp_echo_client.Po \ + echo/$(DEPDIR)/blocking_udp_echo_server.Po \ + executors/$(DEPDIR)/actor.Po executors/$(DEPDIR)/async_1.Po \ + executors/$(DEPDIR)/async_2.Po \ + executors/$(DEPDIR)/bank_account_1.Po \ + executors/$(DEPDIR)/bank_account_2.Po \ + executors/$(DEPDIR)/fork_join.Po \ + executors/$(DEPDIR)/pipeline.Po \ + executors/$(DEPDIR)/priority_scheduler.Po \ + iostreams/$(DEPDIR)/http_client.Po \ + operations/$(DEPDIR)/c_callback_wrapper.Po \ + operations/$(DEPDIR)/callback_wrapper.Po \ + operations/$(DEPDIR)/composed_1.Po \ + operations/$(DEPDIR)/composed_2.Po \ + operations/$(DEPDIR)/composed_3.Po \ + operations/$(DEPDIR)/composed_4.Po \ + operations/$(DEPDIR)/composed_5.Po \ + operations/$(DEPDIR)/composed_6.Po \ + operations/$(DEPDIR)/composed_7.Po \ + operations/$(DEPDIR)/composed_8.Po \ + parallel_group/$(DEPDIR)/parallel_sort.Po \ + parallel_group/$(DEPDIR)/ranged_wait_for_all.Po \ + parallel_group/$(DEPDIR)/wait_for_all.Po \ + parallel_group/$(DEPDIR)/wait_for_one.Po \ + parallel_group/$(DEPDIR)/wait_for_one_error.Po \ + parallel_group/$(DEPDIR)/wait_for_one_success.Po +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(libasio_a_SOURCES) $(deferred_deferred_1_SOURCES) \ + $(deferred_deferred_2_SOURCES) $(deferred_deferred_3_SOURCES) \ + $(deferred_deferred_4_SOURCES) $(deferred_deferred_5_SOURCES) \ + $(deferred_deferred_6_SOURCES) $(deferred_deferred_7_SOURCES) \ + $(echo_async_tcp_echo_server_SOURCES) \ + $(echo_async_udp_echo_server_SOURCES) \ + $(echo_blocking_tcp_echo_client_SOURCES) \ + $(echo_blocking_tcp_echo_server_SOURCES) \ + $(echo_blocking_udp_echo_client_SOURCES) \ + $(echo_blocking_udp_echo_server_SOURCES) \ + $(executors_actor_SOURCES) $(executors_async_1_SOURCES) \ + $(executors_async_2_SOURCES) \ + $(executors_bank_account_1_SOURCES) \ + $(executors_bank_account_2_SOURCES) \ + $(executors_fork_join_SOURCES) $(executors_pipeline_SOURCES) \ + $(executors_priority_scheduler_SOURCES) \ + $(iostreams_http_client_SOURCES) \ + $(operations_c_callback_wrapper_SOURCES) \ + $(operations_callback_wrapper_SOURCES) \ + $(operations_composed_1_SOURCES) \ + $(operations_composed_2_SOURCES) \ + $(operations_composed_3_SOURCES) \ + $(operations_composed_4_SOURCES) \ + $(operations_composed_5_SOURCES) \ + $(operations_composed_6_SOURCES) \ + $(operations_composed_7_SOURCES) \ + $(operations_composed_8_SOURCES) \ + $(parallel_group_parallel_sort_SOURCES) \ + $(parallel_group_ranged_wait_for_all_SOURCES) \ + $(parallel_group_wait_for_all_SOURCES) \ + $(parallel_group_wait_for_one_SOURCES) \ + $(parallel_group_wait_for_one_error_SOURCES) \ + $(parallel_group_wait_for_one_success_SOURCES) +DIST_SOURCES = $(am__libasio_a_SOURCES_DIST) \ + $(deferred_deferred_1_SOURCES) $(deferred_deferred_2_SOURCES) \ + $(deferred_deferred_3_SOURCES) $(deferred_deferred_4_SOURCES) \ + $(deferred_deferred_5_SOURCES) $(deferred_deferred_6_SOURCES) \ + $(deferred_deferred_7_SOURCES) \ + $(echo_async_tcp_echo_server_SOURCES) \ + $(echo_async_udp_echo_server_SOURCES) \ + $(echo_blocking_tcp_echo_client_SOURCES) \ + $(echo_blocking_tcp_echo_server_SOURCES) \ + $(echo_blocking_udp_echo_client_SOURCES) \ + $(echo_blocking_udp_echo_server_SOURCES) \ + $(executors_actor_SOURCES) $(executors_async_1_SOURCES) \ + $(executors_async_2_SOURCES) \ + $(executors_bank_account_1_SOURCES) \ + $(executors_bank_account_2_SOURCES) \ + $(executors_fork_join_SOURCES) $(executors_pipeline_SOURCES) \ + $(executors_priority_scheduler_SOURCES) \ + $(iostreams_http_client_SOURCES) \ + $(operations_c_callback_wrapper_SOURCES) \ + $(operations_callback_wrapper_SOURCES) \ + $(operations_composed_1_SOURCES) \ + $(operations_composed_2_SOURCES) \ + $(operations_composed_3_SOURCES) \ + $(operations_composed_4_SOURCES) \ + $(operations_composed_5_SOURCES) \ + $(operations_composed_6_SOURCES) \ + $(operations_composed_7_SOURCES) \ + $(operations_composed_8_SOURCES) \ + $(parallel_group_parallel_sort_SOURCES) \ + $(parallel_group_ranged_wait_for_all_SOURCES) \ + $(parallel_group_wait_for_all_SOURCES) \ + $(parallel_group_wait_for_one_SOURCES) \ + $(parallel_group_wait_for_one_error_SOURCES) \ + $(parallel_group_wait_for_one_success_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +ETAGS = @ETAGS@ +EXEEXT = @EXEEXT@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfigdir = @pkgconfigdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = subdir-objects +@SEPARATE_COMPILATION_TRUE@noinst_LIBRARIES = libasio.a +@SEPARATE_COMPILATION_TRUE@libasio_a_SOURCES = ../../asio.cpp \ +@SEPARATE_COMPILATION_TRUE@ $(am__append_1) +@SEPARATE_COMPILATION_TRUE@LDADD = libasio.a +AM_CXXFLAGS = -I$(srcdir)/../../../include +deferred_deferred_1_SOURCES = deferred/deferred_1.cpp +deferred_deferred_2_SOURCES = deferred/deferred_2.cpp +deferred_deferred_3_SOURCES = deferred/deferred_3.cpp +deferred_deferred_4_SOURCES = deferred/deferred_4.cpp +deferred_deferred_5_SOURCES = deferred/deferred_5.cpp +deferred_deferred_6_SOURCES = deferred/deferred_6.cpp +deferred_deferred_7_SOURCES = deferred/deferred_7.cpp +echo_async_tcp_echo_server_SOURCES = echo/async_tcp_echo_server.cpp +echo_async_udp_echo_server_SOURCES = echo/async_udp_echo_server.cpp +echo_blocking_tcp_echo_client_SOURCES = echo/blocking_tcp_echo_client.cpp +echo_blocking_tcp_echo_server_SOURCES = echo/blocking_tcp_echo_server.cpp +echo_blocking_udp_echo_client_SOURCES = echo/blocking_udp_echo_client.cpp +echo_blocking_udp_echo_server_SOURCES = echo/blocking_udp_echo_server.cpp +executors_actor_SOURCES = executors/actor.cpp +executors_async_1_SOURCES = executors/async_1.cpp +executors_async_2_SOURCES = executors/async_2.cpp +executors_bank_account_1_SOURCES = executors/bank_account_1.cpp +executors_bank_account_2_SOURCES = executors/bank_account_2.cpp +executors_fork_join_SOURCES = executors/fork_join.cpp +executors_pipeline_SOURCES = executors/pipeline.cpp +executors_priority_scheduler_SOURCES = executors/priority_scheduler.cpp +iostreams_http_client_SOURCES = iostreams/http_client.cpp +operations_c_callback_wrapper_SOURCES = operations/c_callback_wrapper.cpp +operations_callback_wrapper_SOURCES = operations/callback_wrapper.cpp +operations_composed_1_SOURCES = operations/composed_1.cpp +operations_composed_2_SOURCES = operations/composed_2.cpp +operations_composed_3_SOURCES = operations/composed_3.cpp +operations_composed_4_SOURCES = operations/composed_4.cpp +operations_composed_5_SOURCES = operations/composed_5.cpp +operations_composed_6_SOURCES = operations/composed_6.cpp +operations_composed_7_SOURCES = operations/composed_7.cpp +operations_composed_8_SOURCES = operations/composed_8.cpp +parallel_group_parallel_sort_SOURCES = parallel_group/parallel_sort.cpp +parallel_group_ranged_wait_for_all_SOURCES = parallel_group/ranged_wait_for_all.cpp +parallel_group_wait_for_all_SOURCES = parallel_group/wait_for_all.cpp +parallel_group_wait_for_one_SOURCES = parallel_group/wait_for_one.cpp +parallel_group_wait_for_one_error_SOURCES = parallel_group/wait_for_one_error.cpp +parallel_group_wait_for_one_success_SOURCES = parallel_group/wait_for_one_success.cpp +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/examples/cpp14/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/examples/cpp14/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +../../$(am__dirstamp): + @$(MKDIR_P) ../.. + @: > ../../$(am__dirstamp) +../../$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) ../../$(DEPDIR) + @: > ../../$(DEPDIR)/$(am__dirstamp) +../../asio.$(OBJEXT): ../../$(am__dirstamp) \ + ../../$(DEPDIR)/$(am__dirstamp) +../../asio_ssl.$(OBJEXT): ../../$(am__dirstamp) \ + ../../$(DEPDIR)/$(am__dirstamp) + +libasio.a: $(libasio_a_OBJECTS) $(libasio_a_DEPENDENCIES) $(EXTRA_libasio_a_DEPENDENCIES) + $(AM_V_at)-rm -f libasio.a + $(AM_V_AR)$(libasio_a_AR) libasio.a $(libasio_a_OBJECTS) $(libasio_a_LIBADD) + $(AM_V_at)$(RANLIB) libasio.a +deferred/$(am__dirstamp): + @$(MKDIR_P) deferred + @: > deferred/$(am__dirstamp) +deferred/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) deferred/$(DEPDIR) + @: > deferred/$(DEPDIR)/$(am__dirstamp) +deferred/deferred_1.$(OBJEXT): deferred/$(am__dirstamp) \ + deferred/$(DEPDIR)/$(am__dirstamp) + +deferred/deferred_1$(EXEEXT): $(deferred_deferred_1_OBJECTS) $(deferred_deferred_1_DEPENDENCIES) $(EXTRA_deferred_deferred_1_DEPENDENCIES) deferred/$(am__dirstamp) + @rm -f deferred/deferred_1$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(deferred_deferred_1_OBJECTS) $(deferred_deferred_1_LDADD) $(LIBS) +deferred/deferred_2.$(OBJEXT): deferred/$(am__dirstamp) \ + deferred/$(DEPDIR)/$(am__dirstamp) + +deferred/deferred_2$(EXEEXT): $(deferred_deferred_2_OBJECTS) $(deferred_deferred_2_DEPENDENCIES) $(EXTRA_deferred_deferred_2_DEPENDENCIES) deferred/$(am__dirstamp) + @rm -f deferred/deferred_2$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(deferred_deferred_2_OBJECTS) $(deferred_deferred_2_LDADD) $(LIBS) +deferred/deferred_3.$(OBJEXT): deferred/$(am__dirstamp) \ + deferred/$(DEPDIR)/$(am__dirstamp) + +deferred/deferred_3$(EXEEXT): $(deferred_deferred_3_OBJECTS) $(deferred_deferred_3_DEPENDENCIES) $(EXTRA_deferred_deferred_3_DEPENDENCIES) deferred/$(am__dirstamp) + @rm -f deferred/deferred_3$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(deferred_deferred_3_OBJECTS) $(deferred_deferred_3_LDADD) $(LIBS) +deferred/deferred_4.$(OBJEXT): deferred/$(am__dirstamp) \ + deferred/$(DEPDIR)/$(am__dirstamp) + +deferred/deferred_4$(EXEEXT): $(deferred_deferred_4_OBJECTS) $(deferred_deferred_4_DEPENDENCIES) $(EXTRA_deferred_deferred_4_DEPENDENCIES) deferred/$(am__dirstamp) + @rm -f deferred/deferred_4$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(deferred_deferred_4_OBJECTS) $(deferred_deferred_4_LDADD) $(LIBS) +deferred/deferred_5.$(OBJEXT): deferred/$(am__dirstamp) \ + deferred/$(DEPDIR)/$(am__dirstamp) + +deferred/deferred_5$(EXEEXT): $(deferred_deferred_5_OBJECTS) $(deferred_deferred_5_DEPENDENCIES) $(EXTRA_deferred_deferred_5_DEPENDENCIES) deferred/$(am__dirstamp) + @rm -f deferred/deferred_5$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(deferred_deferred_5_OBJECTS) $(deferred_deferred_5_LDADD) $(LIBS) +deferred/deferred_6.$(OBJEXT): deferred/$(am__dirstamp) \ + deferred/$(DEPDIR)/$(am__dirstamp) + +deferred/deferred_6$(EXEEXT): $(deferred_deferred_6_OBJECTS) $(deferred_deferred_6_DEPENDENCIES) $(EXTRA_deferred_deferred_6_DEPENDENCIES) deferred/$(am__dirstamp) + @rm -f deferred/deferred_6$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(deferred_deferred_6_OBJECTS) $(deferred_deferred_6_LDADD) $(LIBS) +deferred/deferred_7.$(OBJEXT): deferred/$(am__dirstamp) \ + deferred/$(DEPDIR)/$(am__dirstamp) + +deferred/deferred_7$(EXEEXT): $(deferred_deferred_7_OBJECTS) $(deferred_deferred_7_DEPENDENCIES) $(EXTRA_deferred_deferred_7_DEPENDENCIES) deferred/$(am__dirstamp) + @rm -f deferred/deferred_7$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(deferred_deferred_7_OBJECTS) $(deferred_deferred_7_LDADD) $(LIBS) +echo/$(am__dirstamp): + @$(MKDIR_P) echo + @: > echo/$(am__dirstamp) +echo/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) echo/$(DEPDIR) + @: > echo/$(DEPDIR)/$(am__dirstamp) +echo/async_tcp_echo_server.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/async_tcp_echo_server$(EXEEXT): $(echo_async_tcp_echo_server_OBJECTS) $(echo_async_tcp_echo_server_DEPENDENCIES) $(EXTRA_echo_async_tcp_echo_server_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/async_tcp_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_async_tcp_echo_server_OBJECTS) $(echo_async_tcp_echo_server_LDADD) $(LIBS) +echo/async_udp_echo_server.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/async_udp_echo_server$(EXEEXT): $(echo_async_udp_echo_server_OBJECTS) $(echo_async_udp_echo_server_DEPENDENCIES) $(EXTRA_echo_async_udp_echo_server_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/async_udp_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_async_udp_echo_server_OBJECTS) $(echo_async_udp_echo_server_LDADD) $(LIBS) +echo/blocking_tcp_echo_client.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/blocking_tcp_echo_client$(EXEEXT): $(echo_blocking_tcp_echo_client_OBJECTS) $(echo_blocking_tcp_echo_client_DEPENDENCIES) $(EXTRA_echo_blocking_tcp_echo_client_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/blocking_tcp_echo_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_blocking_tcp_echo_client_OBJECTS) $(echo_blocking_tcp_echo_client_LDADD) $(LIBS) +echo/blocking_tcp_echo_server.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/blocking_tcp_echo_server$(EXEEXT): $(echo_blocking_tcp_echo_server_OBJECTS) $(echo_blocking_tcp_echo_server_DEPENDENCIES) $(EXTRA_echo_blocking_tcp_echo_server_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/blocking_tcp_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_blocking_tcp_echo_server_OBJECTS) $(echo_blocking_tcp_echo_server_LDADD) $(LIBS) +echo/blocking_udp_echo_client.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/blocking_udp_echo_client$(EXEEXT): $(echo_blocking_udp_echo_client_OBJECTS) $(echo_blocking_udp_echo_client_DEPENDENCIES) $(EXTRA_echo_blocking_udp_echo_client_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/blocking_udp_echo_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_blocking_udp_echo_client_OBJECTS) $(echo_blocking_udp_echo_client_LDADD) $(LIBS) +echo/blocking_udp_echo_server.$(OBJEXT): echo/$(am__dirstamp) \ + echo/$(DEPDIR)/$(am__dirstamp) + +echo/blocking_udp_echo_server$(EXEEXT): $(echo_blocking_udp_echo_server_OBJECTS) $(echo_blocking_udp_echo_server_DEPENDENCIES) $(EXTRA_echo_blocking_udp_echo_server_DEPENDENCIES) echo/$(am__dirstamp) + @rm -f echo/blocking_udp_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(echo_blocking_udp_echo_server_OBJECTS) $(echo_blocking_udp_echo_server_LDADD) $(LIBS) +executors/$(am__dirstamp): + @$(MKDIR_P) executors + @: > executors/$(am__dirstamp) +executors/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) executors/$(DEPDIR) + @: > executors/$(DEPDIR)/$(am__dirstamp) +executors/actor.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/actor$(EXEEXT): $(executors_actor_OBJECTS) $(executors_actor_DEPENDENCIES) $(EXTRA_executors_actor_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/actor$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_actor_OBJECTS) $(executors_actor_LDADD) $(LIBS) +executors/async_1.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/async_1$(EXEEXT): $(executors_async_1_OBJECTS) $(executors_async_1_DEPENDENCIES) $(EXTRA_executors_async_1_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/async_1$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_async_1_OBJECTS) $(executors_async_1_LDADD) $(LIBS) +executors/async_2.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/async_2$(EXEEXT): $(executors_async_2_OBJECTS) $(executors_async_2_DEPENDENCIES) $(EXTRA_executors_async_2_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/async_2$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_async_2_OBJECTS) $(executors_async_2_LDADD) $(LIBS) +executors/bank_account_1.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/bank_account_1$(EXEEXT): $(executors_bank_account_1_OBJECTS) $(executors_bank_account_1_DEPENDENCIES) $(EXTRA_executors_bank_account_1_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/bank_account_1$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_bank_account_1_OBJECTS) $(executors_bank_account_1_LDADD) $(LIBS) +executors/bank_account_2.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/bank_account_2$(EXEEXT): $(executors_bank_account_2_OBJECTS) $(executors_bank_account_2_DEPENDENCIES) $(EXTRA_executors_bank_account_2_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/bank_account_2$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_bank_account_2_OBJECTS) $(executors_bank_account_2_LDADD) $(LIBS) +executors/fork_join.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/fork_join$(EXEEXT): $(executors_fork_join_OBJECTS) $(executors_fork_join_DEPENDENCIES) $(EXTRA_executors_fork_join_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/fork_join$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_fork_join_OBJECTS) $(executors_fork_join_LDADD) $(LIBS) +executors/pipeline.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/pipeline$(EXEEXT): $(executors_pipeline_OBJECTS) $(executors_pipeline_DEPENDENCIES) $(EXTRA_executors_pipeline_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/pipeline$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_pipeline_OBJECTS) $(executors_pipeline_LDADD) $(LIBS) +executors/priority_scheduler.$(OBJEXT): executors/$(am__dirstamp) \ + executors/$(DEPDIR)/$(am__dirstamp) + +executors/priority_scheduler$(EXEEXT): $(executors_priority_scheduler_OBJECTS) $(executors_priority_scheduler_DEPENDENCIES) $(EXTRA_executors_priority_scheduler_DEPENDENCIES) executors/$(am__dirstamp) + @rm -f executors/priority_scheduler$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(executors_priority_scheduler_OBJECTS) $(executors_priority_scheduler_LDADD) $(LIBS) +iostreams/$(am__dirstamp): + @$(MKDIR_P) iostreams + @: > iostreams/$(am__dirstamp) +iostreams/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) iostreams/$(DEPDIR) + @: > iostreams/$(DEPDIR)/$(am__dirstamp) +iostreams/http_client.$(OBJEXT): iostreams/$(am__dirstamp) \ + iostreams/$(DEPDIR)/$(am__dirstamp) + +iostreams/http_client$(EXEEXT): $(iostreams_http_client_OBJECTS) $(iostreams_http_client_DEPENDENCIES) $(EXTRA_iostreams_http_client_DEPENDENCIES) iostreams/$(am__dirstamp) + @rm -f iostreams/http_client$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(iostreams_http_client_OBJECTS) $(iostreams_http_client_LDADD) $(LIBS) +operations/$(am__dirstamp): + @$(MKDIR_P) operations + @: > operations/$(am__dirstamp) +operations/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) operations/$(DEPDIR) + @: > operations/$(DEPDIR)/$(am__dirstamp) +operations/c_callback_wrapper.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/c_callback_wrapper$(EXEEXT): $(operations_c_callback_wrapper_OBJECTS) $(operations_c_callback_wrapper_DEPENDENCIES) $(EXTRA_operations_c_callback_wrapper_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/c_callback_wrapper$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_c_callback_wrapper_OBJECTS) $(operations_c_callback_wrapper_LDADD) $(LIBS) +operations/callback_wrapper.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/callback_wrapper$(EXEEXT): $(operations_callback_wrapper_OBJECTS) $(operations_callback_wrapper_DEPENDENCIES) $(EXTRA_operations_callback_wrapper_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/callback_wrapper$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_callback_wrapper_OBJECTS) $(operations_callback_wrapper_LDADD) $(LIBS) +operations/composed_1.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_1$(EXEEXT): $(operations_composed_1_OBJECTS) $(operations_composed_1_DEPENDENCIES) $(EXTRA_operations_composed_1_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_1$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_1_OBJECTS) $(operations_composed_1_LDADD) $(LIBS) +operations/composed_2.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_2$(EXEEXT): $(operations_composed_2_OBJECTS) $(operations_composed_2_DEPENDENCIES) $(EXTRA_operations_composed_2_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_2$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_2_OBJECTS) $(operations_composed_2_LDADD) $(LIBS) +operations/composed_3.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_3$(EXEEXT): $(operations_composed_3_OBJECTS) $(operations_composed_3_DEPENDENCIES) $(EXTRA_operations_composed_3_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_3$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_3_OBJECTS) $(operations_composed_3_LDADD) $(LIBS) +operations/composed_4.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_4$(EXEEXT): $(operations_composed_4_OBJECTS) $(operations_composed_4_DEPENDENCIES) $(EXTRA_operations_composed_4_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_4$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_4_OBJECTS) $(operations_composed_4_LDADD) $(LIBS) +operations/composed_5.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_5$(EXEEXT): $(operations_composed_5_OBJECTS) $(operations_composed_5_DEPENDENCIES) $(EXTRA_operations_composed_5_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_5$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_5_OBJECTS) $(operations_composed_5_LDADD) $(LIBS) +operations/composed_6.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_6$(EXEEXT): $(operations_composed_6_OBJECTS) $(operations_composed_6_DEPENDENCIES) $(EXTRA_operations_composed_6_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_6$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_6_OBJECTS) $(operations_composed_6_LDADD) $(LIBS) +operations/composed_7.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_7$(EXEEXT): $(operations_composed_7_OBJECTS) $(operations_composed_7_DEPENDENCIES) $(EXTRA_operations_composed_7_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_7$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_7_OBJECTS) $(operations_composed_7_LDADD) $(LIBS) +operations/composed_8.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_8$(EXEEXT): $(operations_composed_8_OBJECTS) $(operations_composed_8_DEPENDENCIES) $(EXTRA_operations_composed_8_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_8$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_8_OBJECTS) $(operations_composed_8_LDADD) $(LIBS) +parallel_group/$(am__dirstamp): + @$(MKDIR_P) parallel_group + @: > parallel_group/$(am__dirstamp) +parallel_group/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) parallel_group/$(DEPDIR) + @: > parallel_group/$(DEPDIR)/$(am__dirstamp) +parallel_group/parallel_sort.$(OBJEXT): \ + parallel_group/$(am__dirstamp) \ + parallel_group/$(DEPDIR)/$(am__dirstamp) + +parallel_group/parallel_sort$(EXEEXT): $(parallel_group_parallel_sort_OBJECTS) $(parallel_group_parallel_sort_DEPENDENCIES) $(EXTRA_parallel_group_parallel_sort_DEPENDENCIES) parallel_group/$(am__dirstamp) + @rm -f parallel_group/parallel_sort$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(parallel_group_parallel_sort_OBJECTS) $(parallel_group_parallel_sort_LDADD) $(LIBS) +parallel_group/ranged_wait_for_all.$(OBJEXT): \ + parallel_group/$(am__dirstamp) \ + parallel_group/$(DEPDIR)/$(am__dirstamp) + +parallel_group/ranged_wait_for_all$(EXEEXT): $(parallel_group_ranged_wait_for_all_OBJECTS) $(parallel_group_ranged_wait_for_all_DEPENDENCIES) $(EXTRA_parallel_group_ranged_wait_for_all_DEPENDENCIES) parallel_group/$(am__dirstamp) + @rm -f parallel_group/ranged_wait_for_all$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(parallel_group_ranged_wait_for_all_OBJECTS) $(parallel_group_ranged_wait_for_all_LDADD) $(LIBS) +parallel_group/wait_for_all.$(OBJEXT): parallel_group/$(am__dirstamp) \ + parallel_group/$(DEPDIR)/$(am__dirstamp) + +parallel_group/wait_for_all$(EXEEXT): $(parallel_group_wait_for_all_OBJECTS) $(parallel_group_wait_for_all_DEPENDENCIES) $(EXTRA_parallel_group_wait_for_all_DEPENDENCIES) parallel_group/$(am__dirstamp) + @rm -f parallel_group/wait_for_all$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(parallel_group_wait_for_all_OBJECTS) $(parallel_group_wait_for_all_LDADD) $(LIBS) +parallel_group/wait_for_one.$(OBJEXT): parallel_group/$(am__dirstamp) \ + parallel_group/$(DEPDIR)/$(am__dirstamp) + +parallel_group/wait_for_one$(EXEEXT): $(parallel_group_wait_for_one_OBJECTS) $(parallel_group_wait_for_one_DEPENDENCIES) $(EXTRA_parallel_group_wait_for_one_DEPENDENCIES) parallel_group/$(am__dirstamp) + @rm -f parallel_group/wait_for_one$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(parallel_group_wait_for_one_OBJECTS) $(parallel_group_wait_for_one_LDADD) $(LIBS) +parallel_group/wait_for_one_error.$(OBJEXT): \ + parallel_group/$(am__dirstamp) \ + parallel_group/$(DEPDIR)/$(am__dirstamp) + +parallel_group/wait_for_one_error$(EXEEXT): $(parallel_group_wait_for_one_error_OBJECTS) $(parallel_group_wait_for_one_error_DEPENDENCIES) $(EXTRA_parallel_group_wait_for_one_error_DEPENDENCIES) parallel_group/$(am__dirstamp) + @rm -f parallel_group/wait_for_one_error$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(parallel_group_wait_for_one_error_OBJECTS) $(parallel_group_wait_for_one_error_LDADD) $(LIBS) +parallel_group/wait_for_one_success.$(OBJEXT): \ + parallel_group/$(am__dirstamp) \ + parallel_group/$(DEPDIR)/$(am__dirstamp) + +parallel_group/wait_for_one_success$(EXEEXT): $(parallel_group_wait_for_one_success_OBJECTS) $(parallel_group_wait_for_one_success_DEPENDENCIES) $(EXTRA_parallel_group_wait_for_one_success_DEPENDENCIES) parallel_group/$(am__dirstamp) + @rm -f parallel_group/wait_for_one_success$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(parallel_group_wait_for_one_success_OBJECTS) $(parallel_group_wait_for_one_success_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + -rm -f ../../*.$(OBJEXT) + -rm -f deferred/*.$(OBJEXT) + -rm -f echo/*.$(OBJEXT) + -rm -f executors/*.$(OBJEXT) + -rm -f iostreams/*.$(OBJEXT) + -rm -f operations/*.$(OBJEXT) + -rm -f parallel_group/*.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@../../$(DEPDIR)/asio.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@../../$(DEPDIR)/asio_ssl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@deferred/$(DEPDIR)/deferred_1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@deferred/$(DEPDIR)/deferred_2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@deferred/$(DEPDIR)/deferred_3.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@deferred/$(DEPDIR)/deferred_4.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@deferred/$(DEPDIR)/deferred_5.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@deferred/$(DEPDIR)/deferred_6.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@deferred/$(DEPDIR)/deferred_7.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/async_tcp_echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/async_udp_echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/blocking_tcp_echo_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/blocking_tcp_echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/blocking_udp_echo_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@echo/$(DEPDIR)/blocking_udp_echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/actor.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/async_1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/async_2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/bank_account_1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/bank_account_2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/fork_join.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/pipeline.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@executors/$(DEPDIR)/priority_scheduler.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@iostreams/$(DEPDIR)/http_client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/c_callback_wrapper.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/callback_wrapper.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_3.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_4.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_5.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_6.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_7.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_8.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@parallel_group/$(DEPDIR)/parallel_sort.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@parallel_group/$(DEPDIR)/ranged_wait_for_all.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@parallel_group/$(DEPDIR)/wait_for_all.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@parallel_group/$(DEPDIR)/wait_for_one.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@parallel_group/$(DEPDIR)/wait_for_one_error.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@parallel_group/$(DEPDIR)/wait_for_one_success.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f ../../$(DEPDIR)/$(am__dirstamp) + -rm -f ../../$(am__dirstamp) + -rm -f deferred/$(DEPDIR)/$(am__dirstamp) + -rm -f deferred/$(am__dirstamp) + -rm -f echo/$(DEPDIR)/$(am__dirstamp) + -rm -f echo/$(am__dirstamp) + -rm -f executors/$(DEPDIR)/$(am__dirstamp) + -rm -f executors/$(am__dirstamp) + -rm -f iostreams/$(DEPDIR)/$(am__dirstamp) + -rm -f iostreams/$(am__dirstamp) + -rm -f operations/$(DEPDIR)/$(am__dirstamp) + -rm -f operations/$(am__dirstamp) + -rm -f parallel_group/$(DEPDIR)/$(am__dirstamp) + -rm -f parallel_group/$(am__dirstamp) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -f ../../$(DEPDIR)/asio.Po + -rm -f ../../$(DEPDIR)/asio_ssl.Po + -rm -f deferred/$(DEPDIR)/deferred_1.Po + -rm -f deferred/$(DEPDIR)/deferred_2.Po + -rm -f deferred/$(DEPDIR)/deferred_3.Po + -rm -f deferred/$(DEPDIR)/deferred_4.Po + -rm -f deferred/$(DEPDIR)/deferred_5.Po + -rm -f deferred/$(DEPDIR)/deferred_6.Po + -rm -f deferred/$(DEPDIR)/deferred_7.Po + -rm -f echo/$(DEPDIR)/async_tcp_echo_server.Po + -rm -f echo/$(DEPDIR)/async_udp_echo_server.Po + -rm -f echo/$(DEPDIR)/blocking_tcp_echo_client.Po + -rm -f echo/$(DEPDIR)/blocking_tcp_echo_server.Po + -rm -f echo/$(DEPDIR)/blocking_udp_echo_client.Po + -rm -f echo/$(DEPDIR)/blocking_udp_echo_server.Po + -rm -f executors/$(DEPDIR)/actor.Po + -rm -f executors/$(DEPDIR)/async_1.Po + -rm -f executors/$(DEPDIR)/async_2.Po + -rm -f executors/$(DEPDIR)/bank_account_1.Po + -rm -f executors/$(DEPDIR)/bank_account_2.Po + -rm -f executors/$(DEPDIR)/fork_join.Po + -rm -f executors/$(DEPDIR)/pipeline.Po + -rm -f executors/$(DEPDIR)/priority_scheduler.Po + -rm -f iostreams/$(DEPDIR)/http_client.Po + -rm -f operations/$(DEPDIR)/c_callback_wrapper.Po + -rm -f operations/$(DEPDIR)/callback_wrapper.Po + -rm -f operations/$(DEPDIR)/composed_1.Po + -rm -f operations/$(DEPDIR)/composed_2.Po + -rm -f operations/$(DEPDIR)/composed_3.Po + -rm -f operations/$(DEPDIR)/composed_4.Po + -rm -f operations/$(DEPDIR)/composed_5.Po + -rm -f operations/$(DEPDIR)/composed_6.Po + -rm -f operations/$(DEPDIR)/composed_7.Po + -rm -f operations/$(DEPDIR)/composed_8.Po + -rm -f parallel_group/$(DEPDIR)/parallel_sort.Po + -rm -f parallel_group/$(DEPDIR)/ranged_wait_for_all.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_all.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one_error.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one_success.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ../../$(DEPDIR)/asio.Po + -rm -f ../../$(DEPDIR)/asio_ssl.Po + -rm -f deferred/$(DEPDIR)/deferred_1.Po + -rm -f deferred/$(DEPDIR)/deferred_2.Po + -rm -f deferred/$(DEPDIR)/deferred_3.Po + -rm -f deferred/$(DEPDIR)/deferred_4.Po + -rm -f deferred/$(DEPDIR)/deferred_5.Po + -rm -f deferred/$(DEPDIR)/deferred_6.Po + -rm -f deferred/$(DEPDIR)/deferred_7.Po + -rm -f echo/$(DEPDIR)/async_tcp_echo_server.Po + -rm -f echo/$(DEPDIR)/async_udp_echo_server.Po + -rm -f echo/$(DEPDIR)/blocking_tcp_echo_client.Po + -rm -f echo/$(DEPDIR)/blocking_tcp_echo_server.Po + -rm -f echo/$(DEPDIR)/blocking_udp_echo_client.Po + -rm -f echo/$(DEPDIR)/blocking_udp_echo_server.Po + -rm -f executors/$(DEPDIR)/actor.Po + -rm -f executors/$(DEPDIR)/async_1.Po + -rm -f executors/$(DEPDIR)/async_2.Po + -rm -f executors/$(DEPDIR)/bank_account_1.Po + -rm -f executors/$(DEPDIR)/bank_account_2.Po + -rm -f executors/$(DEPDIR)/fork_join.Po + -rm -f executors/$(DEPDIR)/pipeline.Po + -rm -f executors/$(DEPDIR)/priority_scheduler.Po + -rm -f iostreams/$(DEPDIR)/http_client.Po + -rm -f operations/$(DEPDIR)/c_callback_wrapper.Po + -rm -f operations/$(DEPDIR)/callback_wrapper.Po + -rm -f operations/$(DEPDIR)/composed_1.Po + -rm -f operations/$(DEPDIR)/composed_2.Po + -rm -f operations/$(DEPDIR)/composed_3.Po + -rm -f operations/$(DEPDIR)/composed_4.Po + -rm -f operations/$(DEPDIR)/composed_5.Po + -rm -f operations/$(DEPDIR)/composed_6.Po + -rm -f operations/$(DEPDIR)/composed_7.Po + -rm -f operations/$(DEPDIR)/composed_8.Po + -rm -f parallel_group/$(DEPDIR)/parallel_sort.Po + -rm -f parallel_group/$(DEPDIR)/ranged_wait_for_all.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_all.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one_error.Po + -rm -f parallel_group/$(DEPDIR)/wait_for_one_success.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/3rdparty/asio/src/examples/cpp14/deferred/deferred_1.cpp b/3rdparty/asio/src/examples/cpp14/deferred/deferred_1.cpp new file mode 100644 index 00000000000..db9213eb3be --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/deferred/deferred_1.cpp @@ -0,0 +1,35 @@ +// +// deferred_1.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> + +using asio::deferred; + +int main() +{ + asio::io_context ctx; + + asio::steady_timer timer(ctx); + timer.expires_after(std::chrono::seconds(1)); + + auto deferred_op = timer.async_wait(deferred); + + std::move(deferred_op)( + [](std::error_code ec) + { + std::cout << "timer wait finished: " << ec.message() << "\n"; + } + ); + + ctx.run(); + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp14/deferred/deferred_2.cpp b/3rdparty/asio/src/examples/cpp14/deferred/deferred_2.cpp new file mode 100644 index 00000000000..07528282de5 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/deferred/deferred_2.cpp @@ -0,0 +1,44 @@ +// +// deferred_2.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> + +using asio::deferred; + +int main() +{ + asio::io_context ctx; + + asio::steady_timer timer(ctx); + timer.expires_after(std::chrono::seconds(1)); + + auto deferred_op = timer.async_wait( + deferred( + [&](std::error_code ec) + { + std::cout << "first timer wait finished: " << ec.message() << "\n"; + timer.expires_after(std::chrono::seconds(1)); + return timer.async_wait(deferred); + } + ) + ); + + std::move(deferred_op)( + [](std::error_code ec) + { + std::cout << "second timer wait finished: " << ec.message() << "\n"; + } + ); + + ctx.run(); + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp14/deferred/deferred_3.cpp b/3rdparty/asio/src/examples/cpp14/deferred/deferred_3.cpp new file mode 100644 index 00000000000..396e40840a1 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/deferred/deferred_3.cpp @@ -0,0 +1,51 @@ +// +// deferred_3.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> + +using asio::deferred; + +template <typename CompletionToken> +auto async_wait_twice(asio::steady_timer& timer, CompletionToken&& token) +{ + return timer.async_wait( + deferred( + [&](std::error_code ec) + { + std::cout << "first timer wait finished: " << ec.message() << "\n"; + timer.expires_after(std::chrono::seconds(1)); + return timer.async_wait(deferred); + } + ) + )( + std::forward<CompletionToken>(token) + ); +} + +int main() +{ + asio::io_context ctx; + + asio::steady_timer timer(ctx); + timer.expires_after(std::chrono::seconds(1)); + + async_wait_twice( + timer, + [](std::error_code ec) + { + std::cout << "second timer wait finished: " << ec.message() << "\n"; + } + ); + + ctx.run(); + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp14/deferred/deferred_4.cpp b/3rdparty/asio/src/examples/cpp14/deferred/deferred_4.cpp new file mode 100644 index 00000000000..a8ea73336d2 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/deferred/deferred_4.cpp @@ -0,0 +1,59 @@ +// +// deferred_4.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> + +using asio::deferred; + +template <typename CompletionToken> +auto async_wait_twice(asio::steady_timer& timer, CompletionToken&& token) +{ + return timer.async_wait( + deferred( + [&](std::error_code ec) + { + std::cout << "first timer wait finished: " << ec.message() << "\n"; + timer.expires_after(std::chrono::seconds(1)); + return timer.async_wait(deferred); + } + ) + )( + deferred( + [&](std::error_code ec) + { + std::cout << "second timer wait finished: " << ec.message() << "\n"; + return deferred.values(42); + } + ) + )( + std::forward<CompletionToken>(token) + ); +} + +int main() +{ + asio::io_context ctx; + + asio::steady_timer timer(ctx); + timer.expires_after(std::chrono::seconds(1)); + + async_wait_twice( + timer, + [](int result) + { + std::cout << "result is " << result << "\n"; + } + ); + + ctx.run(); + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp14/deferred/deferred_5.cpp b/3rdparty/asio/src/examples/cpp14/deferred/deferred_5.cpp new file mode 100644 index 00000000000..d262b977811 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/deferred/deferred_5.cpp @@ -0,0 +1,66 @@ +// +// deferred_5.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> + +using asio::deferred; + +template <typename CompletionToken> +auto async_wait_twice(asio::steady_timer& timer, CompletionToken&& token) +{ + return timer.async_wait( + deferred( + [&](std::error_code ec) + { + std::cout << "first timer wait finished: " << ec.message() << "\n"; + timer.expires_after(std::chrono::seconds(1)); + return deferred.when(!ec) + .then(timer.async_wait(deferred)) + .otherwise(deferred.values(ec)); + } + ) + )( + deferred( + [&](std::error_code ec) + { + std::cout << "second timer wait finished: " << ec.message() << "\n"; + return deferred.when(!ec) + .then(deferred.values(42)) + .otherwise(deferred.values(0)); + } + ) + )( + std::forward<CompletionToken>(token) + ); +} + +int main() +{ + asio::io_context ctx; + + asio::steady_timer timer(ctx); + timer.expires_after(std::chrono::seconds(1)); + + async_wait_twice( + timer, + [](int result) + { + std::cout << "result is " << result << "\n"; + } + ); + + // Uncomment the following line to trigger an error in async_wait_twice. + //timer.cancel(); + + ctx.run(); + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp14/deferred/deferred_6.cpp b/3rdparty/asio/src/examples/cpp14/deferred/deferred_6.cpp new file mode 100644 index 00000000000..7ccef58cc5c --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/deferred/deferred_6.cpp @@ -0,0 +1,75 @@ +// +// deferred_6.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> + +using asio::append; +using asio::deferred; + +template <typename CompletionToken> +auto async_wait_twice(asio::steady_timer& timer, CompletionToken&& token) +{ + return deferred.values(&timer)( + deferred( + [](asio::steady_timer* timer) + { + timer->expires_after(std::chrono::seconds(1)); + return timer->async_wait(append(deferred, timer)); + } + ) + )( + deferred( + [](std::error_code ec, asio::steady_timer* timer) + { + std::cout << "first timer wait finished: " << ec.message() << "\n"; + timer->expires_after(std::chrono::seconds(1)); + return deferred.when(!ec) + .then(timer->async_wait(deferred)) + .otherwise(deferred.values(ec)); + } + ) + )( + deferred( + [](std::error_code ec) + { + std::cout << "second timer wait finished: " << ec.message() << "\n"; + return deferred.when(!ec) + .then(deferred.values(42)) + .otherwise(deferred.values(0)); + } + ) + )( + std::forward<CompletionToken>(token) + ); +} + +int main() +{ + asio::io_context ctx; + + asio::steady_timer timer(ctx); + timer.expires_after(std::chrono::seconds(1)); + + async_wait_twice( + timer, + [](int result) + { + std::cout << "result is " << result << "\n"; + } + ); + + // Uncomment the following line to trigger an error in async_wait_twice. + //timer.cancel(); + + ctx.run(); + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp14/deferred/deferred_7.cpp b/3rdparty/asio/src/examples/cpp14/deferred/deferred_7.cpp new file mode 100644 index 00000000000..b0734542c79 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/deferred/deferred_7.cpp @@ -0,0 +1,71 @@ +// +// deferred_7.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> + +using asio::append; +using asio::deferred; + +template <typename CompletionToken> +auto async_wait_twice(asio::steady_timer& timer, CompletionToken&& token) +{ + return deferred.values(&timer) + | deferred( + [](asio::steady_timer* timer) + { + timer->expires_after(std::chrono::seconds(1)); + return timer->async_wait(append(deferred, timer)); + } + ) + | deferred( + [](std::error_code ec, asio::steady_timer* timer) + { + std::cout << "first timer wait finished: " << ec.message() << "\n"; + timer->expires_after(std::chrono::seconds(1)); + return deferred.when(!ec) + .then(timer->async_wait(deferred)) + .otherwise(deferred.values(ec)); + } + ) + | deferred( + [](std::error_code ec) + { + std::cout << "second timer wait finished: " << ec.message() << "\n"; + return deferred.when(!ec) + .then(deferred.values(42)) + .otherwise(deferred.values(0)); + } + ) + | std::forward<CompletionToken>(token); +} + +int main() +{ + asio::io_context ctx; + + asio::steady_timer timer(ctx); + timer.expires_after(std::chrono::seconds(1)); + + async_wait_twice( + timer, + [](int result) + { + std::cout << "result is " << result << "\n"; + } + ); + + // Uncomment the following line to trigger an error in async_wait_twice. + //timer.cancel(); + + ctx.run(); + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp14/echo/.gitignore b/3rdparty/asio/src/examples/cpp14/echo/.gitignore deleted file mode 100644 index 0882fa6ced3..00000000000 --- a/3rdparty/asio/src/examples/cpp14/echo/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_server -*_client -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp14/echo/async_tcp_echo_server.cpp b/3rdparty/asio/src/examples/cpp14/echo/async_tcp_echo_server.cpp index c6004c0a0e5..9bd1b727500 100644 --- a/3rdparty/asio/src/examples/cpp14/echo/async_tcp_echo_server.cpp +++ b/3rdparty/asio/src/examples/cpp14/echo/async_tcp_echo_server.cpp @@ -2,7 +2,7 @@ // async_tcp_echo_server.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp14/echo/async_udp_echo_server.cpp b/3rdparty/asio/src/examples/cpp14/echo/async_udp_echo_server.cpp index fee8aed6e66..b059af95b82 100644 --- a/3rdparty/asio/src/examples/cpp14/echo/async_udp_echo_server.cpp +++ b/3rdparty/asio/src/examples/cpp14/echo/async_udp_echo_server.cpp @@ -2,7 +2,7 @@ // async_udp_echo_server.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp14/echo/blocking_tcp_echo_client.cpp b/3rdparty/asio/src/examples/cpp14/echo/blocking_tcp_echo_client.cpp index c7c648df97f..8a281203f89 100644 --- a/3rdparty/asio/src/examples/cpp14/echo/blocking_tcp_echo_client.cpp +++ b/3rdparty/asio/src/examples/cpp14/echo/blocking_tcp_echo_client.cpp @@ -2,7 +2,7 @@ // blocking_tcp_echo_client.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp14/echo/blocking_tcp_echo_server.cpp b/3rdparty/asio/src/examples/cpp14/echo/blocking_tcp_echo_server.cpp index d9a4f075a8d..2116712616a 100644 --- a/3rdparty/asio/src/examples/cpp14/echo/blocking_tcp_echo_server.cpp +++ b/3rdparty/asio/src/examples/cpp14/echo/blocking_tcp_echo_server.cpp @@ -2,7 +2,7 @@ // blocking_tcp_echo_server.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp14/echo/blocking_udp_echo_client.cpp b/3rdparty/asio/src/examples/cpp14/echo/blocking_udp_echo_client.cpp index 603a591f47a..4c8a2849d5b 100644 --- a/3rdparty/asio/src/examples/cpp14/echo/blocking_udp_echo_client.cpp +++ b/3rdparty/asio/src/examples/cpp14/echo/blocking_udp_echo_client.cpp @@ -2,7 +2,7 @@ // blocking_udp_echo_client.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp14/echo/blocking_udp_echo_server.cpp b/3rdparty/asio/src/examples/cpp14/echo/blocking_udp_echo_server.cpp index 646fd136649..c3098bdb8fc 100644 --- a/3rdparty/asio/src/examples/cpp14/echo/blocking_udp_echo_server.cpp +++ b/3rdparty/asio/src/examples/cpp14/echo/blocking_udp_echo_server.cpp @@ -2,7 +2,7 @@ // blocking_udp_echo_server.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp14/executors/.gitignore b/3rdparty/asio/src/examples/cpp14/executors/.gitignore deleted file mode 100644 index d51d7f00295..00000000000 --- a/3rdparty/asio/src/examples/cpp14/executors/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -actor -async_[0-9] -bank_account_[0-9] -fork_join -pipeline -priority_scheduler diff --git a/3rdparty/asio/src/examples/cpp14/executors/actor.cpp b/3rdparty/asio/src/examples/cpp14/executors/actor.cpp index 26d2fb4bf11..a46caf45a68 100644 --- a/3rdparty/asio/src/examples/cpp14/executors/actor.cpp +++ b/3rdparty/asio/src/examples/cpp14/executors/actor.cpp @@ -1,4 +1,8 @@ -#include <asio/ts/executor.hpp> +#include <asio/any_io_executor.hpp> +#include <asio/defer.hpp> +#include <asio/post.hpp> +#include <asio/strand.hpp> +#include <asio/system_executor.hpp> #include <condition_variable> #include <deque> #include <memory> @@ -6,8 +10,8 @@ #include <typeinfo> #include <vector> +using asio::any_io_executor; using asio::defer; -using asio::executor; using asio::post; using asio::strand; using asio::system_executor; @@ -94,7 +98,7 @@ public: { // Execute the message handler in the context of the target's executor. post(to->executor_, - [=, msg=std::move(msg)] + [=, msg=std::move(msg)]() mutable { to->call_handler(std::move(msg), from); }); @@ -102,7 +106,7 @@ public: protected: // Construct the actor to use the specified executor for all message handlers. - actor(executor e) + actor(any_io_executor e) : executor_(std::move(e)) { } @@ -120,7 +124,7 @@ protected: template <class Actor, class Message> void deregister_handler(void (Actor::* mf)(Message, actor_address)) { - const std::type_info& id = typeid(message_handler<Message>); + const std::type_info& id = typeid(Message); for (auto iter = handlers_.begin(); iter != handlers_.end(); ++iter) { if ((*iter)->message_id() == id) @@ -166,7 +170,7 @@ private: // All messages associated with a single actor object should be processed // non-concurrently. We use a strand to ensure non-concurrent execution even // if the underlying executor may use multiple threads. - strand<executor> executor_; + strand<any_io_executor> executor_; std::vector<std::shared_ptr<message_handler_base>> handlers_; }; @@ -216,7 +220,7 @@ using asio::thread_pool; class member : public actor { public: - explicit member(executor e) + explicit member(any_io_executor e) : actor(std::move(e)) { register_handler(&member::init_handler); diff --git a/3rdparty/asio/src/examples/cpp14/executors/async_1.cpp b/3rdparty/asio/src/examples/cpp14/executors/async_1.cpp index d282b74f206..0d1bdfcb8bd 100644 --- a/3rdparty/asio/src/examples/cpp14/executors/async_1.cpp +++ b/3rdparty/asio/src/examples/cpp14/executors/async_1.cpp @@ -1,29 +1,33 @@ -#include <asio/ts/executor.hpp> -#include <asio/thread_pool.hpp> +#include <asio/associated_executor.hpp> +#include <asio/bind_executor.hpp> +#include <asio/execution.hpp> +#include <asio/static_thread_pool.hpp> #include <iostream> #include <string> using asio::bind_executor; -using asio::dispatch; -using asio::make_work_guard; -using asio::post; -using asio::thread_pool; +using asio::get_associated_executor; +using asio::static_thread_pool; +namespace execution = asio::execution; // A function to asynchronously read a single line from an input stream. -template <class Handler> -void async_getline(std::istream& is, Handler handler) +template <class IoExecutor, class Handler> +void async_getline(IoExecutor io_ex, std::istream& is, Handler handler) { - // Create executor_work for the handler's associated executor. - auto work = make_work_guard(handler); + // Track work for the handler's associated executor. + auto work_ex = asio::prefer( + get_associated_executor(handler, io_ex), + execution::outstanding_work.tracked); // Post a function object to do the work asynchronously. - post([&is, work, handler=std::move(handler)]() mutable + asio::require(io_ex, execution::blocking.never).execute( + [&is, work_ex, handler=std::move(handler)]() mutable { std::string line; std::getline(is, line); // Pass the result to the handler, via the associated executor. - dispatch(work.get_executor(), + asio::prefer(work_ex, execution::blocking.possibly).execute( [line=std::move(line), handler=std::move(handler)]() mutable { handler(std::move(line)); @@ -33,15 +37,18 @@ void async_getline(std::istream& is, Handler handler) int main() { - thread_pool pool; + static_thread_pool io_pool(1); + static_thread_pool completion_pool(1); std::cout << "Enter a line: "; - async_getline(std::cin, - bind_executor(pool, [](std::string line) + async_getline(io_pool.executor(), std::cin, + bind_executor(completion_pool.executor(), + [](std::string line) { std::cout << "Line: " << line << "\n"; })); - pool.join(); + io_pool.wait(); + completion_pool.wait(); } diff --git a/3rdparty/asio/src/examples/cpp14/executors/async_2.cpp b/3rdparty/asio/src/examples/cpp14/executors/async_2.cpp index b39156dcb23..ee4a72e80c3 100644 --- a/3rdparty/asio/src/examples/cpp14/executors/async_2.cpp +++ b/3rdparty/asio/src/examples/cpp14/executors/async_2.cpp @@ -1,30 +1,33 @@ -#include <asio/ts/executor.hpp> -#include <asio/thread_pool.hpp> +#include <asio/associated_executor.hpp> +#include <asio/bind_executor.hpp> +#include <asio/execution.hpp> +#include <asio/static_thread_pool.hpp> #include <iostream> #include <string> using asio::bind_executor; -using asio::dispatch; using asio::get_associated_executor; -using asio::make_work_guard; -using asio::post; -using asio::thread_pool; +using asio::static_thread_pool; +namespace execution = asio::execution; // A function to asynchronously read a single line from an input stream. -template <class Handler> -void async_getline(std::istream& is, Handler handler) +template <class IoExecutor, class Handler> +void async_getline(IoExecutor io_ex, std::istream& is, Handler handler) { - // Create executor_work for the handler's associated executor. - auto work = make_work_guard(handler); + // Track work for the handler's associated executor. + auto work_ex = asio::prefer( + get_associated_executor(handler, io_ex), + execution::outstanding_work.tracked); // Post a function object to do the work asynchronously. - post([&is, work, handler=std::move(handler)]() mutable + asio::require(io_ex, execution::blocking.never).execute( + [&is, work_ex, handler=std::move(handler)]() mutable { std::string line; std::getline(is, line); // Pass the result to the handler, via the associated executor. - dispatch(work.get_executor(), + asio::prefer(work_ex, execution::blocking.possibly).execute( [line=std::move(line), handler=std::move(handler)]() mutable { handler(std::move(line)); @@ -33,36 +36,44 @@ void async_getline(std::istream& is, Handler handler) } // A function to asynchronously read multiple lines from an input stream. -template <class Handler> -void async_getlines(std::istream& is, std::string init, Handler handler) +template <class IoExecutor, class Handler> +void async_getlines(IoExecutor io_ex, std::istream& is, std::string init, Handler handler) { - // Get the final handler's associated executor. - auto ex = get_associated_executor(handler); + // Track work for the I/O executor. + auto io_work_ex = asio::prefer(io_ex, + execution::outstanding_work.tracked); + + // Track work for the handler's associated executor. + auto handler_work_ex = asio::prefer( + get_associated_executor(handler, io_ex), + execution::outstanding_work.tracked); // Use the associated executor for each operation in the composition. - async_getline(is, - bind_executor(ex, - [&is, lines=std::move(init), handler=std::move(handler)] + async_getline(io_work_ex, is, + bind_executor(handler_work_ex, + [io_work_ex, &is, lines=std::move(init), handler=std::move(handler)] (std::string line) mutable { if (line.empty()) handler(lines); else - async_getlines(is, lines + line + "\n", std::move(handler)); + async_getlines(io_work_ex, is, lines + line + "\n", std::move(handler)); })); } int main() { - thread_pool pool; + static_thread_pool io_pool(1); + static_thread_pool completion_pool(1); std::cout << "Enter text, terminating with a blank line:\n"; - async_getlines(std::cin, "", - bind_executor(pool, [](std::string lines) + async_getlines(io_pool.executor(), std::cin, "", + bind_executor(completion_pool.executor(), [](std::string lines) { std::cout << "Lines:\n" << lines << "\n"; })); - pool.join(); + io_pool.wait(); + completion_pool.wait(); } diff --git a/3rdparty/asio/src/examples/cpp14/executors/bank_account_1.cpp b/3rdparty/asio/src/examples/cpp14/executors/bank_account_1.cpp index f85a1852b56..a63d7fc059b 100644 --- a/3rdparty/asio/src/examples/cpp14/executors/bank_account_1.cpp +++ b/3rdparty/asio/src/examples/cpp14/executors/bank_account_1.cpp @@ -1,9 +1,9 @@ -#include <asio/ts/executor.hpp> -#include <asio/thread_pool.hpp> +#include <asio/execution.hpp> +#include <asio/static_thread_pool.hpp> #include <iostream> -using asio::post; -using asio::thread_pool; +using asio::static_thread_pool; +namespace execution = asio::execution; // Traditional active object pattern. // Member functions do not block. @@ -11,37 +11,40 @@ using asio::thread_pool; class bank_account { int balance_ = 0; - mutable thread_pool pool_{1}; + mutable static_thread_pool pool_{1}; public: void deposit(int amount) { - post(pool_, [=] - { - balance_ += amount; - }); + pool_.executor().execute( + [this, amount] + { + balance_ += amount; + }); } void withdraw(int amount) { - post(pool_, [=] - { - if (balance_ >= amount) - balance_ -= amount; - }); + pool_.executor().execute( + [this, amount] + { + if (balance_ >= amount) + balance_ -= amount; + }); } void print_balance() const { - post(pool_, [=] - { - std::cout << "balance = " << balance_ << "\n"; - }); + pool_.executor().execute( + [this] + { + std::cout << "balance = " << balance_ << "\n"; + }); } ~bank_account() { - pool_.join(); + pool_.wait(); } }; diff --git a/3rdparty/asio/src/examples/cpp14/executors/bank_account_2.cpp b/3rdparty/asio/src/examples/cpp14/executors/bank_account_2.cpp index 5233e77dec3..c2de05156e8 100644 --- a/3rdparty/asio/src/examples/cpp14/executors/bank_account_2.cpp +++ b/3rdparty/asio/src/examples/cpp14/executors/bank_account_2.cpp @@ -1,10 +1,9 @@ -#include <asio/ts/executor.hpp> -#include <asio/thread_pool.hpp> +#include <asio/execution.hpp> +#include <asio/static_thread_pool.hpp> #include <iostream> -using asio::post; -using asio::thread_pool; -using asio::use_future; +using asio::static_thread_pool; +namespace execution = asio::execution; // Traditional active object pattern. // Member functions block until operation is finished. @@ -12,35 +11,38 @@ using asio::use_future; class bank_account { int balance_ = 0; - mutable thread_pool pool_{1}; + mutable static_thread_pool pool_{1}; public: void deposit(int amount) { - post(pool_, - use_future([=] + asio::require(pool_.executor(), execution::blocking.always).execute( + [this, amount] { balance_ += amount; - })).get(); + }); } void withdraw(int amount) { - post(pool_, - use_future([=] + asio::require(pool_.executor(), + execution::blocking.always).execute( + [this, amount] { if (balance_ >= amount) balance_ -= amount; - })).get(); + }); } int balance() const { - return post(pool_, - use_future([=] + int result = 0; + asio::require(pool_.executor(), execution::blocking.always).execute( + [this, &result] { - return balance_; - })).get(); + result = balance_; + }); + return result; } }; diff --git a/3rdparty/asio/src/examples/cpp14/executors/fork_join.cpp b/3rdparty/asio/src/examples/cpp14/executors/fork_join.cpp index fe6746ad7e0..7e8a827356d 100644 --- a/3rdparty/asio/src/examples/cpp14/executors/fork_join.cpp +++ b/3rdparty/asio/src/examples/cpp14/executors/fork_join.cpp @@ -1,19 +1,20 @@ -#include <asio/ts/executor.hpp> -#include <asio/thread_pool.hpp> +#include <asio/execution.hpp> +#include <asio/static_thread_pool.hpp> +#include <algorithm> #include <condition_variable> #include <memory> #include <mutex> #include <queue> #include <thread> +#include <numeric> -using asio::dispatch; -using asio::execution_context; -using asio::thread_pool; +using asio::static_thread_pool; +namespace execution = asio::execution; // A fixed-size thread pool used to implement fork/join semantics. Functions // are scheduled using a simple FIFO queue. Implementing work stealing, or // using a queue based on atomic operations, are left as tasks for the reader. -class fork_join_pool : public execution_context +class fork_join_pool { public: // The constructor starts a thread pool with the specified number of threads. @@ -21,7 +22,7 @@ public: // Additional threads may temporarily be added to the pool if they join a // fork_executor. explicit fork_join_pool( - std::size_t thread_count = std::thread::hardware_concurrency() * 2) + std::size_t thread_count = std::max(std::thread::hardware_concurrency(), 1u) * 2) : use_count_(1), threads_(thread_count) { @@ -31,7 +32,8 @@ public: // it is time to shut down, i.e. the use count is zero. for (thread_count_ = 0; thread_count_ < thread_count; ++thread_count_) { - dispatch(threads_, [&] + threads_.executor().execute( + [this] { std::unique_lock<std::mutex> lock(mutex_); while (use_count_ > 0) @@ -43,7 +45,7 @@ public: catch (...) { stop_threads(); - threads_.join(); + threads_.wait(); throw; } } @@ -52,7 +54,7 @@ public: ~fork_join_pool() { stop_threads(); - threads_.join(); + threads_.wait(); } private: @@ -116,7 +118,7 @@ private: // Dispatch a function, executing it immediately if the queue is already // loaded. Otherwise adds the function to the queue and wakes a thread. - void do_dispatch(std::shared_ptr<function_base> p, + void do_execute(std::shared_ptr<function_base> p, const std::shared_ptr<std::size_t>& work_count) { std::unique_lock<std::mutex> lock(mutex_); @@ -134,16 +136,6 @@ private: } } - // Add a function to the queue and wake a thread. - void do_post(std::shared_ptr<function_base> p, - const std::shared_ptr<std::size_t>& work_count) - { - std::lock_guard<std::mutex> lock(mutex_); - queue_.push(p); - do_work_started(work_count); - condition_.notify_one(); - } - // Ask all threads to shut down. void stop_threads() { @@ -157,7 +149,7 @@ private: std::queue<std::shared_ptr<function_base>> queue_; std::size_t use_count_; std::size_t thread_count_; - thread_pool threads_; + static_thread_pool threads_; }; // A class that satisfies the Executor requirements. Every function or piece of @@ -171,45 +163,16 @@ public: { } - fork_join_pool& context() const noexcept + fork_join_pool& query(execution::context_t) const noexcept { return context_; } - void on_work_started() const noexcept - { - std::lock_guard<std::mutex> lock(context_.mutex_); - context_.do_work_started(work_count_); - } - - void on_work_finished() const noexcept - { - std::lock_guard<std::mutex> lock(context_.mutex_); - context_.do_work_finished(work_count_); - } - - template <class Func, class Alloc> - void dispatch(Func&& f, const Alloc& a) const - { - auto p(std::allocate_shared<function<Func>>( - typename std::allocator_traits<Alloc>::template rebind_alloc<char>(a), - std::move(f), work_count_)); - context_.do_dispatch(p, work_count_); - } - - template <class Func, class Alloc> - void post(Func f, const Alloc& a) const - { - auto p(std::allocate_shared<function<Func>>( - typename std::allocator_traits<Alloc>::template rebind_alloc<char>(a), - std::move(f), work_count_)); - context_.do_post(p, work_count_); - } - - template <class Func, class Alloc> - void defer(Func&& f, const Alloc& a) const + template <class Func> + void execute(Func f) const { - post(std::forward<Func>(f), a); + auto p(std::make_shared<function<Func>>(std::move(f), work_count_)); + context_.do_execute(p, work_count_); } friend bool operator==(const fork_executor& a, @@ -288,8 +251,8 @@ void fork_join_sort(Iterator begin, Iterator end) { fork_executor fork(pool); join_guard join(fork); - dispatch(fork, [=]{ fork_join_sort(begin, begin + n / 2); }); - dispatch(fork, [=]{ fork_join_sort(begin + n / 2, end); }); + fork.execute([=]{ fork_join_sort(begin, begin + n / 2); }); + fork.execute([=]{ fork_join_sort(begin + n / 2, end); }); } std::inplace_merge(begin, begin + n / 2, end); } diff --git a/3rdparty/asio/src/examples/cpp14/executors/pipeline.cpp b/3rdparty/asio/src/examples/cpp14/executors/pipeline.cpp index c66e283fcbc..9754a27d425 100644 --- a/3rdparty/asio/src/examples/cpp14/executors/pipeline.cpp +++ b/3rdparty/asio/src/examples/cpp14/executors/pipeline.cpp @@ -1,4 +1,6 @@ -#include <asio/ts/executor.hpp> +#include <asio/associated_executor.hpp> +#include <asio/bind_executor.hpp> +#include <asio/execution.hpp> #include <condition_variable> #include <future> #include <memory> @@ -6,30 +8,21 @@ #include <queue> #include <thread> #include <vector> +#include <cctype> -using asio::execution_context; using asio::executor_binder; using asio::get_associated_executor; -using asio::post; -using asio::system_executor; -using asio::use_future; -using asio::use_service; +namespace execution = asio::execution; // An executor that launches a new thread for each function submitted to it. -// This class satisfies the Executor requirements. +// This class satisfies the executor requirements. class thread_executor { private: - // Service to track all threads started through a thread_executor. - class thread_bag : public execution_context::service + // Singleton execution context that manages threads launched by the new_thread_executor. + class thread_bag { - public: - typedef thread_bag key_type; - - explicit thread_bag(execution_context& ctx) - : execution_context::service(ctx) - { - } + friend class thread_executor; void add_thread(std::thread&& t) { @@ -37,8 +30,9 @@ private: threads_.push_back(std::move(t)); } - private: - virtual void shutdown() + thread_bag() = default; + + ~thread_bag() { for (auto& t : threads_) t.join(); @@ -49,40 +43,24 @@ private: }; public: - execution_context& context() const noexcept + static thread_bag& query(execution::context_t) { - return system_executor().context(); + static thread_bag threads; + return threads; } - void on_work_started() const noexcept + static constexpr auto query(execution::blocking_t) { - // This executor doesn't count work. + return execution::blocking.never; } - void on_work_finished() const noexcept + template <class Func> + void execute(Func f) const { - // This executor doesn't count work. - } - - 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&) const - { - thread_bag& bag = use_service<thread_bag>(context()); + thread_bag& bag = query(execution::context); bag.add_thread(std::thread(std::move(f))); } - template <class Func, class Alloc> - void defer(Func&& f, const Alloc& a) const - { - post(std::forward<Func>(f), a); - } - friend bool operator==(const thread_executor&, const thread_executor&) noexcept { @@ -185,7 +163,14 @@ std::future<void> pipeline(queue_back<T> in, F f) // Run the function, and as we're the last stage return a future so that the // caller can wait for the pipeline to finish. - return post(ex, use_future([in, f = std::move(f)]() mutable { f(in); })); + std::packaged_task<void()> task( + [in, f = std::move(f)]() mutable + { + f(in); + }); + std::future<void> fut = task.get_future(); + asio::require(ex, execution::blocking.never).execute(std::move(task)); + return fut; } // Launch an intermediate stage in a pipeline. @@ -204,7 +189,8 @@ std::future<void> pipeline(queue_back<T> in, F f, Tail... t) auto ex = get_associated_executor(f, thread_executor()); // Run the function. - post(ex, [in, out, f = std::move(f)]() mutable + asio::require(ex, execution::blocking.never).execute( + [in, out, f = std::move(f)]() mutable { f(in, out); out.stop(); @@ -230,7 +216,8 @@ std::future<void> pipeline(F f, Tail... t) auto ex = get_associated_executor(f, thread_executor()); // Run the function. - post(ex, [out, f = std::move(f)]() mutable + asio::require(ex, execution::blocking.never).execute( + [out, f = std::move(f)]() mutable { f(out); out.stop(); @@ -242,12 +229,12 @@ std::future<void> pipeline(F f, Tail... t) //------------------------------------------------------------------------------ -#include <asio/thread_pool.hpp> +#include <asio/static_thread_pool.hpp> #include <iostream> #include <string> using asio::bind_executor; -using asio::thread_pool; +using asio::static_thread_pool; void reader(queue_front<std::string> out) { @@ -286,8 +273,8 @@ void writer(queue_back<std::string> in) int main() { - thread_pool pool; + static_thread_pool pool(1); - auto f = pipeline(reader, filter, bind_executor(pool, upper), writer); + auto f = pipeline(reader, filter, bind_executor(pool.executor(), upper), writer); f.wait(); } diff --git a/3rdparty/asio/src/examples/cpp14/executors/priority_scheduler.cpp b/3rdparty/asio/src/examples/cpp14/executors/priority_scheduler.cpp index 3b28af1eec0..20d36db933a 100644 --- a/3rdparty/asio/src/examples/cpp14/executors/priority_scheduler.cpp +++ b/3rdparty/asio/src/examples/cpp14/executors/priority_scheduler.cpp @@ -1,66 +1,74 @@ -#include <asio/ts/executor.hpp> +#include <asio/execution.hpp> #include <condition_variable> #include <iostream> #include <memory> #include <mutex> #include <queue> -using asio::dispatch; -using asio::execution_context; +namespace execution = asio::execution; -class priority_scheduler : public execution_context +namespace custom_props { + + struct priority + { + template <typename T> + static constexpr bool is_applicable_property_v = + execution::is_executor<T>::value; + + static constexpr bool is_requirable = true; + static constexpr bool is_preferable = true; + + using polymorphic_query_result_type = int; + + int value() const { return value_; } + + int value_ = 1; + }; + + constexpr priority low_priority{0}; + constexpr priority normal_priority{1}; + constexpr priority high_priority{2}; + +} // namespace custom_props + +class priority_scheduler { public: // A class that satisfies the Executor requirements. class executor_type { public: - executor_type(priority_scheduler& ctx, int pri) noexcept - : context_(ctx), priority_(pri) + executor_type(priority_scheduler& ctx) noexcept + : context_(ctx), priority_(custom_props::normal_priority.value()) { } - priority_scheduler& context() const noexcept + priority_scheduler& query(execution::context_t) const noexcept { return context_; } - void on_work_started() const noexcept - { - // This executor doesn't count work. Instead, the scheduler simply runs - // until explicitly stopped. - } - - void on_work_finished() const noexcept + int query(custom_props::priority) const noexcept { - // This executor doesn't count work. Instead, the scheduler simply runs - // until explicitly stopped. + return priority_; } - template <class Func, class Alloc> - void dispatch(Func&& f, const Alloc& a) const + executor_type require(custom_props::priority pri) const { - post(std::forward<Func>(f), a); + executor_type new_ex(*this); + new_ex.priority_ = pri.value(); + return new_ex; } - template <class Func, class Alloc> - void post(Func f, const Alloc& a) const + template <class Func> + void execute(Func f) 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 { @@ -78,9 +86,9 @@ public: int priority_; }; - executor_type get_executor(int pri = 0) noexcept + executor_type executor() noexcept { - return executor_type(*const_cast<priority_scheduler*>(this), pri); + return executor_type(*const_cast<priority_scheduler*>(this)); } void run() @@ -152,16 +160,22 @@ private: int main() { priority_scheduler sched; - auto low = sched.get_executor(0); - auto med = sched.get_executor(1); - auto high = sched.get_executor(2); - dispatch(low, []{ std::cout << "1\n"; }); - dispatch(low, []{ std::cout << "11\n"; }); - dispatch(med, []{ std::cout << "2\n"; }); - dispatch(med, []{ std::cout << "22\n"; }); - dispatch(high, []{ std::cout << "3\n"; }); - dispatch(high, []{ std::cout << "33\n"; }); - dispatch(high, []{ std::cout << "333\n"; }); - dispatch(sched.get_executor(-1), [&]{ sched.stop(); }); + auto ex = sched.executor(); + auto prefer_low = asio::prefer(ex, custom_props::low_priority); + auto low = asio::require(ex, custom_props::low_priority); + auto med = asio::require(ex, custom_props::normal_priority); + auto high = asio::require(ex, custom_props::high_priority); + execution::any_executor<custom_props::priority> poly_high(high); + prefer_low.execute([]{ std::cout << "1\n"; }); + low.execute([]{ std::cout << "11\n"; }); + low.execute([]{ std::cout << "111\n"; }); + med.execute([]{ std::cout << "2\n"; }); + med.execute([]{ std::cout << "22\n"; }); + high.execute([]{ std::cout << "3\n"; }); + high.execute([]{ std::cout << "33\n"; }); + high.execute([]{ std::cout << "333\n"; }); + poly_high.execute([]{ std::cout << "3333\n"; }); + asio::require(ex, custom_props::priority{-1}).execute([&]{ sched.stop(); }); sched.run(); + std::cout << "polymorphic query result = " << asio::query(poly_high, custom_props::priority{}) << "\n"; } diff --git a/3rdparty/asio/src/examples/cpp14/iostreams/.gitignore b/3rdparty/asio/src/examples/cpp14/iostreams/.gitignore deleted file mode 100644 index bc2b4f8f7fe..00000000000 --- a/3rdparty/asio/src/examples/cpp14/iostreams/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.dirstamp -*.o -*.obj -*.exe -*_client -*_server -*.ilk -*.manifest -*.pdb -*.tds diff --git a/3rdparty/asio/src/examples/cpp14/iostreams/http_client.cpp b/3rdparty/asio/src/examples/cpp14/iostreams/http_client.cpp index 36f14b459e5..3ae02e4f825 100644 --- a/3rdparty/asio/src/examples/cpp14/iostreams/http_client.cpp +++ b/3rdparty/asio/src/examples/cpp14/iostreams/http_client.cpp @@ -2,7 +2,7 @@ // http_client.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/3rdparty/asio/src/examples/cpp14/operations/c_callback_wrapper.cpp b/3rdparty/asio/src/examples/cpp14/operations/c_callback_wrapper.cpp new file mode 100644 index 00000000000..33b1c26e8ae --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/operations/c_callback_wrapper.cpp @@ -0,0 +1,230 @@ +// +// c_callback_wrapper.cpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> +#include <memory> +#include <new> + +//------------------------------------------------------------------------------ + +// This is a mock implementation of a C-based API that uses the function pointer +// plus void* context idiom for exposing a callback. + +void read_input(const char* prompt, void (*cb)(void*, const char*), void* arg) +{ + std::thread( + [prompt = std::string(prompt), cb, arg] + { + std::cout << prompt << ": "; + std::cout.flush(); + std::string line; + std::getline(std::cin, line); + cb(arg, line.c_str()); + }).detach(); +} + +//------------------------------------------------------------------------------ + +// This is an asynchronous operation that wraps the C-based API. + +// To map our completion handler into a function pointer / void* callback, we +// need to allocate some state that will live for the duration of the +// operation. A pointer to this state will be passed to the C-based API. +template <typename Handler> +class read_input_state +{ +public: + read_input_state(Handler&& handler) + : handler_(std::move(handler)), + work_(asio::make_work_guard(handler_)) + { + } + + // Create the state using the handler's associated allocator. + static read_input_state* create(Handler&& handler) + { + // A unique_ptr deleter that is used to destroy uninitialised objects. + struct deleter + { + // Get the handler's associated allocator type. If the handler does not + // specify an associated allocator, we will use a recycling allocator as + // the default. As the associated allocator is a proto-allocator, we must + // rebind it to the correct type before we can use it to allocate objects. + typename std::allocator_traits< + asio::associated_allocator_t<Handler, + asio::recycling_allocator<void>>>::template + rebind_alloc<read_input_state> alloc; + + void operator()(read_input_state* ptr) + { + std::allocator_traits<decltype(alloc)>::deallocate(alloc, ptr, 1); + } + } d{asio::get_associated_allocator(handler, + asio::recycling_allocator<void>())}; + + // Allocate memory for the state. + std::unique_ptr<read_input_state, deleter> uninit_ptr( + std::allocator_traits<decltype(d.alloc)>::allocate(d.alloc, 1), d); + + // Construct the state into the newly allocated memory. This might throw. + read_input_state* ptr = + new (uninit_ptr.get()) read_input_state(std::move(handler)); + + // Release ownership of the memory and return the newly allocated state. + uninit_ptr.release(); + return ptr; + } + + static void callback(void* arg, const char* result) + { + read_input_state* self = static_cast<read_input_state*>(arg); + + // A unique_ptr deleter that is used to destroy initialised objects. + struct deleter + { + // Get the handler's associated allocator type. If the handler does not + // specify an associated allocator, we will use a recycling allocator as + // the default. As the associated allocator is a proto-allocator, we must + // rebind it to the correct type before we can use it to allocate objects. + typename std::allocator_traits< + asio::associated_allocator_t<Handler, + asio::recycling_allocator<void>>>::template + rebind_alloc<read_input_state> alloc; + + void operator()(read_input_state* ptr) + { + std::allocator_traits<decltype(alloc)>::destroy(alloc, ptr); + std::allocator_traits<decltype(alloc)>::deallocate(alloc, ptr, 1); + } + } d{asio::get_associated_allocator(self->handler_, + asio::recycling_allocator<void>())}; + + // To conform to the rules regarding asynchronous operations and memory + // allocation, we must make a copy of the state and deallocate the memory + // before dispatching the completion handler. + std::unique_ptr<read_input_state, deleter> state_ptr(self, d); + read_input_state state(std::move(*self)); + state_ptr.reset(); + + // Dispatch the completion handler through the handler's associated + // executor, using the handler's associated allocator. + asio::dispatch(state.work_.get_executor(), + asio::bind_allocator(d.alloc, + [ + handler = std::move(state.handler_), + result = std::string(result) + ]() mutable + { + std::move(handler)(result); + })); + } + +private: + Handler handler_; + + // According to the rules for asynchronous operations, we need to track + // outstanding work against the handler's associated executor until the + // asynchronous operation is complete. + asio::executor_work_guard< + asio::associated_executor_t<Handler>> work_; +}; + +// The initiating function for the asynchronous operation. +template <typename CompletionToken> +auto async_read_input(const std::string& prompt, CompletionToken&& token) +{ + // Define a function object that contains the code to launch the asynchronous + // operation. This is passed the concrete completion handler, followed by any + // additional arguments that were passed through the call to async_initiate. + auto init = [](auto handler, const std::string& prompt) + { + // The body of the initiation function object creates the long-lived state + // and passes it to the C-based API, along with the function pointer. + using state_type = read_input_state<decltype(handler)>; + read_input(prompt.c_str(), &state_type::callback, + state_type::create(std::move(handler))); + }; + + // The async_initiate function is used to transform the supplied completion + // token to the completion handler. When calling this function we explicitly + // specify the completion signature of the operation. We must also return the + // result of the call since the completion token may produce a return value, + // such as a future. + return asio::async_initiate<CompletionToken, void(std::string)>( + init, // First, pass the function object that launches the operation, + token, // then the completion token that will be transformed to a handler, + prompt); // and, finally, any additional arguments to the function object. +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + // Test our asynchronous operation using a lambda as a callback. We will use + // an io_context to obtain an associated executor. + async_read_input("Enter your name", + asio::bind_executor(io_context, + [](const std::string& result) + { + std::cout << "Hello " << result << "\n"; + })); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_read_input("Enter your name", asio::deferred); + + // Launch our asynchronous operation using a lambda as a callback. We will use + // an io_context to obtain an associated executor. + std::move(op)( + asio::bind_executor(io_context, + [](const std::string& result) + { + std::cout << "Hello " << result << "\n"; + })); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<std::string> f = + async_read_input("Enter your name", asio::use_future); + + std::string result = f.get(); + std::cout << "Hello " << result << "\n"; +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp14/operations/callback_wrapper.cpp b/3rdparty/asio/src/examples/cpp14/operations/callback_wrapper.cpp new file mode 100644 index 00000000000..3d5774c7421 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/operations/callback_wrapper.cpp @@ -0,0 +1,152 @@ +// +// callback_wrapper.cpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> + +//------------------------------------------------------------------------------ + +// This is a mock implementation of an API that uses a move-only function object +// for exposing a callback. The callback has the signature void(std::string). + +template <typename Callback> +void read_input(const std::string& prompt, Callback cb) +{ + std::thread( + [prompt, cb = std::move(cb)]() mutable + { + std::cout << prompt << ": "; + std::cout.flush(); + std::string line; + std::getline(std::cin, line); + std::move(cb)(std::move(line)); + }).detach(); +} + +//------------------------------------------------------------------------------ + +// This is an asynchronous operation that wraps the callback-based API. + +// The initiating function for the asynchronous operation. +template <typename CompletionToken> +auto async_read_input(const std::string& prompt, CompletionToken&& token) +{ + // Define a function object that contains the code to launch the asynchronous + // operation. This is passed the concrete completion handler, followed by any + // additional arguments that were passed through the call to async_initiate. + auto init = [](auto handler, const std::string& prompt) + { + // According to the rules for asynchronous operations, we need to track + // outstanding work against the handler's associated executor until the + // asynchronous operation is complete. + auto work = asio::make_work_guard(handler); + + // Launch the operation with a callback that will receive the result and + // pass it through to the asynchronous operation's completion handler. + read_input(prompt, + [ + handler = std::move(handler), + work = std::move(work) + ](std::string result) mutable + { + // Get the handler's associated allocator. If the handler does not + // specify an allocator, use the recycling allocator as the default. + auto alloc = asio::get_associated_allocator( + handler, asio::recycling_allocator<void>()); + + // Dispatch the completion handler through the handler's associated + // executor, using the handler's associated allocator. + asio::dispatch(work.get_executor(), + asio::bind_allocator(alloc, + [ + handler = std::move(handler), + result = std::string(result) + ]() mutable + { + std::move(handler)(result); + })); + }); + }; + + // The async_initiate function is used to transform the supplied completion + // token to the completion handler. When calling this function we explicitly + // specify the completion signature of the operation. We must also return the + // result of the call since the completion token may produce a return value, + // such as a future. + return asio::async_initiate<CompletionToken, void(std::string)>( + init, // First, pass the function object that launches the operation, + token, // then the completion token that will be transformed to a handler, + prompt); // and, finally, any additional arguments to the function object. +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + // Test our asynchronous operation using a lambda as a callback. We will use + // an io_context to specify an associated executor. + async_read_input("Enter your name", + asio::bind_executor(io_context, + [](const std::string& result) + { + std::cout << "Hello " << result << "\n"; + })); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_read_input("Enter your name", asio::deferred); + + // Launch our asynchronous operation using a lambda as a callback. We will use + // an io_context to obtain an associated executor. + std::move(op)( + asio::bind_executor(io_context, + [](const std::string& result) + { + std::cout << "Hello " << result << "\n"; + })); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<std::string> f = + async_read_input("Enter your name", asio::use_future); + + std::string result = f.get(); + std::cout << "Hello " << result << "\n"; +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp14/operations/composed_1.cpp b/3rdparty/asio/src/examples/cpp14/operations/composed_1.cpp new file mode 100644 index 00000000000..80eaceddf71 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/operations/composed_1.cpp @@ -0,0 +1,155 @@ +// +// composed_1.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +//------------------------------------------------------------------------------ + +// This is the simplest example of a composed asynchronous operation, where we +// simply repackage an existing operation. The asynchronous operation +// requirements are met by delegating responsibility to the underlying +// operation. + +template <typename CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is void. + // However, when the completion token is asio::yield_context (used for + // stackful coroutines) the return type would be std::size_t, and when the + // completion token is asio::use_future it would be std::future<std::size_t>. + // When the completion token is asio::deferred, the return type differs for + // each asynchronous operation. + // + // In C++14 we can omit the return type as it is automatically deduced from + // the return type of our underlying asynchronous operation. +{ + // When delegating to the underlying operation we must take care to perfectly + // forward the completion token. This ensures that our operation works + // correctly with move-only function objects as callbacks, as well as other + // completion token types. + return asio::async_write(socket, + asio::buffer(message, std::strlen(message)), + std::forward<CompletionToken>(token)); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "Testing callback\r\n", + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_message(socket, + "Testing deferred\r\n", asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<std::size_t> f = async_write_message( + socket, "Testing future\r\n", asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + std::size_t n = f.get(); + std::cout << n << " bytes transferred\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp14/operations/composed_2.cpp b/3rdparty/asio/src/examples/cpp14/operations/composed_2.cpp new file mode 100644 index 00000000000..18086bd0627 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/operations/composed_2.cpp @@ -0,0 +1,219 @@ +// +// composed_2.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This next simplest example of a composed asynchronous operation involves +// repackaging multiple operations but choosing to invoke just one of them. All +// of these underlying operations have the same completion signature. The +// asynchronous operation requirements are met by delegating responsibility to +// the underlying operations. + +template <typename CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, bool allow_partial_write, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is void. + // However, when the completion token is asio::yield_context (used for + // stackful coroutines) the return type would be std::size_t, and when the + // completion token is asio::use_future it would be std::future<std::size_t>. + // When the completion token is asio::deferred, the return type differs for + // each asynchronous operation. + // + // In C++14 we can omit the return type as it is automatically deduced from + // the return type of asio::async_initiate. +{ + // In addition to determining the mechanism by which an asynchronous + // operation delivers its result, a completion token also determines the time + // when the operation commences. For example, when the completion token is a + // simple callback the operation commences before the initiating function + // returns. However, if the completion token's delivery mechanism uses a + // future, we might instead want to defer initiation of the operation until + // the returned future object is waited upon. + // + // To enable this, when implementing an asynchronous operation we must + // package the initiation step as a function object. The initiation function + // object's call operator is passed the concrete completion handler produced + // by the completion token. This completion handler matches the asynchronous + // operation's completion handler signature, which in this example is: + // + // void(std::error_code error, std::size_t) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments in the lambda capture set. However, we should prefer to + // propagate them as function call arguments as this allows the completion + // token to optimise how they are passed. For example, a lazy future which + // defers initiation would need to make a decay-copy of the arguments, but + // when using a simple callback the arguments can be trivially forwarded + // straight through.) + auto initiation = [](auto&& completion_handler, tcp::socket& socket, + const char* message, bool allow_partial_write) + { + if (allow_partial_write) + { + // When delegating to an underlying operation we must take care to + // perfectly forward the completion handler. This ensures that our + // operation works correctly with move-only function objects as + // callbacks. + return socket.async_write_some( + asio::buffer(message, std::strlen(message)), + std::forward<decltype(completion_handler)>(completion_handler)); + } + else + { + // As above, we must perfectly forward the completion handler when calling + // the alternate underlying operation. + return asio::async_write(socket, + asio::buffer(message, std::strlen(message)), + std::forward<decltype(completion_handler)>(completion_handler)); + } + }; + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code, std::size_t)>( + initiation, token, std::ref(socket), message, allow_partial_write); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "Testing callback\r\n", false, + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_message(socket, + "Testing deferred\r\n", false, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<std::size_t> f = async_write_message( + socket, "Testing future\r\n", false, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + std::size_t n = f.get(); + std::cout << n << " bytes transferred\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp14/operations/composed_3.cpp b/3rdparty/asio/src/examples/cpp14/operations/composed_3.cpp new file mode 100644 index 00000000000..7b347944768 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/operations/composed_3.cpp @@ -0,0 +1,228 @@ +// +// composed_3.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/bind_executor.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <functional> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// In this composed operation we repackage an existing operation, but with a +// different completion handler signature. The asynchronous operation +// requirements are met by delegating responsibility to the underlying +// operation. + +template <typename CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++14 we can omit the return type as it is automatically deduced from + // the return type of asio::async_initiate. +{ + // In addition to determining the mechanism by which an asynchronous + // operation delivers its result, a completion token also determines the time + // when the operation commences. For example, when the completion token is a + // simple callback the operation commences before the initiating function + // returns. However, if the completion token's delivery mechanism uses a + // future, we might instead want to defer initiation of the operation until + // the returned future object is waited upon. + // + // To enable this, when implementing an asynchronous operation we must + // package the initiation step as a function object. The initiation function + // object's call operator is passed the concrete completion handler produced + // by the completion token. This completion handler matches the asynchronous + // operation's completion handler signature, which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments in the lambda capture set. However, we should prefer to + // propagate them as function call arguments as this allows the completion + // token to optimise how they are passed. For example, a lazy future which + // defers initiation would need to make a decay-copy of the arguments, but + // when using a simple callback the arguments can be trivially forwarded + // straight through.) + auto initiation = [](auto&& completion_handler, + tcp::socket& socket, const char* message) + { + // The async_write operation has a completion handler signature of: + // + // void(std::error_code error, std::size n) + // + // This differs from our operation's signature in that it is also passed + // the number of bytes transferred as an argument of type std::size_t. We + // will adapt our completion handler to async_write's completion handler + // signature by using std::bind, which drops the additional argument. + // + // However, it is essential to the correctness of our composed operation + // that we preserve the executor of the user-supplied completion handler. + // The std::bind function will not do this for us, so we must do this by + // first obtaining the completion handler's associated executor (defaulting + // to the I/O executor - in this case the executor of the socket - if the + // completion handler does not have its own) ... + auto executor = asio::get_associated_executor( + completion_handler, socket.get_executor()); + + // ... and then binding this executor to our adapted completion handler + // using the asio::bind_executor function. + asio::async_write(socket, + asio::buffer(message, std::strlen(message)), + asio::bind_executor(executor, + std::bind(std::forward<decltype(completion_handler)>( + completion_handler), std::placeholders::_1))); + }; + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + initiation, token, std::ref(socket), message); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "Testing callback\r\n", + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_message(socket, + "Testing deferred\r\n", asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_message( + socket, "Testing future\r\n", asio::use_future); + + io_context.run(); + + // Get the result of the operation. + try + { + // Get the result of the operation. + f.get(); + std::cout << "Message sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp14/operations/composed_4.cpp b/3rdparty/asio/src/examples/cpp14/operations/composed_4.cpp new file mode 100644 index 00000000000..808a179e2d3 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/operations/composed_4.cpp @@ -0,0 +1,242 @@ +// +// composed_4.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/bind_executor.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <functional> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// In this composed operation we repackage an existing operation, but with a +// different completion handler signature. We will also intercept an empty +// message as an invalid argument, and propagate the corresponding error to the +// user. The asynchronous operation requirements are met by delegating +// responsibility to the underlying operation. + +template <typename CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++14 we can omit the return type as it is automatically deduced from + // the return type of asio::async_initiate. +{ + // In addition to determining the mechanism by which an asynchronous + // operation delivers its result, a completion token also determines the time + // when the operation commences. For example, when the completion token is a + // simple callback the operation commences before the initiating function + // returns. However, if the completion token's delivery mechanism uses a + // future, we might instead want to defer initiation of the operation until + // the returned future object is waited upon. + // + // To enable this, when implementing an asynchronous operation we must + // package the initiation step as a function object. The initiation function + // object's call operator is passed the concrete completion handler produced + // by the completion token. This completion handler matches the asynchronous + // operation's completion handler signature, which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments in the lambda capture set. However, we should prefer to + // propagate them as function call arguments as this allows the completion + // token to optimise how they are passed. For example, a lazy future which + // defers initiation would need to make a decay-copy of the arguments, but + // when using a simple callback the arguments can be trivially forwarded + // straight through.) + auto initiation = [](auto&& completion_handler, + tcp::socket& socket, const char* message) + { + // The post operation has a completion handler signature of: + // + // void() + // + // and the async_write operation has a completion handler signature of: + // + // void(std::error_code error, std::size n) + // + // Both of these operations' completion handler signatures differ from our + // operation's completion handler signature. We will adapt our completion + // handler to these signatures by using std::bind, which drops the + // additional arguments. + // + // However, it is essential to the correctness of our composed operation + // that we preserve the executor of the user-supplied completion handler. + // The std::bind function will not do this for us, so we must do this by + // first obtaining the completion handler's associated executor (defaulting + // to the I/O executor - in this case the executor of the socket - if the + // completion handler does not have its own) ... + auto executor = asio::get_associated_executor( + completion_handler, socket.get_executor()); + + // ... and then binding this executor to our adapted completion handler + // using the asio::bind_executor function. + std::size_t length = std::strlen(message); + if (length == 0) + { + asio::post( + asio::bind_executor(executor, + std::bind(std::forward<decltype(completion_handler)>( + completion_handler), asio::error::invalid_argument))); + } + else + { + asio::async_write(socket, + asio::buffer(message, length), + asio::bind_executor(executor, + std::bind(std::forward<decltype(completion_handler)>( + completion_handler), std::placeholders::_1))); + } + }; + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + initiation, token, std::ref(socket), message); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "", + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_message(socket, "", asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_message( + socket, "", asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Message sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Exception: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp14/operations/composed_5.cpp b/3rdparty/asio/src/examples/cpp14/operations/composed_5.cpp new file mode 100644 index 00000000000..c28cc8af129 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/operations/composed_5.cpp @@ -0,0 +1,280 @@ +// +// composed_5.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation automatically serialises a message, using its I/O +// streams insertion operator, before sending it on the socket. To do this, it +// must allocate a buffer for the encoded message and ensure this buffer's +// validity until the underlying async_write operation completes. + +template <typename T, typename CompletionToken> +auto async_write_message(tcp::socket& socket, + const T& message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++14 we can omit the return type as it is automatically deduced from + // the return type of asio::async_initiate. +{ + // In addition to determining the mechanism by which an asynchronous + // operation delivers its result, a completion token also determines the time + // when the operation commences. For example, when the completion token is a + // simple callback the operation commences before the initiating function + // returns. However, if the completion token's delivery mechanism uses a + // future, we might instead want to defer initiation of the operation until + // the returned future object is waited upon. + // + // To enable this, when implementing an asynchronous operation we must + // package the initiation step as a function object. The initiation function + // object's call operator is passed the concrete completion handler produced + // by the completion token. This completion handler matches the asynchronous + // operation's completion handler signature, which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments in the lambda capture set. However, we should prefer to + // propagate them as function call arguments as this allows the completion + // token to optimise how they are passed. For example, a lazy future which + // defers initiation would need to make a decay-copy of the arguments, but + // when using a simple callback the arguments can be trivially forwarded + // straight through.) + auto initiation = [](auto&& completion_handler, + tcp::socket& socket, std::unique_ptr<std::string> encoded_message) + { + // In this example, the composed operation's intermediate completion + // handler is implemented as a hand-crafted function object, rather than + // using a lambda or std::bind. + struct intermediate_completion_handler + { + // The intermediate completion handler holds a reference to the socket so + // that it can obtain the I/O executor (see get_executor below). + tcp::socket& socket_; + + // The allocated buffer for the encoded message. The std::unique_ptr + // smart pointer is move-only, and as a consequence our intermediate + // completion handler is also move-only. + std::unique_ptr<std::string> encoded_message_; + + // The user-supplied completion handler. + typename std::decay<decltype(completion_handler)>::type handler_; + + // The function call operator matches the completion signature of the + // async_write operation. + void operator()(const std::error_code& error, std::size_t /*n*/) + { + // Deallocate the encoded message before calling the user-supplied + // completion handler. + encoded_message_.reset(); + + // Call the user-supplied handler with the result of the operation. + // The arguments must match the completion signature of our composed + // operation. + handler_(error); + } + + // It is essential to the correctness of our composed operation that we + // preserve the executor of the user-supplied completion handler. With a + // hand-crafted function object we can do this by defining a nested type + // executor_type and member function get_executor. These obtain the + // completion handler's associated executor, and default to the I/O + // executor - in this case the executor of the socket - if the completion + // handler does not have its own. + using executor_type = asio::associated_executor_t< + typename std::decay<decltype(completion_handler)>::type, + tcp::socket::executor_type>; + + executor_type get_executor() const noexcept + { + return asio::get_associated_executor( + handler_, socket_.get_executor()); + } + + // Although not necessary for correctness, we may also preserve the + // allocator of the user-supplied completion handler. This is achieved by + // defining a nested type allocator_type and member function + // get_allocator. These obtain the completion handler's associated + // allocator, and default to std::allocator<void> if the completion + // handler does not have its own. + using allocator_type = asio::associated_allocator_t< + typename std::decay<decltype(completion_handler)>::type, + std::allocator<void>>; + + allocator_type get_allocator() const noexcept + { + return asio::get_associated_allocator( + handler_, std::allocator<void>{}); + } + }; + + // Initiate the underlying async_write operation using our intermediate + // completion handler. + auto encoded_message_buffer = asio::buffer(*encoded_message); + asio::async_write(socket, encoded_message_buffer, + intermediate_completion_handler{socket, std::move(encoded_message), + std::forward<decltype(completion_handler)>(completion_handler)}); + }; + + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + initiation, token, std::ref(socket), + std::move(encoded_message)); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, 123456, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_message(socket, + std::string("abcdef"), asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_message( + socket, 654.321, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Message sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Exception: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp14/operations/composed_6.cpp b/3rdparty/asio/src/examples/cpp14/operations/composed_6.cpp new file mode 100644 index 00000000000..82c0cd72237 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/operations/composed_6.cpp @@ -0,0 +1,340 @@ +// +// composed_6.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/executor_work_guard.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation shows composition of multiple underlying operations. +// It automatically serialises a message, using its I/O streams insertion +// operator, before sending it N times on the socket. To do this, it must +// allocate a buffer for the encoded message and ensure this buffer's validity +// until all underlying async_write operation complete. A one second delay is +// inserted prior to each write operation, using a steady_timer. + +template <typename T, typename CompletionToken> +auto async_write_messages(tcp::socket& socket, + const T& message, std::size_t repeat_count, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++14 we can omit the return type as it is automatically deduced from + // the return type of asio::async_initiate. +{ + // In addition to determining the mechanism by which an asynchronous + // operation delivers its result, a completion token also determines the time + // when the operation commences. For example, when the completion token is a + // simple callback the operation commences before the initiating function + // returns. However, if the completion token's delivery mechanism uses a + // future, we might instead want to defer initiation of the operation until + // the returned future object is waited upon. + // + // To enable this, when implementing an asynchronous operation we must + // package the initiation step as a function object. The initiation function + // object's call operator is passed the concrete completion handler produced + // by the completion token. This completion handler matches the asynchronous + // operation's completion handler signature, which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments in the lambda capture set. However, we should prefer to + // propagate them as function call arguments as this allows the completion + // token to optimise how they are passed. For example, a lazy future which + // defers initiation would need to make a decay-copy of the arguments, but + // when using a simple callback the arguments can be trivially forwarded + // straight through.) + auto initiation = [](auto&& completion_handler, tcp::socket& socket, + std::unique_ptr<std::string> encoded_message, std::size_t repeat_count, + std::unique_ptr<asio::steady_timer> delay_timer) + { + // In this example, the composed operation's intermediate completion + // handler is implemented as a hand-crafted function object. + struct intermediate_completion_handler + { + // The intermediate completion handler holds a reference to the socket as + // it is used for multiple async_write operations, as well as for + // obtaining the I/O executor (see get_executor below). + tcp::socket& socket_; + + // The allocated buffer for the encoded message. The std::unique_ptr + // smart pointer is move-only, and as a consequence our intermediate + // completion handler is also move-only. + std::unique_ptr<std::string> encoded_message_; + + // The repeat count remaining. + std::size_t repeat_count_; + + // A steady timer used for introducing a delay. + std::unique_ptr<asio::steady_timer> delay_timer_; + + // To manage the cycle between the multiple underlying asychronous + // operations, our intermediate completion handler is implemented as a + // state machine. + enum { starting, waiting, writing } state_; + + // As our composed operation performs multiple underlying I/O operations, + // we should maintain a work object against the I/O executor. This tells + // the I/O executor that there is still more work to come in the future. + asio::executor_work_guard<tcp::socket::executor_type> io_work_; + + // The user-supplied completion handler, called once only on completion + // of the entire composed operation. + typename std::decay<decltype(completion_handler)>::type handler_; + + // By having a default value for the second argument, this function call + // operator matches the completion signature of both the async_write and + // steady_timer::async_wait operations. + void operator()(const std::error_code& error, std::size_t = 0) + { + if (!error) + { + switch (state_) + { + case starting: + case writing: + if (repeat_count_ > 0) + { + --repeat_count_; + state_ = waiting; + delay_timer_->expires_after(std::chrono::seconds(1)); + delay_timer_->async_wait(std::move(*this)); + return; // Composed operation not yet complete. + } + break; // Composed operation complete, continue below. + case waiting: + state_ = writing; + asio::async_write(socket_, + asio::buffer(*encoded_message_), std::move(*this)); + return; // Composed operation not yet complete. + } + } + + // This point is reached only on completion of the entire composed + // operation. + + // We no longer have any future work coming for the I/O executor. + io_work_.reset(); + + // Deallocate the encoded message before calling the user-supplied + // completion handler. + encoded_message_.reset(); + + // Call the user-supplied handler with the result of the operation. + handler_(error); + } + + // It is essential to the correctness of our composed operation that we + // preserve the executor of the user-supplied completion handler. With a + // hand-crafted function object we can do this by defining a nested type + // executor_type and member function get_executor. These obtain the + // completion handler's associated executor, and default to the I/O + // executor - in this case the executor of the socket - if the completion + // handler does not have its own. + using executor_type = asio::associated_executor_t< + typename std::decay<decltype(completion_handler)>::type, + tcp::socket::executor_type>; + + executor_type get_executor() const noexcept + { + return asio::get_associated_executor( + handler_, socket_.get_executor()); + } + + // Although not necessary for correctness, we may also preserve the + // allocator of the user-supplied completion handler. This is achieved by + // defining a nested type allocator_type and member function + // get_allocator. These obtain the completion handler's associated + // allocator, and default to std::allocator<void> if the completion + // handler does not have its own. + using allocator_type = asio::associated_allocator_t< + typename std::decay<decltype(completion_handler)>::type, + std::allocator<void>>; + + allocator_type get_allocator() const noexcept + { + return asio::get_associated_allocator( + handler_, std::allocator<void>{}); + } + }; + + // Initiate the underlying async_write operation using our intermediate + // completion handler. + auto encoded_message_buffer = asio::buffer(*encoded_message); + asio::async_write(socket, encoded_message_buffer, + intermediate_completion_handler{ + socket, std::move(encoded_message), + repeat_count, std::move(delay_timer), + intermediate_completion_handler::starting, + asio::make_work_guard(socket.get_executor()), + std::forward<decltype(completion_handler)>(completion_handler)}); + }; + + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the composed asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // Create a steady_timer to be used for the delay between messages. + std::unique_ptr<asio::steady_timer> delay_timer( + new asio::steady_timer(socket.get_executor())); + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + initiation, token, std::ref(socket), + std::move(encoded_message), repeat_count, + std::move(delay_timer)); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_messages(socket, "Testing callback\r\n", 5, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_messages(socket, + "Testing deferred\r\n", 5, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_messages( + socket, "Testing future\r\n", 5, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Messages sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp14/operations/composed_7.cpp b/3rdparty/asio/src/examples/cpp14/operations/composed_7.cpp new file mode 100644 index 00000000000..841249bef5b --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/operations/composed_7.cpp @@ -0,0 +1,261 @@ +// +// composed_7.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/compose.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_compose function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation shows composition of multiple underlying operations. +// It automatically serialises a message, using its I/O streams insertion +// operator, before sending it N times on the socket. To do this, it must +// allocate a buffer for the encoded message and ensure this buffer's validity +// until all underlying async_write operation complete. A one second delay is +// inserted prior to each write operation, using a steady_timer. + +template <typename T, typename CompletionToken> +auto async_write_messages(tcp::socket& socket, + const T& message, std::size_t repeat_count, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++14 we can omit the return type as it is automatically deduced from + // the return type of asio::async_compose. +{ + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the composed asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // Create a steady_timer to be used for the delay between messages. + std::unique_ptr<asio::steady_timer> delay_timer( + new asio::steady_timer(socket.get_executor())); + + // To manage the cycle between the multiple underlying asychronous + // operations, our implementation is a state machine. + enum { starting, waiting, writing }; + + // The asio::async_compose function takes: + // + // - our asynchronous operation implementation, + // - the completion token, + // - the completion handler signature, and + // - any I/O objects (or executors) used by the operation + // + // It then wraps our implementation, which is implemented here as a state + // machine in a lambda, in an intermediate completion handler that meets the + // requirements of a conforming asynchronous operation. This includes + // tracking outstanding work against the I/O executors associated with the + // operation (in this example, this is the socket's executor). + // + // The first argument to our lambda is a reference to the enclosing + // intermediate completion handler. This intermediate completion handler is + // provided for us by the asio::async_compose function, and takes care + // of all the details required to implement a conforming asynchronous + // operation. When calling an underlying asynchronous operation, we pass it + // this enclosing intermediate completion handler as the completion token. + // + // All arguments to our lambda after the first must be defaulted to allow the + // state machine to be started, as well as to allow the completion handler to + // match the completion signature of both the async_write and + // steady_timer::async_wait operations. + return asio::async_compose< + CompletionToken, void(std::error_code)>( + [ + // The implementation holds a reference to the socket as it is used for + // multiple async_write operations. + &socket, + + // The allocated buffer for the encoded message. The std::unique_ptr + // smart pointer is move-only, and as a consequence our lambda + // implementation is also move-only. + encoded_message = std::move(encoded_message), + + // The repeat count remaining. + repeat_count, + + // A steady timer used for introducing a delay. + delay_timer = std::move(delay_timer), + + // To manage the cycle between the multiple underlying asychronous + // operations, our implementation is a state machine. + state = starting + ] + ( + auto& self, + const std::error_code& error = {}, + std::size_t = 0 + ) mutable + { + if (!error) + { + switch (state) + { + case starting: + case writing: + if (repeat_count > 0) + { + --repeat_count; + state = waiting; + delay_timer->expires_after(std::chrono::seconds(1)); + delay_timer->async_wait(std::move(self)); + return; // Composed operation not yet complete. + } + break; // Composed operation complete, continue below. + case waiting: + state = writing; + asio::async_write(socket, + asio::buffer(*encoded_message), std::move(self)); + return; // Composed operation not yet complete. + } + } + + // This point is reached only on completion of the entire composed + // operation. + + // Deallocate the encoded message and delay timer before calling the + // user-supplied completion handler. + encoded_message.reset(); + delay_timer.reset(); + + // Call the user-supplied handler with the result of the operation. + self.complete(error); + }, + token, socket); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_messages(socket, "Testing callback\r\n", 5, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_messages(socket, + "Testing deferred\r\n", 5, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_messages( + socket, "Testing future\r\n", 5, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Messages sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp14/operations/composed_8.cpp b/3rdparty/asio/src/examples/cpp14/operations/composed_8.cpp new file mode 100644 index 00000000000..d1f46ddce54 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/operations/composed_8.cpp @@ -0,0 +1,254 @@ +// +// composed_8.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/compose.hpp> +#include <asio/coroutine.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_compose function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation shows composition of multiple underlying operations, +// using asio's stackless coroutines support to express the flow of control. It +// automatically serialises a message, using its I/O streams insertion +// operator, before sending it N times on the socket. To do this, it must +// allocate a buffer for the encoded message and ensure this buffer's validity +// until all underlying async_write operation complete. A one second delay is +// inserted prior to each write operation, using a steady_timer. + +#include <asio/yield.hpp> + +template <typename T, typename CompletionToken> +auto async_write_messages(tcp::socket& socket, + const T& message, std::size_t repeat_count, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++14 we can omit the return type as it is automatically deduced from + // the return type of asio::async_compose. +{ + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the composed asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // Create a steady_timer to be used for the delay between messages. + std::unique_ptr<asio::steady_timer> delay_timer( + new asio::steady_timer(socket.get_executor())); + + // The asio::async_compose function takes: + // + // - our asynchronous operation implementation, + // - the completion token, + // - the completion handler signature, and + // - any I/O objects (or executors) used by the operation + // + // It then wraps our implementation, which is implemented here as a stackless + // coroutine in a lambda, in an intermediate completion handler that meets the + // requirements of a conforming asynchronous operation. This includes + // tracking outstanding work against the I/O executors associated with the + // operation (in this example, this is the socket's executor). + // + // The first argument to our lambda is a reference to the enclosing + // intermediate completion handler. This intermediate completion handler is + // provided for us by the asio::async_compose function, and takes care + // of all the details required to implement a conforming asynchronous + // operation. When calling an underlying asynchronous operation, we pass it + // this enclosing intermediate completion handler as the completion token. + // + // All arguments to our lambda after the first must be defaulted to allow the + // state machine to be started, as well as to allow the completion handler to + // match the completion signature of both the async_write and + // steady_timer::async_wait operations. + return asio::async_compose< + CompletionToken, void(std::error_code)>( + [ + // The implementation holds a reference to the socket as it is used for + // multiple async_write operations. + &socket, + + // The allocated buffer for the encoded message. The std::unique_ptr + // smart pointer is move-only, and as a consequence our lambda + // implementation is also move-only. + encoded_message = std::move(encoded_message), + + // The repeat count remaining. + repeat_count, + + // A steady timer used for introducing a delay. + delay_timer = std::move(delay_timer), + + // The coroutine state. + coro = asio::coroutine() + ] + ( + auto& self, + const std::error_code& error = {}, + std::size_t = 0 + ) mutable + { + reenter (coro) + { + while (repeat_count > 0) + { + --repeat_count; + + delay_timer->expires_after(std::chrono::seconds(1)); + yield delay_timer->async_wait(std::move(self)); + if (error) + break; + + yield asio::async_write(socket, + asio::buffer(*encoded_message), std::move(self)); + if (error) + break; + } + + // Deallocate the encoded message and delay timer before calling the + // user-supplied completion handler. + encoded_message.reset(); + delay_timer.reset(); + + // Call the user-supplied handler with the result of the operation. + self.complete(error); + } + }, + token, socket); +} + +#include <asio/unyield.hpp> + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_messages(socket, "Testing callback\r\n", 5, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_write_messages(socket, + "Testing deferred\r\n", 5, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_messages( + socket, "Testing future\r\n", 5, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Messages sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp14/parallel_group/parallel_sort.cpp b/3rdparty/asio/src/examples/cpp14/parallel_group/parallel_sort.cpp new file mode 100644 index 00000000000..8bb7cdfd719 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/parallel_group/parallel_sort.cpp @@ -0,0 +1,133 @@ +// +// parallel_sort.cpp +// ~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/parallel_group.hpp> +#include <algorithm> +#include <chrono> +#include <functional> +#include <iostream> +#include <random> + +template < + typename Executor, + typename RandomAccessIterator, + ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken> +auto parallel_sort( + Executor executor, + RandomAccessIterator begin, + RandomAccessIterator end, + CompletionToken&& token); + +template < + typename Executor, + typename RandomAccessIterator> +void parallel_sort_impl( + Executor executor, + RandomAccessIterator begin, + RandomAccessIterator end, + std::function<void()> continuation) +{ + std::size_t n = end - begin; + if (n <= 16384) + { + asio::post(executor, + [=] + { + std::sort(begin, end); + continuation(); + } + ); + } + else + { + asio::experimental::make_parallel_group( + [=](auto token) + { + return parallel_sort(executor, begin, begin + n / 2, token); + }, + [=](auto token) + { + return parallel_sort(executor, begin + n / 2, end, token); + } + ).async_wait( + asio::experimental::wait_for_all(), + [=](std::array<std::size_t, 2>) + { + std::inplace_merge(begin, begin + n / 2, end); + continuation(); + } + ); + } +} + +template < + typename Executor, + typename RandomAccessIterator, + ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken> +auto parallel_sort( + Executor executor, + RandomAccessIterator begin, + RandomAccessIterator end, + CompletionToken&& token) +{ + return asio::async_compose<CompletionToken, void()>( + [=](auto& self, auto... args) + { + if (sizeof...(args) == 0) + { + using self_type = std::decay_t<decltype(self)>; + parallel_sort_impl(executor, begin, end, + [self = std::make_shared<self_type>(std::move(self))] + { + asio::dispatch( + asio::append( + std::move(*self), 0)); + } + ); + } + else + { + self.complete(); + } + }, + token + ); +} + +int main() +{ + asio::thread_pool pool(4); + + std::vector<int> values(100'000'000); + + std::random_device random_device; + std::mt19937 rng(random_device()); + std::uniform_int_distribution<int> dist(1, 1'000'000); + std::generate(values.begin(), values.end(), [&]{ return dist(rng); }); + + std::cout << "starting sort\n"; + + auto begin = std::chrono::high_resolution_clock::now(); + + parallel_sort( + pool.get_executor(), + values.begin(), + values.end(), + asio::use_future + ).get(); + + auto end = std::chrono::high_resolution_clock::now(); + + auto duration = end - begin; + std::cout << "sort took " + << std::chrono::duration_cast<std::chrono::microseconds>(duration).count() + << " microseconds\n"; +} diff --git a/3rdparty/asio/src/examples/cpp14/parallel_group/ranged_wait_for_all.cpp b/3rdparty/asio/src/examples/cpp14/parallel_group/ranged_wait_for_all.cpp new file mode 100644 index 00000000000..18772884072 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/parallel_group/ranged_wait_for_all.cpp @@ -0,0 +1,70 @@ +// +// ranged_wait_for_all.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/parallel_group.hpp> +#include <iostream> +#include <vector> + +#ifdef ASIO_HAS_POSIX_STREAM_DESCRIPTOR + +int main() +{ + asio::io_context ctx; + + asio::posix::stream_descriptor out(ctx, ::dup(STDOUT_FILENO)); + asio::posix::stream_descriptor err(ctx, ::dup(STDERR_FILENO)); + + using op_type = decltype( + out.async_write_some( + asio::buffer("", 0), + asio::deferred + ) + ); + + std::vector<op_type> ops; + + ops.push_back( + out.async_write_some( + asio::buffer("first\r\n", 7), + asio::deferred + ) + ); + + ops.push_back( + err.async_write_some( + asio::buffer("second\r\n", 8), + asio::deferred + ) + ); + + asio::experimental::make_parallel_group(ops).async_wait( + asio::experimental::wait_for_all(), + []( + std::vector<std::size_t> completion_order, + std::vector<std::error_code> ec, + std::vector<std::size_t> n + ) + { + for (std::size_t i = 0; i < completion_order.size(); ++i) + { + std::size_t idx = completion_order[i]; + std::cout << "operation " << idx << " finished: "; + std::cout << ec[idx] << ", " << n[idx] << "\n"; + } + } + ); + + ctx.run(); +} + +#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +int main() {} +#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_all.cpp b/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_all.cpp new file mode 100644 index 00000000000..f007326326b --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_all.cpp @@ -0,0 +1,64 @@ +// +// wait_for_all.cpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/parallel_group.hpp> +#include <iostream> + +#ifdef ASIO_HAS_POSIX_STREAM_DESCRIPTOR + +int main() +{ + asio::io_context ctx; + + asio::posix::stream_descriptor in(ctx, ::dup(STDIN_FILENO)); + asio::steady_timer timer(ctx, std::chrono::seconds(5)); + + char data[1024]; + + asio::experimental::make_parallel_group( + [&](auto token) + { + return in.async_read_some(asio::buffer(data), token); + }, + [&](auto token) + { + return timer.async_wait(token); + } + ).async_wait( + asio::experimental::wait_for_all(), + []( + std::array<std::size_t, 2> completion_order, + std::error_code ec1, std::size_t n1, + std::error_code ec2 + ) + { + switch (completion_order[0]) + { + case 0: + { + std::cout << "descriptor finished: " << ec1 << ", " << n1 << "\n"; + } + break; + case 1: + { + std::cout << "timer finished: " << ec2 << "\n"; + } + break; + } + } + ); + + ctx.run(); +} + +#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +int main() {} +#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_one.cpp b/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_one.cpp new file mode 100644 index 00000000000..7b25e26d678 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_one.cpp @@ -0,0 +1,64 @@ +// +// wait_for_one.cpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/parallel_group.hpp> +#include <iostream> + +#if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) + +int main() +{ + asio::io_context ctx; + + asio::posix::stream_descriptor in(ctx, ::dup(STDIN_FILENO)); + asio::steady_timer timer(ctx, std::chrono::seconds(5)); + + char data[1024]; + + asio::experimental::make_parallel_group( + [&](auto token) + { + return in.async_read_some(asio::buffer(data), token); + }, + [&](auto token) + { + return timer.async_wait(token); + } + ).async_wait( + asio::experimental::wait_for_one(), + []( + std::array<std::size_t, 2> completion_order, + std::error_code ec1, std::size_t n1, + std::error_code ec2 + ) + { + switch (completion_order[0]) + { + case 0: + { + std::cout << "descriptor finished: " << ec1 << ", " << n1 << "\n"; + } + break; + case 1: + { + std::cout << "timer finished: " << ec2 << "\n"; + } + break; + } + } + ); + + ctx.run(); +} + +#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +int main() {} +#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_one_error.cpp b/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_one_error.cpp new file mode 100644 index 00000000000..c157d0b3355 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_one_error.cpp @@ -0,0 +1,64 @@ +// +// wait_for_one_error.cpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/parallel_group.hpp> +#include <iostream> + +#if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) + +int main() +{ + asio::io_context ctx; + + asio::posix::stream_descriptor in(ctx, ::dup(STDIN_FILENO)); + asio::steady_timer timer(ctx, std::chrono::seconds(5)); + + char data[1024]; + + asio::experimental::make_parallel_group( + [&](auto token) + { + return in.async_read_some(asio::buffer(data), token); + }, + [&](auto token) + { + return timer.async_wait(token); + } + ).async_wait( + asio::experimental::wait_for_one_error(), + []( + std::array<std::size_t, 2> completion_order, + std::error_code ec1, std::size_t n1, + std::error_code ec2 + ) + { + switch (completion_order[0]) + { + case 0: + { + std::cout << "descriptor finished: " << ec1 << ", " << n1 << "\n"; + } + break; + case 1: + { + std::cout << "timer finished: " << ec2 << "\n"; + } + break; + } + } + ); + + ctx.run(); +} + +#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +int main() {} +#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_one_success.cpp b/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_one_success.cpp new file mode 100644 index 00000000000..a328600a9fc --- /dev/null +++ b/3rdparty/asio/src/examples/cpp14/parallel_group/wait_for_one_success.cpp @@ -0,0 +1,64 @@ +// +// wait_for_one_error.cpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/parallel_group.hpp> +#include <iostream> + +#if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) + +int main() +{ + asio::io_context ctx; + + asio::posix::stream_descriptor in(ctx, ::dup(STDIN_FILENO)); + asio::steady_timer timer(ctx, std::chrono::seconds(5)); + + char data[1024]; + + asio::experimental::make_parallel_group( + [&](auto token) + { + return in.async_read_some(asio::buffer(data), token); + }, + [&](auto token) + { + return timer.async_wait(token); + } + ).async_wait( + asio::experimental::wait_for_one_success(), + []( + std::array<std::size_t, 2> completion_order, + std::error_code ec1, std::size_t n1, + std::error_code ec2 + ) + { + switch (completion_order[0]) + { + case 0: + { + std::cout << "descriptor finished: " << ec1 << ", " << n1 << "\n"; + } + break; + case 1: + { + std::cout << "timer finished: " << ec2 << "\n"; + } + break; + } + } + ); + + ctx.run(); +} + +#else // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) +int main() {} +#endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) diff --git a/3rdparty/asio/src/examples/cpp17/Makefile.am b/3rdparty/asio/src/examples/cpp17/Makefile.am new file mode 100644 index 00000000000..c3a571c02f4 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/Makefile.am @@ -0,0 +1,37 @@ +AUTOMAKE_OPTIONS = subdir-objects + +if SEPARATE_COMPILATION +noinst_LIBRARIES = libasio.a +libasio_a_SOURCES = ../../asio.cpp +if HAVE_OPENSSL +libasio_a_SOURCES += ../../asio_ssl.cpp +endif +LDADD = libasio.a +endif + +if HAVE_COROUTINES +noinst_PROGRAMS = \ + coroutines_ts/chat_server \ + coroutines_ts/echo_server \ + coroutines_ts/echo_server_with_default \ + coroutines_ts/echo_server_with_as_single_default \ + coroutines_ts/echo_server_with_as_tuple_default \ + coroutines_ts/refactored_echo_server +endif + +AM_CXXFLAGS = -I$(srcdir)/../../../include + +if HAVE_COROUTINES +coroutines_ts_chat_server_SOURCES = coroutines_ts/chat_server.cpp +coroutines_ts_echo_server_SOURCES = coroutines_ts/echo_server.cpp +coroutines_ts_echo_server_with_default_SOURCES = coroutines_ts/echo_server_with_default.cpp +coroutines_ts_echo_server_with_as_single_default_SOURCES = coroutines_ts/echo_server_with_as_single_default.cpp +coroutines_ts_echo_server_with_as_tuple_default_SOURCES = coroutines_ts/echo_server_with_as_tuple_default.cpp +coroutines_ts_refactored_echo_server_SOURCES = coroutines_ts/refactored_echo_server.cpp +endif + +EXTRA_DIST = \ + coroutines_ts/range_based_for.cpp + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in diff --git a/3rdparty/asio/src/examples/cpp17/Makefile.in b/3rdparty/asio/src/examples/cpp17/Makefile.in new file mode 100644 index 00000000000..db35ec4f320 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/Makefile.in @@ -0,0 +1,738 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@HAVE_OPENSSL_TRUE@@SEPARATE_COMPILATION_TRUE@am__append_1 = ../../asio_ssl.cpp +@HAVE_COROUTINES_TRUE@noinst_PROGRAMS = \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/chat_server$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/echo_server$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/echo_server_with_default$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/echo_server_with_as_single_default$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/echo_server_with_as_tuple_default$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/refactored_echo_server$(EXEEXT) +subdir = src/examples/cpp17 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +PROGRAMS = $(noinst_PROGRAMS) +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +AM_V_AR = $(am__v_AR_@AM_V@) +am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) +am__v_AR_0 = @echo " AR " $@; +am__v_AR_1 = +libasio_a_AR = $(AR) $(ARFLAGS) +libasio_a_LIBADD = +am__libasio_a_SOURCES_DIST = ../../asio.cpp ../../asio_ssl.cpp +am__dirstamp = $(am__leading_dot)dirstamp +@HAVE_OPENSSL_TRUE@@SEPARATE_COMPILATION_TRUE@am__objects_1 = ../../asio_ssl.$(OBJEXT) +@SEPARATE_COMPILATION_TRUE@am_libasio_a_OBJECTS = \ +@SEPARATE_COMPILATION_TRUE@ ../../asio.$(OBJEXT) \ +@SEPARATE_COMPILATION_TRUE@ $(am__objects_1) +libasio_a_OBJECTS = $(am_libasio_a_OBJECTS) +am__coroutines_ts_chat_server_SOURCES_DIST = \ + coroutines_ts/chat_server.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_chat_server_OBJECTS = \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/chat_server.$(OBJEXT) +coroutines_ts_chat_server_OBJECTS = \ + $(am_coroutines_ts_chat_server_OBJECTS) +coroutines_ts_chat_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_chat_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_ts_echo_server_SOURCES_DIST = \ + coroutines_ts/echo_server.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_echo_server_OBJECTS = \ +@HAVE_COROUTINES_TRUE@ coroutines_ts/echo_server.$(OBJEXT) +coroutines_ts_echo_server_OBJECTS = \ + $(am_coroutines_ts_echo_server_OBJECTS) +coroutines_ts_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_ts_echo_server_with_as_single_default_SOURCES_DIST = \ + coroutines_ts/echo_server_with_as_single_default.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_echo_server_with_as_single_default_OBJECTS = coroutines_ts/echo_server_with_as_single_default.$(OBJEXT) +coroutines_ts_echo_server_with_as_single_default_OBJECTS = $(am_coroutines_ts_echo_server_with_as_single_default_OBJECTS) +coroutines_ts_echo_server_with_as_single_default_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_echo_server_with_as_single_default_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_ts_echo_server_with_as_tuple_default_SOURCES_DIST = \ + coroutines_ts/echo_server_with_as_tuple_default.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_echo_server_with_as_tuple_default_OBJECTS = coroutines_ts/echo_server_with_as_tuple_default.$(OBJEXT) +coroutines_ts_echo_server_with_as_tuple_default_OBJECTS = \ + $(am_coroutines_ts_echo_server_with_as_tuple_default_OBJECTS) +coroutines_ts_echo_server_with_as_tuple_default_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_echo_server_with_as_tuple_default_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_ts_echo_server_with_default_SOURCES_DIST = \ + coroutines_ts/echo_server_with_default.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_echo_server_with_default_OBJECTS = coroutines_ts/echo_server_with_default.$(OBJEXT) +coroutines_ts_echo_server_with_default_OBJECTS = \ + $(am_coroutines_ts_echo_server_with_default_OBJECTS) +coroutines_ts_echo_server_with_default_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_echo_server_with_default_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_ts_refactored_echo_server_SOURCES_DIST = \ + coroutines_ts/refactored_echo_server.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_ts_refactored_echo_server_OBJECTS = coroutines_ts/refactored_echo_server.$(OBJEXT) +coroutines_ts_refactored_echo_server_OBJECTS = \ + $(am_coroutines_ts_refactored_echo_server_OBJECTS) +coroutines_ts_refactored_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_ts_refactored_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ../../$(DEPDIR)/asio.Po \ + ../../$(DEPDIR)/asio_ssl.Po \ + coroutines_ts/$(DEPDIR)/chat_server.Po \ + coroutines_ts/$(DEPDIR)/echo_server.Po \ + coroutines_ts/$(DEPDIR)/echo_server_with_as_single_default.Po \ + coroutines_ts/$(DEPDIR)/echo_server_with_as_tuple_default.Po \ + coroutines_ts/$(DEPDIR)/echo_server_with_default.Po \ + coroutines_ts/$(DEPDIR)/refactored_echo_server.Po +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(libasio_a_SOURCES) $(coroutines_ts_chat_server_SOURCES) \ + $(coroutines_ts_echo_server_SOURCES) \ + $(coroutines_ts_echo_server_with_as_single_default_SOURCES) \ + $(coroutines_ts_echo_server_with_as_tuple_default_SOURCES) \ + $(coroutines_ts_echo_server_with_default_SOURCES) \ + $(coroutines_ts_refactored_echo_server_SOURCES) +DIST_SOURCES = $(am__libasio_a_SOURCES_DIST) \ + $(am__coroutines_ts_chat_server_SOURCES_DIST) \ + $(am__coroutines_ts_echo_server_SOURCES_DIST) \ + $(am__coroutines_ts_echo_server_with_as_single_default_SOURCES_DIST) \ + $(am__coroutines_ts_echo_server_with_as_tuple_default_SOURCES_DIST) \ + $(am__coroutines_ts_echo_server_with_default_SOURCES_DIST) \ + $(am__coroutines_ts_refactored_echo_server_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +ETAGS = @ETAGS@ +EXEEXT = @EXEEXT@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfigdir = @pkgconfigdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = subdir-objects +@SEPARATE_COMPILATION_TRUE@noinst_LIBRARIES = libasio.a +@SEPARATE_COMPILATION_TRUE@libasio_a_SOURCES = ../../asio.cpp \ +@SEPARATE_COMPILATION_TRUE@ $(am__append_1) +@SEPARATE_COMPILATION_TRUE@LDADD = libasio.a +AM_CXXFLAGS = -I$(srcdir)/../../../include +@HAVE_COROUTINES_TRUE@coroutines_ts_chat_server_SOURCES = coroutines_ts/chat_server.cpp +@HAVE_COROUTINES_TRUE@coroutines_ts_echo_server_SOURCES = coroutines_ts/echo_server.cpp +@HAVE_COROUTINES_TRUE@coroutines_ts_echo_server_with_default_SOURCES = coroutines_ts/echo_server_with_default.cpp +@HAVE_COROUTINES_TRUE@coroutines_ts_echo_server_with_as_single_default_SOURCES = coroutines_ts/echo_server_with_as_single_default.cpp +@HAVE_COROUTINES_TRUE@coroutines_ts_echo_server_with_as_tuple_default_SOURCES = coroutines_ts/echo_server_with_as_tuple_default.cpp +@HAVE_COROUTINES_TRUE@coroutines_ts_refactored_echo_server_SOURCES = coroutines_ts/refactored_echo_server.cpp +EXTRA_DIST = \ + coroutines_ts/range_based_for.cpp + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/examples/cpp17/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/examples/cpp17/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +../../$(am__dirstamp): + @$(MKDIR_P) ../.. + @: > ../../$(am__dirstamp) +../../$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) ../../$(DEPDIR) + @: > ../../$(DEPDIR)/$(am__dirstamp) +../../asio.$(OBJEXT): ../../$(am__dirstamp) \ + ../../$(DEPDIR)/$(am__dirstamp) +../../asio_ssl.$(OBJEXT): ../../$(am__dirstamp) \ + ../../$(DEPDIR)/$(am__dirstamp) + +libasio.a: $(libasio_a_OBJECTS) $(libasio_a_DEPENDENCIES) $(EXTRA_libasio_a_DEPENDENCIES) + $(AM_V_at)-rm -f libasio.a + $(AM_V_AR)$(libasio_a_AR) libasio.a $(libasio_a_OBJECTS) $(libasio_a_LIBADD) + $(AM_V_at)$(RANLIB) libasio.a +coroutines_ts/$(am__dirstamp): + @$(MKDIR_P) coroutines_ts + @: > coroutines_ts/$(am__dirstamp) +coroutines_ts/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) coroutines_ts/$(DEPDIR) + @: > coroutines_ts/$(DEPDIR)/$(am__dirstamp) +coroutines_ts/chat_server.$(OBJEXT): coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/chat_server$(EXEEXT): $(coroutines_ts_chat_server_OBJECTS) $(coroutines_ts_chat_server_DEPENDENCIES) $(EXTRA_coroutines_ts_chat_server_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/chat_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_chat_server_OBJECTS) $(coroutines_ts_chat_server_LDADD) $(LIBS) +coroutines_ts/echo_server.$(OBJEXT): coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/echo_server$(EXEEXT): $(coroutines_ts_echo_server_OBJECTS) $(coroutines_ts_echo_server_DEPENDENCIES) $(EXTRA_coroutines_ts_echo_server_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_echo_server_OBJECTS) $(coroutines_ts_echo_server_LDADD) $(LIBS) +coroutines_ts/echo_server_with_as_single_default.$(OBJEXT): \ + coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/echo_server_with_as_single_default$(EXEEXT): $(coroutines_ts_echo_server_with_as_single_default_OBJECTS) $(coroutines_ts_echo_server_with_as_single_default_DEPENDENCIES) $(EXTRA_coroutines_ts_echo_server_with_as_single_default_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/echo_server_with_as_single_default$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_echo_server_with_as_single_default_OBJECTS) $(coroutines_ts_echo_server_with_as_single_default_LDADD) $(LIBS) +coroutines_ts/echo_server_with_as_tuple_default.$(OBJEXT): \ + coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/echo_server_with_as_tuple_default$(EXEEXT): $(coroutines_ts_echo_server_with_as_tuple_default_OBJECTS) $(coroutines_ts_echo_server_with_as_tuple_default_DEPENDENCIES) $(EXTRA_coroutines_ts_echo_server_with_as_tuple_default_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/echo_server_with_as_tuple_default$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_echo_server_with_as_tuple_default_OBJECTS) $(coroutines_ts_echo_server_with_as_tuple_default_LDADD) $(LIBS) +coroutines_ts/echo_server_with_default.$(OBJEXT): \ + coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/echo_server_with_default$(EXEEXT): $(coroutines_ts_echo_server_with_default_OBJECTS) $(coroutines_ts_echo_server_with_default_DEPENDENCIES) $(EXTRA_coroutines_ts_echo_server_with_default_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/echo_server_with_default$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_echo_server_with_default_OBJECTS) $(coroutines_ts_echo_server_with_default_LDADD) $(LIBS) +coroutines_ts/refactored_echo_server.$(OBJEXT): \ + coroutines_ts/$(am__dirstamp) \ + coroutines_ts/$(DEPDIR)/$(am__dirstamp) + +coroutines_ts/refactored_echo_server$(EXEEXT): $(coroutines_ts_refactored_echo_server_OBJECTS) $(coroutines_ts_refactored_echo_server_DEPENDENCIES) $(EXTRA_coroutines_ts_refactored_echo_server_DEPENDENCIES) coroutines_ts/$(am__dirstamp) + @rm -f coroutines_ts/refactored_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_ts_refactored_echo_server_OBJECTS) $(coroutines_ts_refactored_echo_server_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + -rm -f ../../*.$(OBJEXT) + -rm -f coroutines_ts/*.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@../../$(DEPDIR)/asio.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@../../$(DEPDIR)/asio_ssl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/chat_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/echo_server_with_as_single_default.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/echo_server_with_as_tuple_default.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/echo_server_with_default.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines_ts/$(DEPDIR)/refactored_echo_server.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f ../../$(DEPDIR)/$(am__dirstamp) + -rm -f ../../$(am__dirstamp) + -rm -f coroutines_ts/$(DEPDIR)/$(am__dirstamp) + -rm -f coroutines_ts/$(am__dirstamp) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -f ../../$(DEPDIR)/asio.Po + -rm -f ../../$(DEPDIR)/asio_ssl.Po + -rm -f coroutines_ts/$(DEPDIR)/chat_server.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_as_single_default.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_as_tuple_default.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_default.Po + -rm -f coroutines_ts/$(DEPDIR)/refactored_echo_server.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ../../$(DEPDIR)/asio.Po + -rm -f ../../$(DEPDIR)/asio_ssl.Po + -rm -f coroutines_ts/$(DEPDIR)/chat_server.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_as_single_default.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_as_tuple_default.Po + -rm -f coroutines_ts/$(DEPDIR)/echo_server_with_default.Po + -rm -f coroutines_ts/$(DEPDIR)/refactored_echo_server.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/chat_server.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/chat_server.cpp new file mode 100644 index 00000000000..cd5fba32486 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/chat_server.cpp @@ -0,0 +1,222 @@ +// +// chat_server.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <cstdlib> +#include <deque> +#include <iostream> +#include <list> +#include <memory> +#include <set> +#include <string> +#include <utility> +#include <asio/awaitable.hpp> +#include <asio/detached.hpp> +#include <asio/co_spawn.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/read_until.hpp> +#include <asio/redirect_error.hpp> +#include <asio/signal_set.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_awaitable.hpp> +#include <asio/write.hpp> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::redirect_error; +using asio::use_awaitable; + +//---------------------------------------------------------------------- + +class chat_participant +{ +public: + virtual ~chat_participant() {} + virtual void deliver(const std::string& msg) = 0; +}; + +typedef std::shared_ptr<chat_participant> chat_participant_ptr; + +//---------------------------------------------------------------------- + +class chat_room +{ +public: + void join(chat_participant_ptr participant) + { + participants_.insert(participant); + for (auto msg: recent_msgs_) + participant->deliver(msg); + } + + void leave(chat_participant_ptr participant) + { + participants_.erase(participant); + } + + void deliver(const std::string& msg) + { + recent_msgs_.push_back(msg); + while (recent_msgs_.size() > max_recent_msgs) + recent_msgs_.pop_front(); + + for (auto participant: participants_) + participant->deliver(msg); + } + +private: + std::set<chat_participant_ptr> participants_; + enum { max_recent_msgs = 100 }; + std::deque<std::string> recent_msgs_; +}; + +//---------------------------------------------------------------------- + +class chat_session + : public chat_participant, + public std::enable_shared_from_this<chat_session> +{ +public: + chat_session(tcp::socket socket, chat_room& room) + : socket_(std::move(socket)), + timer_(socket_.get_executor()), + room_(room) + { + timer_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + void start() + { + room_.join(shared_from_this()); + + co_spawn(socket_.get_executor(), + [self = shared_from_this()]{ return self->reader(); }, + detached); + + co_spawn(socket_.get_executor(), + [self = shared_from_this()]{ return self->writer(); }, + detached); + } + + void deliver(const std::string& msg) + { + write_msgs_.push_back(msg); + timer_.cancel_one(); + } + +private: + awaitable<void> reader() + { + try + { + for (std::string read_msg;;) + { + std::size_t n = co_await asio::async_read_until(socket_, + asio::dynamic_buffer(read_msg, 1024), "\n", use_awaitable); + + room_.deliver(read_msg.substr(0, n)); + read_msg.erase(0, n); + } + } + catch (std::exception&) + { + stop(); + } + } + + awaitable<void> writer() + { + try + { + while (socket_.is_open()) + { + if (write_msgs_.empty()) + { + asio::error_code ec; + co_await timer_.async_wait(redirect_error(use_awaitable, ec)); + } + else + { + co_await asio::async_write(socket_, + asio::buffer(write_msgs_.front()), use_awaitable); + write_msgs_.pop_front(); + } + } + } + catch (std::exception&) + { + stop(); + } + } + + void stop() + { + room_.leave(shared_from_this()); + socket_.close(); + timer_.cancel(); + } + + tcp::socket socket_; + asio::steady_timer timer_; + chat_room& room_; + std::deque<std::string> write_msgs_; +}; + +//---------------------------------------------------------------------- + +awaitable<void> listener(tcp::acceptor acceptor) +{ + chat_room room; + + for (;;) + { + std::make_shared<chat_session>( + co_await acceptor.async_accept(use_awaitable), + room + )->start(); + } +} + +//---------------------------------------------------------------------- + +int main(int argc, char* argv[]) +{ + try + { + if (argc < 2) + { + std::cerr << "Usage: chat_server <port> [<port> ...]\n"; + return 1; + } + + asio::io_context io_context(1); + + for (int i = 1; i < argc; ++i) + { + unsigned short port = std::atoi(argv[i]); + co_spawn(io_context, + listener(tcp::acceptor(io_context, {tcp::v4(), port})), + detached); + } + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server.cpp new file mode 100644 index 00000000000..a9532459f77 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server.cpp @@ -0,0 +1,76 @@ +// +// echo_server.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable; +namespace this_coro = asio::this_coro; + +#if defined(ASIO_ENABLE_HANDLER_TRACKING) +# define use_awaitable \ + asio::use_awaitable_t(__FILE__, __LINE__, __PRETTY_FUNCTION__) +#endif + +awaitable<void> echo(tcp::socket socket) +{ + try + { + char data[1024]; + for (;;) + { + std::size_t n = co_await socket.async_read_some(asio::buffer(data), use_awaitable); + co_await async_write(socket, asio::buffer(data, n), use_awaitable); + } + } + catch (std::exception& e) + { + std::printf("echo Exception: %s\n", e.what()); + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp::acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + tcp::socket socket = co_await acceptor.async_accept(use_awaitable); + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_single_default.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_single_default.cpp new file mode 100644 index 00000000000..4a692acc872 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_single_default.cpp @@ -0,0 +1,71 @@ +// +// echo_server_with_as_single_default.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/experimental/as_single.hpp> +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::experimental::as_single_t; +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable_t; +using default_token = as_single_t<use_awaitable_t<>>; +using tcp_acceptor = default_token::as_default_on_t<tcp::acceptor>; +using tcp_socket = default_token::as_default_on_t<tcp::socket>; +namespace this_coro = asio::this_coro; + +awaitable<void> echo(tcp_socket socket) +{ + char data[1024]; + for (;;) + { + auto [e1, nread] = co_await socket.async_read_some(asio::buffer(data)); + if (nread == 0) break; + auto [e2, nwritten] = co_await async_write(socket, asio::buffer(data, nread)); + if (nwritten != nread) break; + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp_acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + if (auto [e, socket] = co_await acceptor.async_accept(); socket.is_open()) + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_tuple_default.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_tuple_default.cpp new file mode 100644 index 00000000000..de162cad78e --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_as_tuple_default.cpp @@ -0,0 +1,71 @@ +// +// echo_server_with_as_tuple_default.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/as_tuple.hpp> +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::as_tuple_t; +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable_t; +using default_token = as_tuple_t<use_awaitable_t<>>; +using tcp_acceptor = default_token::as_default_on_t<tcp::acceptor>; +using tcp_socket = default_token::as_default_on_t<tcp::socket>; +namespace this_coro = asio::this_coro; + +awaitable<void> echo(tcp_socket socket) +{ + char data[1024]; + for (;;) + { + auto [e1, nread] = co_await socket.async_read_some(asio::buffer(data)); + if (nread == 0) break; + auto [e2, nwritten] = co_await async_write(socket, asio::buffer(data, nread)); + if (nwritten != nread) break; + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp_acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + if (auto [e, socket] = co_await acceptor.async_accept(); socket.is_open()) + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_default.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_default.cpp new file mode 100644 index 00000000000..54344d94d56 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/echo_server_with_default.cpp @@ -0,0 +1,73 @@ +// +// echo_server_with_default.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable_t; +using tcp_acceptor = use_awaitable_t<>::as_default_on_t<tcp::acceptor>; +using tcp_socket = use_awaitable_t<>::as_default_on_t<tcp::socket>; +namespace this_coro = asio::this_coro; + +awaitable<void> echo(tcp_socket socket) +{ + try + { + char data[1024]; + for (;;) + { + std::size_t n = co_await socket.async_read_some(asio::buffer(data)); + co_await async_write(socket, asio::buffer(data, n)); + } + } + catch (std::exception& e) + { + std::printf("echo Exception: %s\n", e.what()); + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp_acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + auto socket = co_await acceptor.async_accept(); + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/range_based_for.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/range_based_for.cpp new file mode 100644 index 00000000000..599ed80cd3f --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/range_based_for.cpp @@ -0,0 +1,102 @@ +// +// range_based_for.cpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable; + +class connection_iter +{ + friend class connections; + tcp::acceptor* acceptor_ = nullptr; + tcp::socket socket_; + + connection_iter(tcp::acceptor& a, tcp::socket s) + : acceptor_(&a), socket_(std::move(s)) {} + +public: + tcp::socket operator*() + { + return std::move(socket_); + } + + awaitable<void> operator++() + { + socket_ = co_await acceptor_->async_accept(use_awaitable); + } + + bool operator==(const connection_iter&) const noexcept + { + return false; + } + + bool operator!=(const connection_iter&) const noexcept + { + return true; + } +}; + +class connections +{ + tcp::acceptor& acceptor_; + +public: + explicit connections(tcp::acceptor& a) : acceptor_(a) {} + + awaitable<connection_iter> begin() + { + tcp::socket s = co_await acceptor_.async_accept(use_awaitable); + co_return connection_iter(acceptor_, std::move(s)); + } + + connection_iter end() + { + return connection_iter(acceptor_, + tcp::socket(acceptor_.get_executor())); + } +}; + +awaitable<void> listener(tcp::acceptor acceptor) +{ + for co_await (tcp::socket s : connections(acceptor)) + { + co_await asio::async_write(s, asio::buffer("hello\r\n", 7), use_awaitable); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + co_spawn(io_context, listener(std::move(acceptor)), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp17/coroutines_ts/refactored_echo_server.cpp b/3rdparty/asio/src/examples/cpp17/coroutines_ts/refactored_echo_server.cpp new file mode 100644 index 00000000000..dc7b03d86e2 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp17/coroutines_ts/refactored_echo_server.cpp @@ -0,0 +1,80 @@ +// +// refactored_echo_server.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable; +namespace this_coro = asio::this_coro; + +awaitable<void> echo_once(tcp::socket& socket) +{ + char data[128]; + std::size_t n = co_await socket.async_read_some(asio::buffer(data), use_awaitable); + co_await async_write(socket, asio::buffer(data, n), use_awaitable); +} + +awaitable<void> echo(tcp::socket socket) +{ + try + { + for (;;) + { + // The asynchronous operations to echo a single chunk of data have been + // refactored into a separate function. When this function is called, the + // operations are still performed in the context of the current + // coroutine, and the behaviour is functionally equivalent. + co_await echo_once(socket); + } + } + catch (std::exception& e) + { + std::printf("echo Exception: %s\n", e.what()); + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp::acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + tcp::socket socket = co_await acceptor.async_accept(use_awaitable); + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp20/Makefile.am b/3rdparty/asio/src/examples/cpp20/Makefile.am new file mode 100644 index 00000000000..619893c208e --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/Makefile.am @@ -0,0 +1,79 @@ +AUTOMAKE_OPTIONS = subdir-objects + +if SEPARATE_COMPILATION +noinst_LIBRARIES = libasio.a +libasio_a_SOURCES = ../../asio.cpp +if HAVE_OPENSSL +libasio_a_SOURCES += ../../asio_ssl.cpp +endif +LDADD = libasio.a +endif + +noinst_PROGRAMS = \ + invocation/completion_executor \ + operations/c_callback_wrapper \ + operations/callback_wrapper \ + operations/composed_1 \ + operations/composed_1 \ + operations/composed_2 \ + operations/composed_3 \ + operations/composed_4 \ + operations/composed_5 \ + operations/composed_6 \ + operations/composed_7 \ + operations/composed_8 + +if HAVE_COROUTINES +noinst_PROGRAMS += \ + channels/mutual_exclusion_1 \ + channels/mutual_exclusion_2 \ + channels/throttling_proxy \ + coroutines/chat_server \ + coroutines/echo_server \ + coroutines/echo_server_with_default \ + coroutines/echo_server_with_deferred \ + coroutines/echo_server_with_deferred_default \ + coroutines/echo_server_with_as_single_default \ + coroutines/echo_server_with_as_tuple_default \ + coroutines/refactored_echo_server \ + coroutines/timeout \ + type_erasure/type_erasure +endif + +AM_CXXFLAGS = -I$(srcdir)/../../../include + +invocation_completion_executor_SOURCES = invocation/completion_executor.cpp +operations_c_callback_wrapper_SOURCES = operations/c_callback_wrapper.cpp +operations_callback_wrapper_SOURCES = operations/callback_wrapper.cpp +operations_composed_1_SOURCES = operations/composed_1.cpp +operations_composed_2_SOURCES = operations/composed_2.cpp +operations_composed_3_SOURCES = operations/composed_3.cpp +operations_composed_4_SOURCES = operations/composed_4.cpp +operations_composed_5_SOURCES = operations/composed_5.cpp +operations_composed_6_SOURCES = operations/composed_6.cpp +operations_composed_7_SOURCES = operations/composed_7.cpp +operations_composed_8_SOURCES = operations/composed_8.cpp + +if HAVE_COROUTINES +channels_mutual_exclusion_1_SOURCES = channels/mutual_exclusion_1.cpp +channels_mutual_exclusion_2_SOURCES = channels/mutual_exclusion_2.cpp +channels_throttling_proxy_SOURCES = channels/throttling_proxy.cpp +coroutines_chat_server_SOURCES = coroutines/chat_server.cpp +coroutines_echo_server_SOURCES = coroutines/echo_server.cpp +coroutines_echo_server_with_default_SOURCES = coroutines/echo_server_with_default.cpp +coroutines_echo_server_with_deferred_SOURCES = coroutines/echo_server_with_deferred.cpp +coroutines_echo_server_with_deferred_default_SOURCES = coroutines/echo_server_with_deferred_default.cpp +coroutines_echo_server_with_as_single_default_SOURCES = coroutines/echo_server_with_as_single_default.cpp +coroutines_echo_server_with_as_tuple_default_SOURCES = coroutines/echo_server_with_as_tuple_default.cpp +coroutines_refactored_echo_server_SOURCES = coroutines/refactored_echo_server.cpp +coroutines_timeout_SOURCES = coroutines/timeout.cpp +type_erasure_type_erasure_SOURCES = type_erasure/main.cpp type_erasure/stdin_line_reader.cpp type_erasure/sleep.cpp +endif + +EXTRA_DIST = \ + type_erasure/line_reader.hpp \ + type_erasure/stdin_line_reader.hpp \ + type_erasure/sleep.hpp + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in diff --git a/3rdparty/asio/src/examples/cpp20/Makefile.in b/3rdparty/asio/src/examples/cpp20/Makefile.in new file mode 100644 index 00000000000..87311465ece --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/Makefile.in @@ -0,0 +1,1173 @@ +# Makefile.in generated by automake 1.16.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2021 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +@HAVE_OPENSSL_TRUE@@SEPARATE_COMPILATION_TRUE@am__append_1 = ../../asio_ssl.cpp +noinst_PROGRAMS = invocation/completion_executor$(EXEEXT) \ + operations/c_callback_wrapper$(EXEEXT) \ + operations/callback_wrapper$(EXEEXT) \ + operations/composed_1$(EXEEXT) operations/composed_1$(EXEEXT) \ + operations/composed_2$(EXEEXT) operations/composed_3$(EXEEXT) \ + operations/composed_4$(EXEEXT) operations/composed_5$(EXEEXT) \ + operations/composed_6$(EXEEXT) operations/composed_7$(EXEEXT) \ + operations/composed_8$(EXEEXT) $(am__EXEEXT_1) +@HAVE_COROUTINES_TRUE@am__append_2 = \ +@HAVE_COROUTINES_TRUE@ channels/mutual_exclusion_1 \ +@HAVE_COROUTINES_TRUE@ channels/mutual_exclusion_2 \ +@HAVE_COROUTINES_TRUE@ channels/throttling_proxy \ +@HAVE_COROUTINES_TRUE@ coroutines/chat_server \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server_with_default \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server_with_deferred \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server_with_deferred_default \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server_with_as_single_default \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server_with_as_tuple_default \ +@HAVE_COROUTINES_TRUE@ coroutines/refactored_echo_server \ +@HAVE_COROUTINES_TRUE@ coroutines/timeout \ +@HAVE_COROUTINES_TRUE@ type_erasure/type_erasure + +subdir = src/examples/cpp20 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +@HAVE_COROUTINES_TRUE@am__EXEEXT_1 = \ +@HAVE_COROUTINES_TRUE@ channels/mutual_exclusion_1$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ channels/mutual_exclusion_2$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ channels/throttling_proxy$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines/chat_server$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server_with_default$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server_with_deferred$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server_with_deferred_default$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server_with_as_single_default$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server_with_as_tuple_default$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines/refactored_echo_server$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ coroutines/timeout$(EXEEXT) \ +@HAVE_COROUTINES_TRUE@ type_erasure/type_erasure$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +AM_V_AR = $(am__v_AR_@AM_V@) +am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) +am__v_AR_0 = @echo " AR " $@; +am__v_AR_1 = +libasio_a_AR = $(AR) $(ARFLAGS) +libasio_a_LIBADD = +am__libasio_a_SOURCES_DIST = ../../asio.cpp ../../asio_ssl.cpp +am__dirstamp = $(am__leading_dot)dirstamp +@HAVE_OPENSSL_TRUE@@SEPARATE_COMPILATION_TRUE@am__objects_1 = ../../asio_ssl.$(OBJEXT) +@SEPARATE_COMPILATION_TRUE@am_libasio_a_OBJECTS = \ +@SEPARATE_COMPILATION_TRUE@ ../../asio.$(OBJEXT) \ +@SEPARATE_COMPILATION_TRUE@ $(am__objects_1) +libasio_a_OBJECTS = $(am_libasio_a_OBJECTS) +am__channels_mutual_exclusion_1_SOURCES_DIST = \ + channels/mutual_exclusion_1.cpp +@HAVE_COROUTINES_TRUE@am_channels_mutual_exclusion_1_OBJECTS = \ +@HAVE_COROUTINES_TRUE@ channels/mutual_exclusion_1.$(OBJEXT) +channels_mutual_exclusion_1_OBJECTS = \ + $(am_channels_mutual_exclusion_1_OBJECTS) +channels_mutual_exclusion_1_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@channels_mutual_exclusion_1_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__channels_mutual_exclusion_2_SOURCES_DIST = \ + channels/mutual_exclusion_2.cpp +@HAVE_COROUTINES_TRUE@am_channels_mutual_exclusion_2_OBJECTS = \ +@HAVE_COROUTINES_TRUE@ channels/mutual_exclusion_2.$(OBJEXT) +channels_mutual_exclusion_2_OBJECTS = \ + $(am_channels_mutual_exclusion_2_OBJECTS) +channels_mutual_exclusion_2_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@channels_mutual_exclusion_2_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__channels_throttling_proxy_SOURCES_DIST = \ + channels/throttling_proxy.cpp +@HAVE_COROUTINES_TRUE@am_channels_throttling_proxy_OBJECTS = \ +@HAVE_COROUTINES_TRUE@ channels/throttling_proxy.$(OBJEXT) +channels_throttling_proxy_OBJECTS = \ + $(am_channels_throttling_proxy_OBJECTS) +channels_throttling_proxy_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@channels_throttling_proxy_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_chat_server_SOURCES_DIST = coroutines/chat_server.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_chat_server_OBJECTS = \ +@HAVE_COROUTINES_TRUE@ coroutines/chat_server.$(OBJEXT) +coroutines_chat_server_OBJECTS = $(am_coroutines_chat_server_OBJECTS) +coroutines_chat_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_chat_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_echo_server_SOURCES_DIST = coroutines/echo_server.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_echo_server_OBJECTS = \ +@HAVE_COROUTINES_TRUE@ coroutines/echo_server.$(OBJEXT) +coroutines_echo_server_OBJECTS = $(am_coroutines_echo_server_OBJECTS) +coroutines_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_echo_server_with_as_single_default_SOURCES_DIST = \ + coroutines/echo_server_with_as_single_default.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_echo_server_with_as_single_default_OBJECTS = coroutines/echo_server_with_as_single_default.$(OBJEXT) +coroutines_echo_server_with_as_single_default_OBJECTS = \ + $(am_coroutines_echo_server_with_as_single_default_OBJECTS) +coroutines_echo_server_with_as_single_default_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_echo_server_with_as_single_default_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_echo_server_with_as_tuple_default_SOURCES_DIST = \ + coroutines/echo_server_with_as_tuple_default.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_echo_server_with_as_tuple_default_OBJECTS = coroutines/echo_server_with_as_tuple_default.$(OBJEXT) +coroutines_echo_server_with_as_tuple_default_OBJECTS = \ + $(am_coroutines_echo_server_with_as_tuple_default_OBJECTS) +coroutines_echo_server_with_as_tuple_default_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_echo_server_with_as_tuple_default_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_echo_server_with_default_SOURCES_DIST = \ + coroutines/echo_server_with_default.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_echo_server_with_default_OBJECTS = coroutines/echo_server_with_default.$(OBJEXT) +coroutines_echo_server_with_default_OBJECTS = \ + $(am_coroutines_echo_server_with_default_OBJECTS) +coroutines_echo_server_with_default_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_echo_server_with_default_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_echo_server_with_deferred_SOURCES_DIST = \ + coroutines/echo_server_with_deferred.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_echo_server_with_deferred_OBJECTS = coroutines/echo_server_with_deferred.$(OBJEXT) +coroutines_echo_server_with_deferred_OBJECTS = \ + $(am_coroutines_echo_server_with_deferred_OBJECTS) +coroutines_echo_server_with_deferred_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_echo_server_with_deferred_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_echo_server_with_deferred_default_SOURCES_DIST = \ + coroutines/echo_server_with_deferred_default.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_echo_server_with_deferred_default_OBJECTS = coroutines/echo_server_with_deferred_default.$(OBJEXT) +coroutines_echo_server_with_deferred_default_OBJECTS = \ + $(am_coroutines_echo_server_with_deferred_default_OBJECTS) +coroutines_echo_server_with_deferred_default_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_echo_server_with_deferred_default_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_refactored_echo_server_SOURCES_DIST = \ + coroutines/refactored_echo_server.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_refactored_echo_server_OBJECTS = coroutines/refactored_echo_server.$(OBJEXT) +coroutines_refactored_echo_server_OBJECTS = \ + $(am_coroutines_refactored_echo_server_OBJECTS) +coroutines_refactored_echo_server_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_refactored_echo_server_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__coroutines_timeout_SOURCES_DIST = coroutines/timeout.cpp +@HAVE_COROUTINES_TRUE@am_coroutines_timeout_OBJECTS = \ +@HAVE_COROUTINES_TRUE@ coroutines/timeout.$(OBJEXT) +coroutines_timeout_OBJECTS = $(am_coroutines_timeout_OBJECTS) +coroutines_timeout_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@coroutines_timeout_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_invocation_completion_executor_OBJECTS = \ + invocation/completion_executor.$(OBJEXT) +invocation_completion_executor_OBJECTS = \ + $(am_invocation_completion_executor_OBJECTS) +invocation_completion_executor_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@invocation_completion_executor_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_c_callback_wrapper_OBJECTS = \ + operations/c_callback_wrapper.$(OBJEXT) +operations_c_callback_wrapper_OBJECTS = \ + $(am_operations_c_callback_wrapper_OBJECTS) +operations_c_callback_wrapper_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_c_callback_wrapper_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_callback_wrapper_OBJECTS = \ + operations/callback_wrapper.$(OBJEXT) +operations_callback_wrapper_OBJECTS = \ + $(am_operations_callback_wrapper_OBJECTS) +operations_callback_wrapper_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_callback_wrapper_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_1_OBJECTS = operations/composed_1.$(OBJEXT) +operations_composed_1_OBJECTS = $(am_operations_composed_1_OBJECTS) +operations_composed_1_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_1_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_2_OBJECTS = operations/composed_2.$(OBJEXT) +operations_composed_2_OBJECTS = $(am_operations_composed_2_OBJECTS) +operations_composed_2_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_2_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_3_OBJECTS = operations/composed_3.$(OBJEXT) +operations_composed_3_OBJECTS = $(am_operations_composed_3_OBJECTS) +operations_composed_3_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_3_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_4_OBJECTS = operations/composed_4.$(OBJEXT) +operations_composed_4_OBJECTS = $(am_operations_composed_4_OBJECTS) +operations_composed_4_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_4_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_5_OBJECTS = operations/composed_5.$(OBJEXT) +operations_composed_5_OBJECTS = $(am_operations_composed_5_OBJECTS) +operations_composed_5_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_5_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_6_OBJECTS = operations/composed_6.$(OBJEXT) +operations_composed_6_OBJECTS = $(am_operations_composed_6_OBJECTS) +operations_composed_6_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_6_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_7_OBJECTS = operations/composed_7.$(OBJEXT) +operations_composed_7_OBJECTS = $(am_operations_composed_7_OBJECTS) +operations_composed_7_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_7_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am_operations_composed_8_OBJECTS = operations/composed_8.$(OBJEXT) +operations_composed_8_OBJECTS = $(am_operations_composed_8_OBJECTS) +operations_composed_8_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@operations_composed_8_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +am__type_erasure_type_erasure_SOURCES_DIST = type_erasure/main.cpp \ + type_erasure/stdin_line_reader.cpp type_erasure/sleep.cpp +@HAVE_COROUTINES_TRUE@am_type_erasure_type_erasure_OBJECTS = \ +@HAVE_COROUTINES_TRUE@ type_erasure/main.$(OBJEXT) \ +@HAVE_COROUTINES_TRUE@ type_erasure/stdin_line_reader.$(OBJEXT) \ +@HAVE_COROUTINES_TRUE@ type_erasure/sleep.$(OBJEXT) +type_erasure_type_erasure_OBJECTS = \ + $(am_type_erasure_type_erasure_OBJECTS) +type_erasure_type_erasure_LDADD = $(LDADD) +@SEPARATE_COMPILATION_TRUE@type_erasure_type_erasure_DEPENDENCIES = \ +@SEPARATE_COMPILATION_TRUE@ libasio.a +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ../../$(DEPDIR)/asio.Po \ + ../../$(DEPDIR)/asio_ssl.Po \ + channels/$(DEPDIR)/mutual_exclusion_1.Po \ + channels/$(DEPDIR)/mutual_exclusion_2.Po \ + channels/$(DEPDIR)/throttling_proxy.Po \ + coroutines/$(DEPDIR)/chat_server.Po \ + coroutines/$(DEPDIR)/echo_server.Po \ + coroutines/$(DEPDIR)/echo_server_with_as_single_default.Po \ + coroutines/$(DEPDIR)/echo_server_with_as_tuple_default.Po \ + coroutines/$(DEPDIR)/echo_server_with_default.Po \ + coroutines/$(DEPDIR)/echo_server_with_deferred.Po \ + coroutines/$(DEPDIR)/echo_server_with_deferred_default.Po \ + coroutines/$(DEPDIR)/refactored_echo_server.Po \ + coroutines/$(DEPDIR)/timeout.Po \ + invocation/$(DEPDIR)/completion_executor.Po \ + operations/$(DEPDIR)/c_callback_wrapper.Po \ + operations/$(DEPDIR)/callback_wrapper.Po \ + operations/$(DEPDIR)/composed_1.Po \ + operations/$(DEPDIR)/composed_2.Po \ + operations/$(DEPDIR)/composed_3.Po \ + operations/$(DEPDIR)/composed_4.Po \ + operations/$(DEPDIR)/composed_5.Po \ + operations/$(DEPDIR)/composed_6.Po \ + operations/$(DEPDIR)/composed_7.Po \ + operations/$(DEPDIR)/composed_8.Po \ + type_erasure/$(DEPDIR)/main.Po type_erasure/$(DEPDIR)/sleep.Po \ + type_erasure/$(DEPDIR)/stdin_line_reader.Po +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(libasio_a_SOURCES) $(channels_mutual_exclusion_1_SOURCES) \ + $(channels_mutual_exclusion_2_SOURCES) \ + $(channels_throttling_proxy_SOURCES) \ + $(coroutines_chat_server_SOURCES) \ + $(coroutines_echo_server_SOURCES) \ + $(coroutines_echo_server_with_as_single_default_SOURCES) \ + $(coroutines_echo_server_with_as_tuple_default_SOURCES) \ + $(coroutines_echo_server_with_default_SOURCES) \ + $(coroutines_echo_server_with_deferred_SOURCES) \ + $(coroutines_echo_server_with_deferred_default_SOURCES) \ + $(coroutines_refactored_echo_server_SOURCES) \ + $(coroutines_timeout_SOURCES) \ + $(invocation_completion_executor_SOURCES) \ + $(operations_c_callback_wrapper_SOURCES) \ + $(operations_callback_wrapper_SOURCES) \ + $(operations_composed_1_SOURCES) \ + $(operations_composed_2_SOURCES) \ + $(operations_composed_3_SOURCES) \ + $(operations_composed_4_SOURCES) \ + $(operations_composed_5_SOURCES) \ + $(operations_composed_6_SOURCES) \ + $(operations_composed_7_SOURCES) \ + $(operations_composed_8_SOURCES) \ + $(type_erasure_type_erasure_SOURCES) +DIST_SOURCES = $(am__libasio_a_SOURCES_DIST) \ + $(am__channels_mutual_exclusion_1_SOURCES_DIST) \ + $(am__channels_mutual_exclusion_2_SOURCES_DIST) \ + $(am__channels_throttling_proxy_SOURCES_DIST) \ + $(am__coroutines_chat_server_SOURCES_DIST) \ + $(am__coroutines_echo_server_SOURCES_DIST) \ + $(am__coroutines_echo_server_with_as_single_default_SOURCES_DIST) \ + $(am__coroutines_echo_server_with_as_tuple_default_SOURCES_DIST) \ + $(am__coroutines_echo_server_with_default_SOURCES_DIST) \ + $(am__coroutines_echo_server_with_deferred_SOURCES_DIST) \ + $(am__coroutines_echo_server_with_deferred_default_SOURCES_DIST) \ + $(am__coroutines_refactored_echo_server_SOURCES_DIST) \ + $(am__coroutines_timeout_SOURCES_DIST) \ + $(invocation_completion_executor_SOURCES) \ + $(operations_c_callback_wrapper_SOURCES) \ + $(operations_callback_wrapper_SOURCES) \ + $(operations_composed_1_SOURCES) \ + $(operations_composed_2_SOURCES) \ + $(operations_composed_3_SOURCES) \ + $(operations_composed_4_SOURCES) \ + $(operations_composed_5_SOURCES) \ + $(operations_composed_6_SOURCES) \ + $(operations_composed_7_SOURCES) \ + $(operations_composed_8_SOURCES) \ + $(am__type_erasure_type_erasure_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +ETAGS = @ETAGS@ +EXEEXT = @EXEEXT@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfigdir = @pkgconfigdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = subdir-objects +@SEPARATE_COMPILATION_TRUE@noinst_LIBRARIES = libasio.a +@SEPARATE_COMPILATION_TRUE@libasio_a_SOURCES = ../../asio.cpp \ +@SEPARATE_COMPILATION_TRUE@ $(am__append_1) +@SEPARATE_COMPILATION_TRUE@LDADD = libasio.a +AM_CXXFLAGS = -I$(srcdir)/../../../include +invocation_completion_executor_SOURCES = invocation/completion_executor.cpp +operations_c_callback_wrapper_SOURCES = operations/c_callback_wrapper.cpp +operations_callback_wrapper_SOURCES = operations/callback_wrapper.cpp +operations_composed_1_SOURCES = operations/composed_1.cpp +operations_composed_2_SOURCES = operations/composed_2.cpp +operations_composed_3_SOURCES = operations/composed_3.cpp +operations_composed_4_SOURCES = operations/composed_4.cpp +operations_composed_5_SOURCES = operations/composed_5.cpp +operations_composed_6_SOURCES = operations/composed_6.cpp +operations_composed_7_SOURCES = operations/composed_7.cpp +operations_composed_8_SOURCES = operations/composed_8.cpp +@HAVE_COROUTINES_TRUE@channels_mutual_exclusion_1_SOURCES = channels/mutual_exclusion_1.cpp +@HAVE_COROUTINES_TRUE@channels_mutual_exclusion_2_SOURCES = channels/mutual_exclusion_2.cpp +@HAVE_COROUTINES_TRUE@channels_throttling_proxy_SOURCES = channels/throttling_proxy.cpp +@HAVE_COROUTINES_TRUE@coroutines_chat_server_SOURCES = coroutines/chat_server.cpp +@HAVE_COROUTINES_TRUE@coroutines_echo_server_SOURCES = coroutines/echo_server.cpp +@HAVE_COROUTINES_TRUE@coroutines_echo_server_with_default_SOURCES = coroutines/echo_server_with_default.cpp +@HAVE_COROUTINES_TRUE@coroutines_echo_server_with_deferred_SOURCES = coroutines/echo_server_with_deferred.cpp +@HAVE_COROUTINES_TRUE@coroutines_echo_server_with_deferred_default_SOURCES = coroutines/echo_server_with_deferred_default.cpp +@HAVE_COROUTINES_TRUE@coroutines_echo_server_with_as_single_default_SOURCES = coroutines/echo_server_with_as_single_default.cpp +@HAVE_COROUTINES_TRUE@coroutines_echo_server_with_as_tuple_default_SOURCES = coroutines/echo_server_with_as_tuple_default.cpp +@HAVE_COROUTINES_TRUE@coroutines_refactored_echo_server_SOURCES = coroutines/refactored_echo_server.cpp +@HAVE_COROUTINES_TRUE@coroutines_timeout_SOURCES = coroutines/timeout.cpp +@HAVE_COROUTINES_TRUE@type_erasure_type_erasure_SOURCES = type_erasure/main.cpp type_erasure/stdin_line_reader.cpp type_erasure/sleep.cpp +EXTRA_DIST = \ + type_erasure/line_reader.hpp \ + type_erasure/stdin_line_reader.hpp \ + type_erasure/sleep.hpp + +MAINTAINERCLEANFILES = \ + $(srcdir)/Makefile.in + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/examples/cpp20/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/examples/cpp20/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +../../$(am__dirstamp): + @$(MKDIR_P) ../.. + @: > ../../$(am__dirstamp) +../../$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) ../../$(DEPDIR) + @: > ../../$(DEPDIR)/$(am__dirstamp) +../../asio.$(OBJEXT): ../../$(am__dirstamp) \ + ../../$(DEPDIR)/$(am__dirstamp) +../../asio_ssl.$(OBJEXT): ../../$(am__dirstamp) \ + ../../$(DEPDIR)/$(am__dirstamp) + +libasio.a: $(libasio_a_OBJECTS) $(libasio_a_DEPENDENCIES) $(EXTRA_libasio_a_DEPENDENCIES) + $(AM_V_at)-rm -f libasio.a + $(AM_V_AR)$(libasio_a_AR) libasio.a $(libasio_a_OBJECTS) $(libasio_a_LIBADD) + $(AM_V_at)$(RANLIB) libasio.a +channels/$(am__dirstamp): + @$(MKDIR_P) channels + @: > channels/$(am__dirstamp) +channels/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) channels/$(DEPDIR) + @: > channels/$(DEPDIR)/$(am__dirstamp) +channels/mutual_exclusion_1.$(OBJEXT): channels/$(am__dirstamp) \ + channels/$(DEPDIR)/$(am__dirstamp) + +channels/mutual_exclusion_1$(EXEEXT): $(channels_mutual_exclusion_1_OBJECTS) $(channels_mutual_exclusion_1_DEPENDENCIES) $(EXTRA_channels_mutual_exclusion_1_DEPENDENCIES) channels/$(am__dirstamp) + @rm -f channels/mutual_exclusion_1$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(channels_mutual_exclusion_1_OBJECTS) $(channels_mutual_exclusion_1_LDADD) $(LIBS) +channels/mutual_exclusion_2.$(OBJEXT): channels/$(am__dirstamp) \ + channels/$(DEPDIR)/$(am__dirstamp) + +channels/mutual_exclusion_2$(EXEEXT): $(channels_mutual_exclusion_2_OBJECTS) $(channels_mutual_exclusion_2_DEPENDENCIES) $(EXTRA_channels_mutual_exclusion_2_DEPENDENCIES) channels/$(am__dirstamp) + @rm -f channels/mutual_exclusion_2$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(channels_mutual_exclusion_2_OBJECTS) $(channels_mutual_exclusion_2_LDADD) $(LIBS) +channels/throttling_proxy.$(OBJEXT): channels/$(am__dirstamp) \ + channels/$(DEPDIR)/$(am__dirstamp) + +channels/throttling_proxy$(EXEEXT): $(channels_throttling_proxy_OBJECTS) $(channels_throttling_proxy_DEPENDENCIES) $(EXTRA_channels_throttling_proxy_DEPENDENCIES) channels/$(am__dirstamp) + @rm -f channels/throttling_proxy$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(channels_throttling_proxy_OBJECTS) $(channels_throttling_proxy_LDADD) $(LIBS) +coroutines/$(am__dirstamp): + @$(MKDIR_P) coroutines + @: > coroutines/$(am__dirstamp) +coroutines/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) coroutines/$(DEPDIR) + @: > coroutines/$(DEPDIR)/$(am__dirstamp) +coroutines/chat_server.$(OBJEXT): coroutines/$(am__dirstamp) \ + coroutines/$(DEPDIR)/$(am__dirstamp) + +coroutines/chat_server$(EXEEXT): $(coroutines_chat_server_OBJECTS) $(coroutines_chat_server_DEPENDENCIES) $(EXTRA_coroutines_chat_server_DEPENDENCIES) coroutines/$(am__dirstamp) + @rm -f coroutines/chat_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_chat_server_OBJECTS) $(coroutines_chat_server_LDADD) $(LIBS) +coroutines/echo_server.$(OBJEXT): coroutines/$(am__dirstamp) \ + coroutines/$(DEPDIR)/$(am__dirstamp) + +coroutines/echo_server$(EXEEXT): $(coroutines_echo_server_OBJECTS) $(coroutines_echo_server_DEPENDENCIES) $(EXTRA_coroutines_echo_server_DEPENDENCIES) coroutines/$(am__dirstamp) + @rm -f coroutines/echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_echo_server_OBJECTS) $(coroutines_echo_server_LDADD) $(LIBS) +coroutines/echo_server_with_as_single_default.$(OBJEXT): \ + coroutines/$(am__dirstamp) \ + coroutines/$(DEPDIR)/$(am__dirstamp) + +coroutines/echo_server_with_as_single_default$(EXEEXT): $(coroutines_echo_server_with_as_single_default_OBJECTS) $(coroutines_echo_server_with_as_single_default_DEPENDENCIES) $(EXTRA_coroutines_echo_server_with_as_single_default_DEPENDENCIES) coroutines/$(am__dirstamp) + @rm -f coroutines/echo_server_with_as_single_default$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_echo_server_with_as_single_default_OBJECTS) $(coroutines_echo_server_with_as_single_default_LDADD) $(LIBS) +coroutines/echo_server_with_as_tuple_default.$(OBJEXT): \ + coroutines/$(am__dirstamp) \ + coroutines/$(DEPDIR)/$(am__dirstamp) + +coroutines/echo_server_with_as_tuple_default$(EXEEXT): $(coroutines_echo_server_with_as_tuple_default_OBJECTS) $(coroutines_echo_server_with_as_tuple_default_DEPENDENCIES) $(EXTRA_coroutines_echo_server_with_as_tuple_default_DEPENDENCIES) coroutines/$(am__dirstamp) + @rm -f coroutines/echo_server_with_as_tuple_default$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_echo_server_with_as_tuple_default_OBJECTS) $(coroutines_echo_server_with_as_tuple_default_LDADD) $(LIBS) +coroutines/echo_server_with_default.$(OBJEXT): \ + coroutines/$(am__dirstamp) \ + coroutines/$(DEPDIR)/$(am__dirstamp) + +coroutines/echo_server_with_default$(EXEEXT): $(coroutines_echo_server_with_default_OBJECTS) $(coroutines_echo_server_with_default_DEPENDENCIES) $(EXTRA_coroutines_echo_server_with_default_DEPENDENCIES) coroutines/$(am__dirstamp) + @rm -f coroutines/echo_server_with_default$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_echo_server_with_default_OBJECTS) $(coroutines_echo_server_with_default_LDADD) $(LIBS) +coroutines/echo_server_with_deferred.$(OBJEXT): \ + coroutines/$(am__dirstamp) \ + coroutines/$(DEPDIR)/$(am__dirstamp) + +coroutines/echo_server_with_deferred$(EXEEXT): $(coroutines_echo_server_with_deferred_OBJECTS) $(coroutines_echo_server_with_deferred_DEPENDENCIES) $(EXTRA_coroutines_echo_server_with_deferred_DEPENDENCIES) coroutines/$(am__dirstamp) + @rm -f coroutines/echo_server_with_deferred$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_echo_server_with_deferred_OBJECTS) $(coroutines_echo_server_with_deferred_LDADD) $(LIBS) +coroutines/echo_server_with_deferred_default.$(OBJEXT): \ + coroutines/$(am__dirstamp) \ + coroutines/$(DEPDIR)/$(am__dirstamp) + +coroutines/echo_server_with_deferred_default$(EXEEXT): $(coroutines_echo_server_with_deferred_default_OBJECTS) $(coroutines_echo_server_with_deferred_default_DEPENDENCIES) $(EXTRA_coroutines_echo_server_with_deferred_default_DEPENDENCIES) coroutines/$(am__dirstamp) + @rm -f coroutines/echo_server_with_deferred_default$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_echo_server_with_deferred_default_OBJECTS) $(coroutines_echo_server_with_deferred_default_LDADD) $(LIBS) +coroutines/refactored_echo_server.$(OBJEXT): \ + coroutines/$(am__dirstamp) \ + coroutines/$(DEPDIR)/$(am__dirstamp) + +coroutines/refactored_echo_server$(EXEEXT): $(coroutines_refactored_echo_server_OBJECTS) $(coroutines_refactored_echo_server_DEPENDENCIES) $(EXTRA_coroutines_refactored_echo_server_DEPENDENCIES) coroutines/$(am__dirstamp) + @rm -f coroutines/refactored_echo_server$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_refactored_echo_server_OBJECTS) $(coroutines_refactored_echo_server_LDADD) $(LIBS) +coroutines/timeout.$(OBJEXT): coroutines/$(am__dirstamp) \ + coroutines/$(DEPDIR)/$(am__dirstamp) + +coroutines/timeout$(EXEEXT): $(coroutines_timeout_OBJECTS) $(coroutines_timeout_DEPENDENCIES) $(EXTRA_coroutines_timeout_DEPENDENCIES) coroutines/$(am__dirstamp) + @rm -f coroutines/timeout$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(coroutines_timeout_OBJECTS) $(coroutines_timeout_LDADD) $(LIBS) +invocation/$(am__dirstamp): + @$(MKDIR_P) invocation + @: > invocation/$(am__dirstamp) +invocation/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) invocation/$(DEPDIR) + @: > invocation/$(DEPDIR)/$(am__dirstamp) +invocation/completion_executor.$(OBJEXT): invocation/$(am__dirstamp) \ + invocation/$(DEPDIR)/$(am__dirstamp) + +invocation/completion_executor$(EXEEXT): $(invocation_completion_executor_OBJECTS) $(invocation_completion_executor_DEPENDENCIES) $(EXTRA_invocation_completion_executor_DEPENDENCIES) invocation/$(am__dirstamp) + @rm -f invocation/completion_executor$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(invocation_completion_executor_OBJECTS) $(invocation_completion_executor_LDADD) $(LIBS) +operations/$(am__dirstamp): + @$(MKDIR_P) operations + @: > operations/$(am__dirstamp) +operations/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) operations/$(DEPDIR) + @: > operations/$(DEPDIR)/$(am__dirstamp) +operations/c_callback_wrapper.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/c_callback_wrapper$(EXEEXT): $(operations_c_callback_wrapper_OBJECTS) $(operations_c_callback_wrapper_DEPENDENCIES) $(EXTRA_operations_c_callback_wrapper_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/c_callback_wrapper$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_c_callback_wrapper_OBJECTS) $(operations_c_callback_wrapper_LDADD) $(LIBS) +operations/callback_wrapper.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/callback_wrapper$(EXEEXT): $(operations_callback_wrapper_OBJECTS) $(operations_callback_wrapper_DEPENDENCIES) $(EXTRA_operations_callback_wrapper_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/callback_wrapper$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_callback_wrapper_OBJECTS) $(operations_callback_wrapper_LDADD) $(LIBS) +operations/composed_1.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_1$(EXEEXT): $(operations_composed_1_OBJECTS) $(operations_composed_1_DEPENDENCIES) $(EXTRA_operations_composed_1_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_1$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_1_OBJECTS) $(operations_composed_1_LDADD) $(LIBS) +operations/composed_2.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_2$(EXEEXT): $(operations_composed_2_OBJECTS) $(operations_composed_2_DEPENDENCIES) $(EXTRA_operations_composed_2_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_2$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_2_OBJECTS) $(operations_composed_2_LDADD) $(LIBS) +operations/composed_3.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_3$(EXEEXT): $(operations_composed_3_OBJECTS) $(operations_composed_3_DEPENDENCIES) $(EXTRA_operations_composed_3_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_3$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_3_OBJECTS) $(operations_composed_3_LDADD) $(LIBS) +operations/composed_4.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_4$(EXEEXT): $(operations_composed_4_OBJECTS) $(operations_composed_4_DEPENDENCIES) $(EXTRA_operations_composed_4_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_4$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_4_OBJECTS) $(operations_composed_4_LDADD) $(LIBS) +operations/composed_5.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_5$(EXEEXT): $(operations_composed_5_OBJECTS) $(operations_composed_5_DEPENDENCIES) $(EXTRA_operations_composed_5_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_5$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_5_OBJECTS) $(operations_composed_5_LDADD) $(LIBS) +operations/composed_6.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_6$(EXEEXT): $(operations_composed_6_OBJECTS) $(operations_composed_6_DEPENDENCIES) $(EXTRA_operations_composed_6_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_6$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_6_OBJECTS) $(operations_composed_6_LDADD) $(LIBS) +operations/composed_7.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_7$(EXEEXT): $(operations_composed_7_OBJECTS) $(operations_composed_7_DEPENDENCIES) $(EXTRA_operations_composed_7_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_7$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_7_OBJECTS) $(operations_composed_7_LDADD) $(LIBS) +operations/composed_8.$(OBJEXT): operations/$(am__dirstamp) \ + operations/$(DEPDIR)/$(am__dirstamp) + +operations/composed_8$(EXEEXT): $(operations_composed_8_OBJECTS) $(operations_composed_8_DEPENDENCIES) $(EXTRA_operations_composed_8_DEPENDENCIES) operations/$(am__dirstamp) + @rm -f operations/composed_8$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(operations_composed_8_OBJECTS) $(operations_composed_8_LDADD) $(LIBS) +type_erasure/$(am__dirstamp): + @$(MKDIR_P) type_erasure + @: > type_erasure/$(am__dirstamp) +type_erasure/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) type_erasure/$(DEPDIR) + @: > type_erasure/$(DEPDIR)/$(am__dirstamp) +type_erasure/main.$(OBJEXT): type_erasure/$(am__dirstamp) \ + type_erasure/$(DEPDIR)/$(am__dirstamp) +type_erasure/stdin_line_reader.$(OBJEXT): \ + type_erasure/$(am__dirstamp) \ + type_erasure/$(DEPDIR)/$(am__dirstamp) +type_erasure/sleep.$(OBJEXT): type_erasure/$(am__dirstamp) \ + type_erasure/$(DEPDIR)/$(am__dirstamp) + +type_erasure/type_erasure$(EXEEXT): $(type_erasure_type_erasure_OBJECTS) $(type_erasure_type_erasure_DEPENDENCIES) $(EXTRA_type_erasure_type_erasure_DEPENDENCIES) type_erasure/$(am__dirstamp) + @rm -f type_erasure/type_erasure$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(type_erasure_type_erasure_OBJECTS) $(type_erasure_type_erasure_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + -rm -f ../../*.$(OBJEXT) + -rm -f channels/*.$(OBJEXT) + -rm -f coroutines/*.$(OBJEXT) + -rm -f invocation/*.$(OBJEXT) + -rm -f operations/*.$(OBJEXT) + -rm -f type_erasure/*.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@../../$(DEPDIR)/asio.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@../../$(DEPDIR)/asio_ssl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@channels/$(DEPDIR)/mutual_exclusion_1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@channels/$(DEPDIR)/mutual_exclusion_2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@channels/$(DEPDIR)/throttling_proxy.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines/$(DEPDIR)/chat_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines/$(DEPDIR)/echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines/$(DEPDIR)/echo_server_with_as_single_default.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines/$(DEPDIR)/echo_server_with_as_tuple_default.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines/$(DEPDIR)/echo_server_with_default.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines/$(DEPDIR)/echo_server_with_deferred.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines/$(DEPDIR)/echo_server_with_deferred_default.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines/$(DEPDIR)/refactored_echo_server.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@coroutines/$(DEPDIR)/timeout.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@invocation/$(DEPDIR)/completion_executor.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/c_callback_wrapper.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/callback_wrapper.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_1.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_3.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_4.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_5.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_6.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_7.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@operations/$(DEPDIR)/composed_8.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@type_erasure/$(DEPDIR)/main.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@type_erasure/$(DEPDIR)/sleep.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@type_erasure/$(DEPDIR)/stdin_line_reader.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f ../../$(DEPDIR)/$(am__dirstamp) + -rm -f ../../$(am__dirstamp) + -rm -f channels/$(DEPDIR)/$(am__dirstamp) + -rm -f channels/$(am__dirstamp) + -rm -f coroutines/$(DEPDIR)/$(am__dirstamp) + -rm -f coroutines/$(am__dirstamp) + -rm -f invocation/$(DEPDIR)/$(am__dirstamp) + -rm -f invocation/$(am__dirstamp) + -rm -f operations/$(DEPDIR)/$(am__dirstamp) + -rm -f operations/$(am__dirstamp) + -rm -f type_erasure/$(DEPDIR)/$(am__dirstamp) + -rm -f type_erasure/$(am__dirstamp) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -f ../../$(DEPDIR)/asio.Po + -rm -f ../../$(DEPDIR)/asio_ssl.Po + -rm -f channels/$(DEPDIR)/mutual_exclusion_1.Po + -rm -f channels/$(DEPDIR)/mutual_exclusion_2.Po + -rm -f channels/$(DEPDIR)/throttling_proxy.Po + -rm -f coroutines/$(DEPDIR)/chat_server.Po + -rm -f coroutines/$(DEPDIR)/echo_server.Po + -rm -f coroutines/$(DEPDIR)/echo_server_with_as_single_default.Po + -rm -f coroutines/$(DEPDIR)/echo_server_with_as_tuple_default.Po + -rm -f coroutines/$(DEPDIR)/echo_server_with_default.Po + -rm -f coroutines/$(DEPDIR)/echo_server_with_deferred.Po + -rm -f coroutines/$(DEPDIR)/echo_server_with_deferred_default.Po + -rm -f coroutines/$(DEPDIR)/refactored_echo_server.Po + -rm -f coroutines/$(DEPDIR)/timeout.Po + -rm -f invocation/$(DEPDIR)/completion_executor.Po + -rm -f operations/$(DEPDIR)/c_callback_wrapper.Po + -rm -f operations/$(DEPDIR)/callback_wrapper.Po + -rm -f operations/$(DEPDIR)/composed_1.Po + -rm -f operations/$(DEPDIR)/composed_2.Po + -rm -f operations/$(DEPDIR)/composed_3.Po + -rm -f operations/$(DEPDIR)/composed_4.Po + -rm -f operations/$(DEPDIR)/composed_5.Po + -rm -f operations/$(DEPDIR)/composed_6.Po + -rm -f operations/$(DEPDIR)/composed_7.Po + -rm -f operations/$(DEPDIR)/composed_8.Po + -rm -f type_erasure/$(DEPDIR)/main.Po + -rm -f type_erasure/$(DEPDIR)/sleep.Po + -rm -f type_erasure/$(DEPDIR)/stdin_line_reader.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ../../$(DEPDIR)/asio.Po + -rm -f ../../$(DEPDIR)/asio_ssl.Po + -rm -f channels/$(DEPDIR)/mutual_exclusion_1.Po + -rm -f channels/$(DEPDIR)/mutual_exclusion_2.Po + -rm -f channels/$(DEPDIR)/throttling_proxy.Po + -rm -f coroutines/$(DEPDIR)/chat_server.Po + -rm -f coroutines/$(DEPDIR)/echo_server.Po + -rm -f coroutines/$(DEPDIR)/echo_server_with_as_single_default.Po + -rm -f coroutines/$(DEPDIR)/echo_server_with_as_tuple_default.Po + -rm -f coroutines/$(DEPDIR)/echo_server_with_default.Po + -rm -f coroutines/$(DEPDIR)/echo_server_with_deferred.Po + -rm -f coroutines/$(DEPDIR)/echo_server_with_deferred_default.Po + -rm -f coroutines/$(DEPDIR)/refactored_echo_server.Po + -rm -f coroutines/$(DEPDIR)/timeout.Po + -rm -f invocation/$(DEPDIR)/completion_executor.Po + -rm -f operations/$(DEPDIR)/c_callback_wrapper.Po + -rm -f operations/$(DEPDIR)/callback_wrapper.Po + -rm -f operations/$(DEPDIR)/composed_1.Po + -rm -f operations/$(DEPDIR)/composed_2.Po + -rm -f operations/$(DEPDIR)/composed_3.Po + -rm -f operations/$(DEPDIR)/composed_4.Po + -rm -f operations/$(DEPDIR)/composed_5.Po + -rm -f operations/$(DEPDIR)/composed_6.Po + -rm -f operations/$(DEPDIR)/composed_7.Po + -rm -f operations/$(DEPDIR)/composed_8.Po + -rm -f type_erasure/$(DEPDIR)/main.Po + -rm -f type_erasure/$(DEPDIR)/sleep.Po + -rm -f type_erasure/$(DEPDIR)/stdin_line_reader.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/3rdparty/asio/src/examples/cpp20/channels/mutual_exclusion_1.cpp b/3rdparty/asio/src/examples/cpp20/channels/mutual_exclusion_1.cpp new file mode 100644 index 00000000000..79654f1e8f1 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/channels/mutual_exclusion_1.cpp @@ -0,0 +1,182 @@ +// +// mutual_exclusion_1.cpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/channel.hpp> +#include <iostream> +#include <memory> + +using asio::as_tuple; +using asio::awaitable; +using asio::dynamic_buffer; +using asio::co_spawn; +using asio::deferred; +using asio::detached; +using asio::experimental::channel; +using asio::io_context; +using asio::ip::tcp; +using asio::steady_timer; +using namespace asio::buffer_literals; +using namespace std::literals::chrono_literals; + +// This class implements a simple line-based protocol: +// +// * For event line that is received from the client, the session sends a +// message header followed by the content of the line as the message body. +// +// * The session generates heartbeat messages once a second. +// +// This protocol is implemented using two actors, handle_messages() and +// send_heartbeats(), each written as a coroutine. +class line_based_echo_session : + public std::enable_shared_from_this<line_based_echo_session> +{ + // The socket used to read from and write to the client. This socket is a + // data member as it is shared between the two actors. + tcp::socket socket_; + + // As both of the actors will write to the socket, we need a lock to prevent + // these writes from overlapping. To achieve this, we use a channel with a + // buffer size of one. The lock is claimed by sending a message to the + // channel, and then released by receiving this message back again. If the + // lock is not held then the channel's buffer is empty, and the send will + // complete without delay. Otherwise, if the lock is held by the other actor, + // then the send operation will not complete until the lock is released. + channel<void()> write_lock_{socket_.get_executor(), 1}; + +public: + line_based_echo_session(tcp::socket socket) + : socket_{std::move(socket)} + { + socket_.set_option(tcp::no_delay(true)); + } + + void start() + { + co_spawn(socket_.get_executor(), + [self = shared_from_this()]{ return self->handle_messages(); }, + detached); + + co_spawn(socket_.get_executor(), + [self = shared_from_this()]{ return self->send_heartbeats(); }, + detached); + } + +private: + void stop() + { + socket_.close(); + write_lock_.cancel(); + } + + awaitable<void> handle_messages() + { + try + { + constexpr std::size_t max_line_length = 1024; + std::string data; + for (;;) + { + // Read an entire line from the client. + std::size_t length = co_await async_read_until(socket_, + dynamic_buffer(data, max_line_length), '\n', deferred); + + // Claim the write lock by sending a message to the channel. Since the + // channel signature is void(), there are no arguments to send in the + // message itself. + co_await write_lock_.async_send(deferred); + + // Respond to the client with a message, echoing the line they sent. + co_await async_write(socket_, "<line>"_buf, deferred); + co_await async_write(socket_, dynamic_buffer(data, length), deferred); + + // Release the lock by receiving the message back again. + write_lock_.try_receive([](auto...){}); + } + } + catch (const std::exception&) + { + stop(); + } + } + + awaitable<void> send_heartbeats() + { + steady_timer timer{socket_.get_executor()}; + try + { + for (;;) + { + // Wait one second before trying to send the next heartbeat. + timer.expires_after(1s); + co_await timer.async_wait(deferred); + + // Claim the write lock by sending a message to the channel. Since the + // channel signature is void(), there are no arguments to send in the + // message itself. + co_await write_lock_.async_send(deferred); + + // Send a heartbeat to the client. As the content of the heartbeat + // message never varies, a buffer literal can be used to specify the + // bytes of the message. The memory associated with a buffer literal is + // valid for the lifetime of the program, which mean that the buffer + // can be safely passed as-is to the asynchronous operation. + co_await async_write(socket_, "<heartbeat>\n"_buf, deferred); + + // Release the lock by receiving the message back again. + write_lock_.try_receive([](auto...){}); + } + } + catch (const std::exception&) + { + stop(); + } + } + +}; + +awaitable<void> listen(tcp::acceptor& acceptor) +{ + for (;;) + { + auto [e, socket] = co_await acceptor.async_accept(as_tuple(deferred)); + if (!e) + { + std::make_shared<line_based_echo_session>(std::move(socket))->start(); + } + } +} + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 3) + { + std::cerr << "Usage: mutual_exclusion_1"; + std::cerr << " <listen_address> <listen_port>\n"; + return 1; + } + + io_context ctx; + + auto listen_endpoint = + *tcp::resolver(ctx).resolve(argv[1], argv[2], + tcp::resolver::passive).begin(); + + tcp::acceptor acceptor(ctx, listen_endpoint); + co_spawn(ctx, listen(acceptor), detached); + ctx.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } +} diff --git a/3rdparty/asio/src/examples/cpp20/channels/mutual_exclusion_2.cpp b/3rdparty/asio/src/examples/cpp20/channels/mutual_exclusion_2.cpp new file mode 100644 index 00000000000..46cfeb647a2 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/channels/mutual_exclusion_2.cpp @@ -0,0 +1,192 @@ +// +// mutual_exclusion_2.cpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/channel.hpp> +#include <iostream> +#include <memory> + +using asio::as_tuple; +using asio::awaitable; +using asio::dynamic_buffer; +using asio::co_spawn; +using asio::deferred; +using asio::detached; +using asio::experimental::channel; +using asio::io_context; +using asio::ip::tcp; +using asio::steady_timer; +using namespace asio::buffer_literals; +using namespace std::literals::chrono_literals; + +// This class implements a simple line-based protocol: +// +// * For event line that is received from the client, the session sends a +// message header followed by the content of the line as the message body. +// +// * The session generates heartbeat messages once a second. +// +// This protocol is implemented using two actors, handle_messages() and +// send_heartbeats(), each written as a coroutine. +class line_based_echo_session : + public std::enable_shared_from_this<line_based_echo_session> +{ + // The socket used to read from and write to the client. This socket is a + // data member as it is shared between the two actors. + tcp::socket socket_; + + // As both of the actors will write to the socket, we need a lock to prevent + // these writes from overlapping. To achieve this, we use a channel with a + // buffer size of one. The lock is claimed by sending a message to the + // channel, and then released by receiving this message back again. If the + // lock is not held then the channel's buffer is empty, and the send will + // complete without delay. Otherwise, if the lock is held by the other actor, + // then the send operation will not complete until the lock is released. + channel<void()> write_lock_{socket_.get_executor(), 1}; + +public: + line_based_echo_session(tcp::socket socket) + : socket_{std::move(socket)} + { + socket_.set_option(tcp::no_delay(true)); + } + + void start() + { + co_spawn(socket_.get_executor(), + [self = shared_from_this()]{ return self->handle_messages(); }, + detached); + + co_spawn(socket_.get_executor(), + [self = shared_from_this()]{ return self->send_heartbeats(); }, + detached); + } + +private: + void stop() + { + socket_.close(); + write_lock_.cancel(); + } + + awaitable<void> handle_messages() + { + try + { + constexpr std::size_t max_line_length = 1024; + std::string data; + for (;;) + { + // Read an entire line from the client. + std::size_t length = co_await async_read_until(socket_, + dynamic_buffer(data, max_line_length), '\n', deferred); + + // Claim the write lock by sending a message to the channel. Since the + // channel signature is void(), there are no arguments to send in the + // message itself. In this example we optimise for the common case, + // where the lock is not held by the other actor, by first trying a + // non-blocking send. + if (!write_lock_.try_send()) + { + co_await write_lock_.async_send(deferred); + } + + // Respond to the client with a message, echoing the line they sent. + co_await async_write(socket_, "<line>"_buf, deferred); + co_await async_write(socket_, dynamic_buffer(data, length), deferred); + + // Release the lock by receiving the message back again. + write_lock_.try_receive([](auto...){}); + } + } + catch (const std::exception&) + { + stop(); + } + } + + awaitable<void> send_heartbeats() + { + steady_timer timer{socket_.get_executor()}; + try + { + for (;;) + { + // Wait one second before trying to send the next heartbeat. + timer.expires_after(1s); + co_await timer.async_wait(deferred); + + // Claim the write lock by sending a message to the channel. Since the + // channel signature is void(), there are no arguments to send in the + // message itself. In this example we optimise for the common case, + // where the lock is not held by the other actor, by first trying a + // non-blocking send. + if (!write_lock_.try_send()) + { + co_await write_lock_.async_send(deferred); + } + + // Send a heartbeat to the client. As the content of the heartbeat + // message never varies, a buffer literal can be used to specify the + // bytes of the message. The memory associated with a buffer literal is + // valid for the lifetime of the program, which mean that the buffer + // can be safely passed as-is to the asynchronous operation. + co_await async_write(socket_, "<heartbeat>\n"_buf, deferred); + + // Release the lock by receiving the message back again. + write_lock_.try_receive([](auto...){}); + } + } + catch (const std::exception&) + { + stop(); + } + } + +}; + +awaitable<void> listen(tcp::acceptor& acceptor) +{ + for (;;) + { + auto [e, socket] = co_await acceptor.async_accept(as_tuple(deferred)); + if (!e) + { + std::make_shared<line_based_echo_session>(std::move(socket))->start(); + } + } +} + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 3) + { + std::cerr << "Usage: mutual_exclusion_1"; + std::cerr << " <listen_address> <listen_port>\n"; + return 1; + } + + io_context ctx; + + auto listen_endpoint = + *tcp::resolver(ctx).resolve(argv[1], argv[2], + tcp::resolver::passive).begin(); + + tcp::acceptor acceptor(ctx, listen_endpoint); + co_spawn(ctx, listen(acceptor), detached); + ctx.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } +} diff --git a/3rdparty/asio/src/examples/cpp20/channels/throttling_proxy.cpp b/3rdparty/asio/src/examples/cpp20/channels/throttling_proxy.cpp new file mode 100644 index 00000000000..c54d2986af7 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/channels/throttling_proxy.cpp @@ -0,0 +1,135 @@ +// +// throttling_proxy.cpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/awaitable_operators.hpp> +#include <asio/experimental/channel.hpp> +#include <iostream> + +using asio::as_tuple; +using asio::awaitable; +using asio::buffer; +using asio::co_spawn; +using asio::detached; +using asio::experimental::channel; +using asio::io_context; +using asio::ip::tcp; +using asio::steady_timer; +using asio::use_awaitable; +namespace this_coro = asio::this_coro; +using namespace asio::experimental::awaitable_operators; +using namespace std::literals::chrono_literals; + +using token_channel = channel<void(asio::error_code, std::size_t)>; + +awaitable<void> produce_tokens(std::size_t bytes_per_token, + steady_timer::duration token_interval, token_channel& tokens) +{ + steady_timer timer(co_await this_coro::executor); + for (;;) + { + co_await tokens.async_send( + asio::error_code{}, bytes_per_token, + use_awaitable); + + timer.expires_after(token_interval); + co_await timer.async_wait(use_awaitable); + } +} + +awaitable<void> transfer(tcp::socket& from, + tcp::socket& to, token_channel& tokens) +{ + std::array<unsigned char, 4096> data; + for (;;) + { + std::size_t bytes_available = co_await tokens.async_receive(use_awaitable); + while (bytes_available > 0) + { + std::size_t n = co_await from.async_read_some( + buffer(data, bytes_available), use_awaitable); + + co_await async_write(to, buffer(data, n), use_awaitable); + + bytes_available -= n; + } + } +} + +awaitable<void> proxy(tcp::socket client, tcp::endpoint target) +{ + constexpr std::size_t number_of_tokens = 100; + constexpr size_t bytes_per_token = 20 * 1024; + constexpr steady_timer::duration token_interval = 100ms; + + auto ex = client.get_executor(); + tcp::socket server(ex); + token_channel client_tokens(ex, number_of_tokens); + token_channel server_tokens(ex, number_of_tokens); + + co_await server.async_connect(target, use_awaitable); + co_await ( + produce_tokens(bytes_per_token, token_interval, client_tokens) && + transfer(client, server, client_tokens) && + produce_tokens(bytes_per_token, token_interval, server_tokens) && + transfer(server, client, server_tokens) + ); +} + +awaitable<void> listen(tcp::acceptor& acceptor, tcp::endpoint target) +{ + for (;;) + { + auto [e, client] = co_await acceptor.async_accept(as_tuple(use_awaitable)); + if (!e) + { + auto ex = client.get_executor(); + co_spawn(ex, proxy(std::move(client), target), detached); + } + else + { + std::cerr << "Accept failed: " << e.message() << "\n"; + steady_timer timer(co_await this_coro::executor); + timer.expires_after(100ms); + co_await timer.async_wait(use_awaitable); + } + } +} + +int main(int argc, char* argv[]) +{ + try + { + if (argc != 5) + { + std::cerr << "Usage: throttling_proxy"; + std::cerr << " <listen_address> <listen_port>"; + std::cerr << " <target_address> <target_port>\n"; + return 1; + } + + io_context ctx; + + auto listen_endpoint = + *tcp::resolver(ctx).resolve(argv[1], argv[2], + tcp::resolver::passive).begin(); + + auto target_endpoint = + *tcp::resolver(ctx).resolve(argv[3], argv[4]).begin(); + + tcp::acceptor acceptor(ctx, listen_endpoint); + co_spawn(ctx, listen(acceptor, target_endpoint), detached); + ctx.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } +} diff --git a/3rdparty/asio/src/examples/cpp20/coroutines/chat_server.cpp b/3rdparty/asio/src/examples/cpp20/coroutines/chat_server.cpp new file mode 100644 index 00000000000..cd5fba32486 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/coroutines/chat_server.cpp @@ -0,0 +1,222 @@ +// +// chat_server.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <cstdlib> +#include <deque> +#include <iostream> +#include <list> +#include <memory> +#include <set> +#include <string> +#include <utility> +#include <asio/awaitable.hpp> +#include <asio/detached.hpp> +#include <asio/co_spawn.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/read_until.hpp> +#include <asio/redirect_error.hpp> +#include <asio/signal_set.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_awaitable.hpp> +#include <asio/write.hpp> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::redirect_error; +using asio::use_awaitable; + +//---------------------------------------------------------------------- + +class chat_participant +{ +public: + virtual ~chat_participant() {} + virtual void deliver(const std::string& msg) = 0; +}; + +typedef std::shared_ptr<chat_participant> chat_participant_ptr; + +//---------------------------------------------------------------------- + +class chat_room +{ +public: + void join(chat_participant_ptr participant) + { + participants_.insert(participant); + for (auto msg: recent_msgs_) + participant->deliver(msg); + } + + void leave(chat_participant_ptr participant) + { + participants_.erase(participant); + } + + void deliver(const std::string& msg) + { + recent_msgs_.push_back(msg); + while (recent_msgs_.size() > max_recent_msgs) + recent_msgs_.pop_front(); + + for (auto participant: participants_) + participant->deliver(msg); + } + +private: + std::set<chat_participant_ptr> participants_; + enum { max_recent_msgs = 100 }; + std::deque<std::string> recent_msgs_; +}; + +//---------------------------------------------------------------------- + +class chat_session + : public chat_participant, + public std::enable_shared_from_this<chat_session> +{ +public: + chat_session(tcp::socket socket, chat_room& room) + : socket_(std::move(socket)), + timer_(socket_.get_executor()), + room_(room) + { + timer_.expires_at(std::chrono::steady_clock::time_point::max()); + } + + void start() + { + room_.join(shared_from_this()); + + co_spawn(socket_.get_executor(), + [self = shared_from_this()]{ return self->reader(); }, + detached); + + co_spawn(socket_.get_executor(), + [self = shared_from_this()]{ return self->writer(); }, + detached); + } + + void deliver(const std::string& msg) + { + write_msgs_.push_back(msg); + timer_.cancel_one(); + } + +private: + awaitable<void> reader() + { + try + { + for (std::string read_msg;;) + { + std::size_t n = co_await asio::async_read_until(socket_, + asio::dynamic_buffer(read_msg, 1024), "\n", use_awaitable); + + room_.deliver(read_msg.substr(0, n)); + read_msg.erase(0, n); + } + } + catch (std::exception&) + { + stop(); + } + } + + awaitable<void> writer() + { + try + { + while (socket_.is_open()) + { + if (write_msgs_.empty()) + { + asio::error_code ec; + co_await timer_.async_wait(redirect_error(use_awaitable, ec)); + } + else + { + co_await asio::async_write(socket_, + asio::buffer(write_msgs_.front()), use_awaitable); + write_msgs_.pop_front(); + } + } + } + catch (std::exception&) + { + stop(); + } + } + + void stop() + { + room_.leave(shared_from_this()); + socket_.close(); + timer_.cancel(); + } + + tcp::socket socket_; + asio::steady_timer timer_; + chat_room& room_; + std::deque<std::string> write_msgs_; +}; + +//---------------------------------------------------------------------- + +awaitable<void> listener(tcp::acceptor acceptor) +{ + chat_room room; + + for (;;) + { + std::make_shared<chat_session>( + co_await acceptor.async_accept(use_awaitable), + room + )->start(); + } +} + +//---------------------------------------------------------------------- + +int main(int argc, char* argv[]) +{ + try + { + if (argc < 2) + { + std::cerr << "Usage: chat_server <port> [<port> ...]\n"; + return 1; + } + + asio::io_context io_context(1); + + for (int i = 1; i < argc; ++i) + { + unsigned short port = std::atoi(argv[i]); + co_spawn(io_context, + listener(tcp::acceptor(io_context, {tcp::v4(), port})), + detached); + } + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + io_context.run(); + } + catch (std::exception& e) + { + std::cerr << "Exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp20/coroutines/echo_server.cpp b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server.cpp new file mode 100644 index 00000000000..a9532459f77 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server.cpp @@ -0,0 +1,76 @@ +// +// echo_server.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable; +namespace this_coro = asio::this_coro; + +#if defined(ASIO_ENABLE_HANDLER_TRACKING) +# define use_awaitable \ + asio::use_awaitable_t(__FILE__, __LINE__, __PRETTY_FUNCTION__) +#endif + +awaitable<void> echo(tcp::socket socket) +{ + try + { + char data[1024]; + for (;;) + { + std::size_t n = co_await socket.async_read_some(asio::buffer(data), use_awaitable); + co_await async_write(socket, asio::buffer(data, n), use_awaitable); + } + } + catch (std::exception& e) + { + std::printf("echo Exception: %s\n", e.what()); + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp::acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + tcp::socket socket = co_await acceptor.async_accept(use_awaitable); + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_as_single_default.cpp b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_as_single_default.cpp new file mode 100644 index 00000000000..4a692acc872 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_as_single_default.cpp @@ -0,0 +1,71 @@ +// +// echo_server_with_as_single_default.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/experimental/as_single.hpp> +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::experimental::as_single_t; +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable_t; +using default_token = as_single_t<use_awaitable_t<>>; +using tcp_acceptor = default_token::as_default_on_t<tcp::acceptor>; +using tcp_socket = default_token::as_default_on_t<tcp::socket>; +namespace this_coro = asio::this_coro; + +awaitable<void> echo(tcp_socket socket) +{ + char data[1024]; + for (;;) + { + auto [e1, nread] = co_await socket.async_read_some(asio::buffer(data)); + if (nread == 0) break; + auto [e2, nwritten] = co_await async_write(socket, asio::buffer(data, nread)); + if (nwritten != nread) break; + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp_acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + if (auto [e, socket] = co_await acceptor.async_accept(); socket.is_open()) + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_as_tuple_default.cpp b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_as_tuple_default.cpp new file mode 100644 index 00000000000..de162cad78e --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_as_tuple_default.cpp @@ -0,0 +1,71 @@ +// +// echo_server_with_as_tuple_default.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/as_tuple.hpp> +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::as_tuple_t; +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable_t; +using default_token = as_tuple_t<use_awaitable_t<>>; +using tcp_acceptor = default_token::as_default_on_t<tcp::acceptor>; +using tcp_socket = default_token::as_default_on_t<tcp::socket>; +namespace this_coro = asio::this_coro; + +awaitable<void> echo(tcp_socket socket) +{ + char data[1024]; + for (;;) + { + auto [e1, nread] = co_await socket.async_read_some(asio::buffer(data)); + if (nread == 0) break; + auto [e2, nwritten] = co_await async_write(socket, asio::buffer(data, nread)); + if (nwritten != nread) break; + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp_acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + if (auto [e, socket] = co_await acceptor.async_accept(); socket.is_open()) + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_default.cpp b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_default.cpp new file mode 100644 index 00000000000..54344d94d56 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_default.cpp @@ -0,0 +1,73 @@ +// +// echo_server_with_default.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable_t; +using tcp_acceptor = use_awaitable_t<>::as_default_on_t<tcp::acceptor>; +using tcp_socket = use_awaitable_t<>::as_default_on_t<tcp::socket>; +namespace this_coro = asio::this_coro; + +awaitable<void> echo(tcp_socket socket) +{ + try + { + char data[1024]; + for (;;) + { + std::size_t n = co_await socket.async_read_some(asio::buffer(data)); + co_await async_write(socket, asio::buffer(data, n)); + } + } + catch (std::exception& e) + { + std::printf("echo Exception: %s\n", e.what()); + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp_acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + auto socket = co_await acceptor.async_accept(); + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_deferred.cpp b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_deferred.cpp new file mode 100644 index 00000000000..54469ba7aba --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_deferred.cpp @@ -0,0 +1,72 @@ +// +// echo_server.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/deferred.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::deferred; +using asio::detached; +namespace this_coro = asio::this_coro; + +awaitable<void> echo(tcp::socket socket) +{ + try + { + char data[1024]; + for (;;) + { + std::size_t n = co_await socket.async_read_some(asio::buffer(data), deferred); + co_await async_write(socket, asio::buffer(data, n), deferred); + } + } + catch (std::exception& e) + { + std::printf("echo Exception: %s\n", e.what()); + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp::acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + tcp::socket socket = co_await acceptor.async_accept(deferred); + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_deferred_default.cpp b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_deferred_default.cpp new file mode 100644 index 00000000000..33c383311d2 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/coroutines/echo_server_with_deferred_default.cpp @@ -0,0 +1,74 @@ +// +// echo_server.cpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/deferred.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using default_token = asio::deferred_t; +using tcp_acceptor = default_token::as_default_on_t<tcp::acceptor>; +using tcp_socket = default_token::as_default_on_t<tcp::socket>; +namespace this_coro = asio::this_coro; + +awaitable<void> echo(tcp_socket socket) +{ + try + { + char data[1024]; + for (;;) + { + std::size_t n = co_await socket.async_read_some(asio::buffer(data)); + co_await async_write(socket, asio::buffer(data, n)); + } + } + catch (std::exception& e) + { + std::printf("echo Exception: %s\n", e.what()); + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp_acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + tcp::socket socket = co_await acceptor.async_accept(); + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp20/coroutines/refactored_echo_server.cpp b/3rdparty/asio/src/examples/cpp20/coroutines/refactored_echo_server.cpp new file mode 100644 index 00000000000..dc7b03d86e2 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/coroutines/refactored_echo_server.cpp @@ -0,0 +1,80 @@ +// +// refactored_echo_server.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/signal_set.hpp> +#include <asio/write.hpp> +#include <cstdio> + +using asio::ip::tcp; +using asio::awaitable; +using asio::co_spawn; +using asio::detached; +using asio::use_awaitable; +namespace this_coro = asio::this_coro; + +awaitable<void> echo_once(tcp::socket& socket) +{ + char data[128]; + std::size_t n = co_await socket.async_read_some(asio::buffer(data), use_awaitable); + co_await async_write(socket, asio::buffer(data, n), use_awaitable); +} + +awaitable<void> echo(tcp::socket socket) +{ + try + { + for (;;) + { + // The asynchronous operations to echo a single chunk of data have been + // refactored into a separate function. When this function is called, the + // operations are still performed in the context of the current + // coroutine, and the behaviour is functionally equivalent. + co_await echo_once(socket); + } + } + catch (std::exception& e) + { + std::printf("echo Exception: %s\n", e.what()); + } +} + +awaitable<void> listener() +{ + auto executor = co_await this_coro::executor; + tcp::acceptor acceptor(executor, {tcp::v4(), 55555}); + for (;;) + { + tcp::socket socket = co_await acceptor.async_accept(use_awaitable); + co_spawn(executor, echo(std::move(socket)), detached); + } +} + +int main() +{ + try + { + asio::io_context io_context(1); + + asio::signal_set signals(io_context, SIGINT, SIGTERM); + signals.async_wait([&](auto, auto){ io_context.stop(); }); + + co_spawn(io_context, listener(), detached); + + io_context.run(); + } + catch (std::exception& e) + { + std::printf("Exception: %s\n", e.what()); + } +} diff --git a/3rdparty/asio/src/examples/cpp20/coroutines/timeout.cpp b/3rdparty/asio/src/examples/cpp20/coroutines/timeout.cpp new file mode 100644 index 00000000000..2ffcab7ad35 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/coroutines/timeout.cpp @@ -0,0 +1,66 @@ +// +// timeout.cpp +// ~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <asio/experimental/awaitable_operators.hpp> + +using namespace asio; +using namespace asio::experimental::awaitable_operators; +using time_point = std::chrono::steady_clock::time_point; +using ip::tcp; + +awaitable<void> echo(tcp::socket& sock, time_point& deadline) +{ + char data[4196]; + for (;;) + { + deadline = std::chrono::steady_clock::now() + std::chrono::seconds(10); + auto n = co_await sock.async_read_some(buffer(data), use_awaitable); + co_await async_write(sock, buffer(data, n), use_awaitable); + } +} + +awaitable<void> watchdog(time_point& deadline) +{ + steady_timer timer(co_await this_coro::executor); + auto now = std::chrono::steady_clock::now(); + while (deadline > now) + { + timer.expires_at(deadline); + co_await timer.async_wait(use_awaitable); + now = std::chrono::steady_clock::now(); + } + throw std::system_error(std::make_error_code(std::errc::timed_out)); +} + +awaitable<void> handle_connection(tcp::socket sock) +{ + time_point deadline{}; + co_await (echo(sock, deadline) && watchdog(deadline)); +} + +awaitable<void> listen(tcp::acceptor& acceptor) +{ + for (;;) + { + co_spawn( + acceptor.get_executor(), + handle_connection(co_await acceptor.async_accept(use_awaitable)), + detached); + } +} + +int main() +{ + io_context ctx; + tcp::acceptor acceptor(ctx, {tcp::v4(), 54321}); + co_spawn(ctx, listen(acceptor), detached); + ctx.run(); +} diff --git a/3rdparty/asio/src/examples/cpp20/invocation/completion_executor.cpp b/3rdparty/asio/src/examples/cpp20/invocation/completion_executor.cpp new file mode 100644 index 00000000000..409be96d0f4 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/invocation/completion_executor.cpp @@ -0,0 +1,83 @@ +// +// completion_executor.cpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "asio.hpp" +#include <concepts> +#include <iostream> + +using asio::ip::tcp; + +//---------------------------------------------------------------------- + +// The logging_executor class implements a minimal executor that satisfies the +// requirements for use as a completion executor. This means it may be bound to +// a handler using bind_executor. +class logging_executor +{ +public: + // All executors must be no-throw equality comparable. + bool operator==(const logging_executor&) const noexcept = default; + + // All executors must provide a const member function execute(). + void execute(std::invocable auto handler) const + { + try + { + std::cout << "handler invocation starting\n"; + std::move(handler)(); + std::cout << "handler invocation complete\n"; + } + catch (...) + { + std::cout << "handler invocation completed with exception\n"; + throw; + } + } +}; + +// Confirm that a logging_executor satisfies the executor requirements. +static_assert(asio::execution::executor<logging_executor>); + +// Confirm that a logging_executor can be used as a completion executor. +static_assert(std::convertible_to< + logging_executor, asio::any_completion_executor>); + +//---------------------------------------------------------------------- + +int main() +{ + asio::io_context io_context(1); + + // Post a completion handler to be run immediately. + asio::post(io_context, + asio::bind_executor(logging_executor{}, + []{ std::cout << "post complete\n"; })); + + // Start an asynchronous accept that will complete immediately. + tcp::endpoint endpoint(asio::ip::address_v4::loopback(), 0); + tcp::acceptor acceptor(io_context, endpoint); + tcp::socket server_socket(io_context); + acceptor.async_accept( + asio::bind_executor(logging_executor{}, + [](auto...){ std::cout << "async_accept complete\n"; })); + tcp::socket client_socket(io_context); + client_socket.connect(acceptor.local_endpoint()); + + // Set a timer to expire immediately. + asio::steady_timer timer(io_context); + timer.expires_at(asio::steady_timer::clock_type::time_point::min()); + timer.async_wait( + asio::bind_executor(logging_executor{}, + [](auto){ std::cout << "async_wait complete\n"; })); + + io_context.run(); + + return 0; +} diff --git a/3rdparty/asio/src/examples/cpp20/operations/c_callback_wrapper.cpp b/3rdparty/asio/src/examples/cpp20/operations/c_callback_wrapper.cpp new file mode 100644 index 00000000000..f4fbe2617ea --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/operations/c_callback_wrapper.cpp @@ -0,0 +1,232 @@ +// +// c_callback_wrapper.cpp +// ~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> +#include <memory> +#include <new> + +//------------------------------------------------------------------------------ + +// This is a mock implementation of a C-based API that uses the function pointer +// plus void* context idiom for exposing a callback. + +void read_input(const char* prompt, void (*cb)(void*, const char*), void* arg) +{ + std::thread( + [prompt = std::string(prompt), cb, arg] + { + std::cout << prompt << ": "; + std::cout.flush(); + std::string line; + std::getline(std::cin, line); + cb(arg, line.c_str()); + }).detach(); +} + +//------------------------------------------------------------------------------ + +// This is an asynchronous operation that wraps the C-based API. + +// To map our completion handler into a function pointer / void* callback, we +// need to allocate some state that will live for the duration of the +// operation. A pointer to this state will be passed to the C-based API. +template <asio::completion_handler_for<void(std::string)> Handler> +class read_input_state +{ +public: + read_input_state(Handler&& handler) + : handler_(std::move(handler)), + work_(asio::make_work_guard(handler_)) + { + } + + // Create the state using the handler's associated allocator. + static read_input_state* create(Handler&& handler) + { + // A unique_ptr deleter that is used to destroy uninitialised objects. + struct deleter + { + // Get the handler's associated allocator type. If the handler does not + // specify an associated allocator, we will use a recycling allocator as + // the default. As the associated allocator is a proto-allocator, we must + // rebind it to the correct type before we can use it to allocate objects. + typename std::allocator_traits< + asio::associated_allocator_t<Handler, + asio::recycling_allocator<void>>>::template + rebind_alloc<read_input_state> alloc; + + void operator()(read_input_state* ptr) + { + std::allocator_traits<decltype(alloc)>::deallocate(alloc, ptr, 1); + } + } d{asio::get_associated_allocator(handler, + asio::recycling_allocator<void>())}; + + // Allocate memory for the state. + std::unique_ptr<read_input_state, deleter> uninit_ptr( + std::allocator_traits<decltype(d.alloc)>::allocate(d.alloc, 1), d); + + // Construct the state into the newly allocated memory. This might throw. + read_input_state* ptr = + new (uninit_ptr.get()) read_input_state(std::move(handler)); + + // Release ownership of the memory and return the newly allocated state. + uninit_ptr.release(); + return ptr; + } + + static void callback(void* arg, const char* result) + { + read_input_state* self = static_cast<read_input_state*>(arg); + + // A unique_ptr deleter that is used to destroy initialised objects. + struct deleter + { + // Get the handler's associated allocator type. If the handler does not + // specify an associated allocator, we will use a recycling allocator as + // the default. As the associated allocator is a proto-allocator, we must + // rebind it to the correct type before we can use it to allocate objects. + typename std::allocator_traits< + asio::associated_allocator_t<Handler, + asio::recycling_allocator<void>>>::template + rebind_alloc<read_input_state> alloc; + + void operator()(read_input_state* ptr) + { + std::allocator_traits<decltype(alloc)>::destroy(alloc, ptr); + std::allocator_traits<decltype(alloc)>::deallocate(alloc, ptr, 1); + } + } d{asio::get_associated_allocator(self->handler_, + asio::recycling_allocator<void>())}; + + // To conform to the rules regarding asynchronous operations and memory + // allocation, we must make a copy of the state and deallocate the memory + // before dispatching the completion handler. + std::unique_ptr<read_input_state, deleter> state_ptr(self, d); + read_input_state state(std::move(*self)); + state_ptr.reset(); + + // Dispatch the completion handler through the handler's associated + // executor, using the handler's associated allocator. + asio::dispatch(state.work_.get_executor(), + asio::bind_allocator(d.alloc, + [ + handler = std::move(state.handler_), + result = std::string(result) + ]() mutable + { + std::move(handler)(result); + })); + } + +private: + Handler handler_; + + // According to the rules for asynchronous operations, we need to track + // outstanding work against the handler's associated executor until the + // asynchronous operation is complete. + asio::executor_work_guard< + asio::associated_executor_t<Handler>> work_; +}; + +// The initiating function for the asynchronous operation. +template <asio::completion_token_for<void(std::string)> CompletionToken> +auto async_read_input(const std::string& prompt, CompletionToken&& token) +{ + // Define a function object that contains the code to launch the asynchronous + // operation. This is passed the concrete completion handler, followed by any + // additional arguments that were passed through the call to async_initiate. + auto init = []( + asio::completion_handler_for<void(std::string)> auto handler, + const std::string& prompt) + { + // The body of the initiation function object creates the long-lived state + // and passes it to the C-based API, along with the function pointer. + using state_type = read_input_state<decltype(handler)>; + read_input(prompt.c_str(), &state_type::callback, + state_type::create(std::move(handler))); + }; + + // The async_initiate function is used to transform the supplied completion + // token to the completion handler. When calling this function we explicitly + // specify the completion signature of the operation. We must also return the + // result of the call since the completion token may produce a return value, + // such as a future. + return asio::async_initiate<CompletionToken, void(std::string)>( + init, // First, pass the function object that launches the operation, + token, // then the completion token that will be transformed to a handler, + prompt); // and, finally, any additional arguments to the function object. +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + // Test our asynchronous operation using a lambda as a callback. We will use + // an io_context to obtain an associated executor. + async_read_input("Enter your name", + asio::bind_executor(io_context, + [](const std::string& result) + { + std::cout << "Hello " << result << "\n"; + })); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_read_input("Enter your name", asio::deferred); + + // Launch our asynchronous operation using a lambda as a callback. We will use + // an io_context to obtain an associated executor. + std::move(op)( + asio::bind_executor(io_context, + [](const std::string& result) + { + std::cout << "Hello " << result << "\n"; + })); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<std::string> f = + async_read_input("Enter your name", asio::use_future); + + std::string result = f.get(); + std::cout << "Hello " << result << "\n"; +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp20/operations/callback_wrapper.cpp b/3rdparty/asio/src/examples/cpp20/operations/callback_wrapper.cpp new file mode 100644 index 00000000000..f8f37b48944 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/operations/callback_wrapper.cpp @@ -0,0 +1,154 @@ +// +// callback_wrapper.cpp +// ~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio.hpp> +#include <iostream> + +//------------------------------------------------------------------------------ + +// This is a mock implementation of an API that uses a move-only function object +// for exposing a callback. The callback has the signature void(std::string). + +template <typename Callback> +void read_input(const std::string& prompt, Callback cb) +{ + std::thread( + [prompt, cb = std::move(cb)]() mutable + { + std::cout << prompt << ": "; + std::cout.flush(); + std::string line; + std::getline(std::cin, line); + std::move(cb)(std::move(line)); + }).detach(); +} + +//------------------------------------------------------------------------------ + +// This is an asynchronous operation that wraps the callback-based API. + +// The initiating function for the asynchronous operation. +template <asio::completion_token_for<void(std::string)> CompletionToken> +auto async_read_input(const std::string& prompt, CompletionToken&& token) +{ + // Define a function object that contains the code to launch the asynchronous + // operation. This is passed the concrete completion handler, followed by any + // additional arguments that were passed through the call to async_initiate. + auto init = []( + asio::completion_handler_for<void(std::string)> auto handler, + const std::string& prompt) + { + // According to the rules for asynchronous operations, we need to track + // outstanding work against the handler's associated executor until the + // asynchronous operation is complete. + auto work = asio::make_work_guard(handler); + + // Launch the operation with a callback that will receive the result and + // pass it through to the asynchronous operation's completion handler. + read_input(prompt, + [ + handler = std::move(handler), + work = std::move(work) + ](std::string result) mutable + { + // Get the handler's associated allocator. If the handler does not + // specify an allocator, use the recycling allocator as the default. + auto alloc = asio::get_associated_allocator( + handler, asio::recycling_allocator<void>()); + + // Dispatch the completion handler through the handler's associated + // executor, using the handler's associated allocator. + asio::dispatch(work.get_executor(), + asio::bind_allocator(alloc, + [ + handler = std::move(handler), + result = std::string(result) + ]() mutable + { + std::move(handler)(result); + })); + }); + }; + + // The async_initiate function is used to transform the supplied completion + // token to the completion handler. When calling this function we explicitly + // specify the completion signature of the operation. We must also return the + // result of the call since the completion token may produce a return value, + // such as a future. + return asio::async_initiate<CompletionToken, void(std::string)>( + init, // First, pass the function object that launches the operation, + token, // then the completion token that will be transformed to a handler, + prompt); // and, finally, any additional arguments to the function object. +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + // Test our asynchronous operation using a lambda as a callback. We will use + // an io_context to specify an associated executor. + async_read_input("Enter your name", + asio::bind_executor(io_context, + [](const std::string& result) + { + std::cout << "Hello " << result << "\n"; + })); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + auto op = async_read_input("Enter your name", asio::deferred); + + // Launch our asynchronous operation using a lambda as a callback. We will use + // an io_context to obtain an associated executor. + std::move(op)( + asio::bind_executor(io_context, + [](const std::string& result) + { + std::cout << "Hello " << result << "\n"; + })); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<std::string> f = + async_read_input("Enter your name", asio::use_future); + + std::string result = f.get(); + std::cout << "Hello " << result << "\n"; +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp20/operations/composed_1.cpp b/3rdparty/asio/src/examples/cpp20/operations/composed_1.cpp new file mode 100644 index 00000000000..e7f795e1756 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/operations/composed_1.cpp @@ -0,0 +1,157 @@ +// +// composed_1.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +//------------------------------------------------------------------------------ + +// This is the simplest example of a composed asynchronous operation, where we +// simply repackage an existing operation. The asynchronous operation +// requirements are met by delegating responsibility to the underlying +// operation. + +template < + asio::completion_token_for<void(std::error_code, std::size_t)> + CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is void. + // However, when the completion token is asio::yield_context (used for + // stackful coroutines) the return type would be std::size_t, and when the + // completion token is asio::use_future it would be std::future<std::size_t>. + // When the completion token is asio::deferred, the return type differs for + // each asynchronous operation. + // + // In C++20 we can omit the return type as it is automatically deduced from + // the return type of our underlying asynchronous operation. +{ + // When delegating to the underlying operation we must take care to perfectly + // forward the completion token. This ensures that our operation works + // correctly with move-only function objects as callbacks, as well as other + // completion token types. + return asio::async_write(socket, + asio::buffer(message, std::strlen(message)), + std::forward<CompletionToken>(token)); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "Testing callback\r\n", + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + asio::async_operation auto op = async_write_message( + socket, "Testing deferred\r\n", asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<std::size_t> f = async_write_message( + socket, "Testing future\r\n", asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + std::size_t n = f.get(); + std::cout << n << " bytes transferred\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp20/operations/composed_2.cpp b/3rdparty/asio/src/examples/cpp20/operations/composed_2.cpp new file mode 100644 index 00000000000..ada029d38f0 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/operations/composed_2.cpp @@ -0,0 +1,225 @@ +// +// composed_2.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This next simplest example of a composed asynchronous operation involves +// repackaging multiple operations but choosing to invoke just one of them. All +// of these underlying operations have the same completion signature. The +// asynchronous operation requirements are met by delegating responsibility to +// the underlying operations. + +template < + asio::completion_token_for<void(std::error_code, std::size_t)> + CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, bool allow_partial_write, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is void. + // However, when the completion token is asio::yield_context (used for + // stackful coroutines) the return type would be std::size_t, and when the + // completion token is asio::use_future it would be std::future<std::size_t>. + // When the completion token is asio::deferred, the return type differs for + // each asynchronous operation. + // + // In C++20 we can omit the return type as it is automatically deduced from + // the return type of asio::async_initiate. +{ + // In addition to determining the mechanism by which an asynchronous + // operation delivers its result, a completion token also determines the time + // when the operation commences. For example, when the completion token is a + // simple callback the operation commences before the initiating function + // returns. However, if the completion token's delivery mechanism uses a + // future, we might instead want to defer initiation of the operation until + // the returned future object is waited upon. + // + // To enable this, when implementing an asynchronous operation we must + // package the initiation step as a function object. The initiation function + // object's call operator is passed the concrete completion handler produced + // by the completion token. This completion handler matches the asynchronous + // operation's completion handler signature, which in this example is: + // + // void(std::error_code error, std::size_t) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments in the lambda capture set. However, we should prefer to + // propagate them as function call arguments as this allows the completion + // token to optimise how they are passed. For example, a lazy future which + // defers initiation would need to make a decay-copy of the arguments, but + // when using a simple callback the arguments can be trivially forwarded + // straight through.) + auto initiation = []( + asio::completion_handler_for<void(std::error_code, std::size_t)> + auto&& completion_handler, + tcp::socket& socket, + const char* message, + bool allow_partial_write) + { + if (allow_partial_write) + { + // When delegating to an underlying operation we must take care to + // perfectly forward the completion handler. This ensures that our + // operation works correctly with move-only function objects as + // callbacks. + return socket.async_write_some( + asio::buffer(message, std::strlen(message)), + std::forward<decltype(completion_handler)>(completion_handler)); + } + else + { + // As above, we must perfectly forward the completion handler when calling + // the alternate underlying operation. + return asio::async_write(socket, + asio::buffer(message, std::strlen(message)), + std::forward<decltype(completion_handler)>(completion_handler)); + } + }; + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code, std::size_t)>( + initiation, token, std::ref(socket), message, allow_partial_write); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "Testing callback\r\n", false, + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + asio::async_operation auto op = async_write_message( + socket, "Testing deferred\r\n", false, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error, std::size_t n) + { + if (!error) + { + std::cout << n << " bytes transferred\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<std::size_t> f = async_write_message( + socket, "Testing future\r\n", false, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + std::size_t n = f.get(); + std::cout << n << " bytes transferred\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp20/operations/composed_3.cpp b/3rdparty/asio/src/examples/cpp20/operations/composed_3.cpp new file mode 100644 index 00000000000..46436a68e28 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/operations/composed_3.cpp @@ -0,0 +1,232 @@ +// +// composed_3.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/bind_executor.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <functional> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// In this composed operation we repackage an existing operation, but with a +// different completion handler signature. The asynchronous operation +// requirements are met by delegating responsibility to the underlying +// operation. + +template < + asio::completion_token_for<void(std::error_code)> CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++20 we can omit the return type as it is automatically deduced from + // the return type of asio::async_initiate. +{ + // In addition to determining the mechanism by which an asynchronous + // operation delivers its result, a completion token also determines the time + // when the operation commences. For example, when the completion token is a + // simple callback the operation commences before the initiating function + // returns. However, if the completion token's delivery mechanism uses a + // future, we might instead want to defer initiation of the operation until + // the returned future object is waited upon. + // + // To enable this, when implementing an asynchronous operation we must + // package the initiation step as a function object. The initiation function + // object's call operator is passed the concrete completion handler produced + // by the completion token. This completion handler matches the asynchronous + // operation's completion handler signature, which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments in the lambda capture set. However, we should prefer to + // propagate them as function call arguments as this allows the completion + // token to optimise how they are passed. For example, a lazy future which + // defers initiation would need to make a decay-copy of the arguments, but + // when using a simple callback the arguments can be trivially forwarded + // straight through.) + auto initiation = []( + asio::completion_handler_for<void(std::error_code)> + auto&& completion_handler, + tcp::socket& socket, + const char* message) + { + // The async_write operation has a completion handler signature of: + // + // void(std::error_code error, std::size n) + // + // This differs from our operation's signature in that it is also passed + // the number of bytes transferred as an argument of type std::size_t. We + // will adapt our completion handler to async_write's completion handler + // signature by using std::bind, which drops the additional argument. + // + // However, it is essential to the correctness of our composed operation + // that we preserve the executor of the user-supplied completion handler. + // The std::bind function will not do this for us, so we must do this by + // first obtaining the completion handler's associated executor (defaulting + // to the I/O executor - in this case the executor of the socket - if the + // completion handler does not have its own) ... + auto executor = asio::get_associated_executor( + completion_handler, socket.get_executor()); + + // ... and then binding this executor to our adapted completion handler + // using the asio::bind_executor function. + asio::async_write(socket, + asio::buffer(message, std::strlen(message)), + asio::bind_executor(executor, + std::bind(std::forward<decltype(completion_handler)>( + completion_handler), std::placeholders::_1))); + }; + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + initiation, token, std::ref(socket), message); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "Testing callback\r\n", + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + asio::async_operation auto op = async_write_message( + socket, "Testing deferred\r\n", asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_message( + socket, "Testing future\r\n", asio::use_future); + + io_context.run(); + + // Get the result of the operation. + try + { + // Get the result of the operation. + f.get(); + std::cout << "Message sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp20/operations/composed_4.cpp b/3rdparty/asio/src/examples/cpp20/operations/composed_4.cpp new file mode 100644 index 00000000000..069f57ce1ac --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/operations/composed_4.cpp @@ -0,0 +1,247 @@ +// +// composed_4.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/bind_executor.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <cstring> +#include <functional> +#include <iostream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// In this composed operation we repackage an existing operation, but with a +// different completion handler signature. We will also intercept an empty +// message as an invalid argument, and propagate the corresponding error to the +// user. The asynchronous operation requirements are met by delegating +// responsibility to the underlying operation. + +template < + asio::completion_token_for<void(std::error_code)> CompletionToken> +auto async_write_message(tcp::socket& socket, + const char* message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++20 we can omit the return type as it is automatically deduced from + // the return type of asio::async_initiate. +{ + // In addition to determining the mechanism by which an asynchronous + // operation delivers its result, a completion token also determines the time + // when the operation commences. For example, when the completion token is a + // simple callback the operation commences before the initiating function + // returns. However, if the completion token's delivery mechanism uses a + // future, we might instead want to defer initiation of the operation until + // the returned future object is waited upon. + // + // To enable this, when implementing an asynchronous operation we must + // package the initiation step as a function object. The initiation function + // object's call operator is passed the concrete completion handler produced + // by the completion token. This completion handler matches the asynchronous + // operation's completion handler signature, which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments in the lambda capture set. However, we should prefer to + // propagate them as function call arguments as this allows the completion + // token to optimise how they are passed. For example, a lazy future which + // defers initiation would need to make a decay-copy of the arguments, but + // when using a simple callback the arguments can be trivially forwarded + // straight through.) + auto initiation = []( + asio::completion_handler_for<void(std::error_code)> + auto&& completion_handler, + tcp::socket& socket, + const char* message) + { + // The post operation has a completion handler signature of: + // + // void() + // + // and the async_write operation has a completion handler signature of: + // + // void(std::error_code error, std::size n) + // + // Both of these operations' completion handler signatures differ from our + // operation's completion handler signature. We will adapt our completion + // handler to these signatures by using std::bind, which drops the + // additional arguments. + // + // However, it is essential to the correctness of our composed operation + // that we preserve the executor of the user-supplied completion handler. + // The std::bind function will not do this for us, so we must do this by + // first obtaining the completion handler's associated executor (defaulting + // to the I/O executor - in this case the executor of the socket - if the + // completion handler does not have its own) ... + auto executor = asio::get_associated_executor( + completion_handler, socket.get_executor()); + + // ... and then binding this executor to our adapted completion handler + // using the asio::bind_executor function. + std::size_t length = std::strlen(message); + if (length == 0) + { + asio::post( + asio::bind_executor(executor, + std::bind(std::forward<decltype(completion_handler)>( + completion_handler), asio::error::invalid_argument))); + } + else + { + asio::async_write(socket, + asio::buffer(message, length), + asio::bind_executor(executor, + std::bind(std::forward<decltype(completion_handler)>( + completion_handler), std::placeholders::_1))); + } + }; + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + initiation, token, std::ref(socket), message); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, "", + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + asio::async_operation auto op = + async_write_message(socket, "", asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_message( + socket, "", asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Message sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Exception: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp20/operations/composed_5.cpp b/3rdparty/asio/src/examples/cpp20/operations/composed_5.cpp new file mode 100644 index 00000000000..bec83ec3a59 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/operations/composed_5.cpp @@ -0,0 +1,284 @@ +// +// composed_5.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation automatically serialises a message, using its I/O +// streams insertion operator, before sending it on the socket. To do this, it +// must allocate a buffer for the encoded message and ensure this buffer's +// validity until the underlying async_write operation completes. + +template <typename T, + asio::completion_token_for<void(std::error_code)> CompletionToken> +auto async_write_message(tcp::socket& socket, + const T& message, CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++20 we can omit the return type as it is automatically deduced from + // the return type of asio::async_initiate. +{ + // In addition to determining the mechanism by which an asynchronous + // operation delivers its result, a completion token also determines the time + // when the operation commences. For example, when the completion token is a + // simple callback the operation commences before the initiating function + // returns. However, if the completion token's delivery mechanism uses a + // future, we might instead want to defer initiation of the operation until + // the returned future object is waited upon. + // + // To enable this, when implementing an asynchronous operation we must + // package the initiation step as a function object. The initiation function + // object's call operator is passed the concrete completion handler produced + // by the completion token. This completion handler matches the asynchronous + // operation's completion handler signature, which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments in the lambda capture set. However, we should prefer to + // propagate them as function call arguments as this allows the completion + // token to optimise how they are passed. For example, a lazy future which + // defers initiation would need to make a decay-copy of the arguments, but + // when using a simple callback the arguments can be trivially forwarded + // straight through.) + auto initiation = []( + asio::completion_handler_for<void(std::error_code)> + auto&& completion_handler, + tcp::socket& socket, + std::unique_ptr<std::string> encoded_message) + { + // In this example, the composed operation's intermediate completion + // handler is implemented as a hand-crafted function object, rather than + // using a lambda or std::bind. + struct intermediate_completion_handler + { + // The intermediate completion handler holds a reference to the socket so + // that it can obtain the I/O executor (see get_executor below). + tcp::socket& socket_; + + // The allocated buffer for the encoded message. The std::unique_ptr + // smart pointer is move-only, and as a consequence our intermediate + // completion handler is also move-only. + std::unique_ptr<std::string> encoded_message_; + + // The user-supplied completion handler. + typename std::decay<decltype(completion_handler)>::type handler_; + + // The function call operator matches the completion signature of the + // async_write operation. + void operator()(const std::error_code& error, std::size_t /*n*/) + { + // Deallocate the encoded message before calling the user-supplied + // completion handler. + encoded_message_.reset(); + + // Call the user-supplied handler with the result of the operation. + // The arguments must match the completion signature of our composed + // operation. + handler_(error); + } + + // It is essential to the correctness of our composed operation that we + // preserve the executor of the user-supplied completion handler. With a + // hand-crafted function object we can do this by defining a nested type + // executor_type and member function get_executor. These obtain the + // completion handler's associated executor, and default to the I/O + // executor - in this case the executor of the socket - if the completion + // handler does not have its own. + using executor_type = asio::associated_executor_t< + typename std::decay<decltype(completion_handler)>::type, + tcp::socket::executor_type>; + + executor_type get_executor() const noexcept + { + return asio::get_associated_executor( + handler_, socket_.get_executor()); + } + + // Although not necessary for correctness, we may also preserve the + // allocator of the user-supplied completion handler. This is achieved by + // defining a nested type allocator_type and member function + // get_allocator. These obtain the completion handler's associated + // allocator, and default to std::allocator<void> if the completion + // handler does not have its own. + using allocator_type = asio::associated_allocator_t< + typename std::decay<decltype(completion_handler)>::type, + std::allocator<void>>; + + allocator_type get_allocator() const noexcept + { + return asio::get_associated_allocator( + handler_, std::allocator<void>{}); + } + }; + + // Initiate the underlying async_write operation using our intermediate + // completion handler. + auto encoded_message_buffer = asio::buffer(*encoded_message); + asio::async_write(socket, encoded_message_buffer, + intermediate_completion_handler{socket, std::move(encoded_message), + std::forward<decltype(completion_handler)>(completion_handler)}); + }; + + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + initiation, token, std::ref(socket), + std::move(encoded_message)); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_message(socket, 123456, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + asio::async_operation auto op = async_write_message( + socket, std::string("abcdef"), asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Message sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_message( + socket, 654.321, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Message sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Exception: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp20/operations/composed_6.cpp b/3rdparty/asio/src/examples/cpp20/operations/composed_6.cpp new file mode 100644 index 00000000000..77e2f50f93e --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/operations/composed_6.cpp @@ -0,0 +1,345 @@ +// +// composed_6.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/deferred.hpp> +#include <asio/executor_work_guard.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_initiate function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation shows composition of multiple underlying operations. +// It automatically serialises a message, using its I/O streams insertion +// operator, before sending it N times on the socket. To do this, it must +// allocate a buffer for the encoded message and ensure this buffer's validity +// until all underlying async_write operation complete. A one second delay is +// inserted prior to each write operation, using a steady_timer. + +template <typename T, + asio::completion_token_for<void(std::error_code)> CompletionToken> +auto async_write_messages(tcp::socket& socket, + const T& message, std::size_t repeat_count, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++20 we can omit the return type as it is automatically deduced from + // the return type of asio::async_initiate. +{ + // In addition to determining the mechanism by which an asynchronous + // operation delivers its result, a completion token also determines the time + // when the operation commences. For example, when the completion token is a + // simple callback the operation commences before the initiating function + // returns. However, if the completion token's delivery mechanism uses a + // future, we might instead want to defer initiation of the operation until + // the returned future object is waited upon. + // + // To enable this, when implementing an asynchronous operation we must + // package the initiation step as a function object. The initiation function + // object's call operator is passed the concrete completion handler produced + // by the completion token. This completion handler matches the asynchronous + // operation's completion handler signature, which in this example is: + // + // void(std::error_code error) + // + // The initiation function object also receives any additional arguments + // required to start the operation. (Note: We could have instead passed these + // arguments in the lambda capture set. However, we should prefer to + // propagate them as function call arguments as this allows the completion + // token to optimise how they are passed. For example, a lazy future which + // defers initiation would need to make a decay-copy of the arguments, but + // when using a simple callback the arguments can be trivially forwarded + // straight through.) + auto initiation = []( + asio::completion_handler_for<void(std::error_code)> + auto&& completion_handler, + tcp::socket& socket, + std::unique_ptr<std::string> encoded_message, + std::size_t repeat_count, + std::unique_ptr<asio::steady_timer> delay_timer) + { + // In this example, the composed operation's intermediate completion + // handler is implemented as a hand-crafted function object. + struct intermediate_completion_handler + { + // The intermediate completion handler holds a reference to the socket as + // it is used for multiple async_write operations, as well as for + // obtaining the I/O executor (see get_executor below). + tcp::socket& socket_; + + // The allocated buffer for the encoded message. The std::unique_ptr + // smart pointer is move-only, and as a consequence our intermediate + // completion handler is also move-only. + std::unique_ptr<std::string> encoded_message_; + + // The repeat count remaining. + std::size_t repeat_count_; + + // A steady timer used for introducing a delay. + std::unique_ptr<asio::steady_timer> delay_timer_; + + // To manage the cycle between the multiple underlying asychronous + // operations, our intermediate completion handler is implemented as a + // state machine. + enum { starting, waiting, writing } state_; + + // As our composed operation performs multiple underlying I/O operations, + // we should maintain a work object against the I/O executor. This tells + // the I/O executor that there is still more work to come in the future. + asio::executor_work_guard<tcp::socket::executor_type> io_work_; + + // The user-supplied completion handler, called once only on completion + // of the entire composed operation. + typename std::decay<decltype(completion_handler)>::type handler_; + + // By having a default value for the second argument, this function call + // operator matches the completion signature of both the async_write and + // steady_timer::async_wait operations. + void operator()(const std::error_code& error, std::size_t = 0) + { + if (!error) + { + switch (state_) + { + case starting: + case writing: + if (repeat_count_ > 0) + { + --repeat_count_; + state_ = waiting; + delay_timer_->expires_after(std::chrono::seconds(1)); + delay_timer_->async_wait(std::move(*this)); + return; // Composed operation not yet complete. + } + break; // Composed operation complete, continue below. + case waiting: + state_ = writing; + asio::async_write(socket_, + asio::buffer(*encoded_message_), std::move(*this)); + return; // Composed operation not yet complete. + } + } + + // This point is reached only on completion of the entire composed + // operation. + + // We no longer have any future work coming for the I/O executor. + io_work_.reset(); + + // Deallocate the encoded message before calling the user-supplied + // completion handler. + encoded_message_.reset(); + + // Call the user-supplied handler with the result of the operation. + handler_(error); + } + + // It is essential to the correctness of our composed operation that we + // preserve the executor of the user-supplied completion handler. With a + // hand-crafted function object we can do this by defining a nested type + // executor_type and member function get_executor. These obtain the + // completion handler's associated executor, and default to the I/O + // executor - in this case the executor of the socket - if the completion + // handler does not have its own. + using executor_type = asio::associated_executor_t< + typename std::decay<decltype(completion_handler)>::type, + tcp::socket::executor_type>; + + executor_type get_executor() const noexcept + { + return asio::get_associated_executor( + handler_, socket_.get_executor()); + } + + // Although not necessary for correctness, we may also preserve the + // allocator of the user-supplied completion handler. This is achieved by + // defining a nested type allocator_type and member function + // get_allocator. These obtain the completion handler's associated + // allocator, and default to std::allocator<void> if the completion + // handler does not have its own. + using allocator_type = asio::associated_allocator_t< + typename std::decay<decltype(completion_handler)>::type, + std::allocator<void>>; + + allocator_type get_allocator() const noexcept + { + return asio::get_associated_allocator( + handler_, std::allocator<void>{}); + } + }; + + // Initiate the underlying async_write operation using our intermediate + // completion handler. + auto encoded_message_buffer = asio::buffer(*encoded_message); + asio::async_write(socket, encoded_message_buffer, + intermediate_completion_handler{ + socket, std::move(encoded_message), + repeat_count, std::move(delay_timer), + intermediate_completion_handler::starting, + asio::make_work_guard(socket.get_executor()), + std::forward<decltype(completion_handler)>(completion_handler)}); + }; + + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the composed asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // Create a steady_timer to be used for the delay between messages. + std::unique_ptr<asio::steady_timer> delay_timer( + new asio::steady_timer(socket.get_executor())); + + // The asio::async_initiate function takes: + // + // - our initiation function object, + // - the completion token, + // - the completion handler signature, and + // - any additional arguments we need to initiate the operation. + // + // It then asks the completion token to create a completion handler (i.e. a + // callback) with the specified signature, and invoke the initiation function + // object with this completion handler as well as the additional arguments. + // The return value of async_initiate is the result of our operation's + // initiating function. + // + // Note that we wrap non-const reference arguments in std::reference_wrapper + // to prevent incorrect decay-copies of these objects. + return asio::async_initiate< + CompletionToken, void(std::error_code)>( + initiation, token, std::ref(socket), + std::move(encoded_message), repeat_count, + std::move(delay_timer)); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_messages(socket, "Testing callback\r\n", 5, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + asio::async_operation auto op = async_write_messages( + socket, "Testing deferred\r\n", 5, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_messages( + socket, "Testing future\r\n", 5, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Messages sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp20/operations/composed_7.cpp b/3rdparty/asio/src/examples/cpp20/operations/composed_7.cpp new file mode 100644 index 00000000000..9ae44c797fb --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/operations/composed_7.cpp @@ -0,0 +1,262 @@ +// +// composed_7.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/compose.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_compose function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation shows composition of multiple underlying operations. +// It automatically serialises a message, using its I/O streams insertion +// operator, before sending it N times on the socket. To do this, it must +// allocate a buffer for the encoded message and ensure this buffer's validity +// until all underlying async_write operation complete. A one second delay is +// inserted prior to each write operation, using a steady_timer. + +template <typename T, + asio::completion_token_for<void(std::error_code)> CompletionToken> +auto async_write_messages(tcp::socket& socket, + const T& message, std::size_t repeat_count, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++20 we can omit the return type as it is automatically deduced from + // the return type of asio::async_compose. +{ + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the composed asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // Create a steady_timer to be used for the delay between messages. + std::unique_ptr<asio::steady_timer> delay_timer( + new asio::steady_timer(socket.get_executor())); + + // To manage the cycle between the multiple underlying asychronous + // operations, our implementation is a state machine. + enum { starting, waiting, writing }; + + // The asio::async_compose function takes: + // + // - our asynchronous operation implementation, + // - the completion token, + // - the completion handler signature, and + // - any I/O objects (or executors) used by the operation + // + // It then wraps our implementation, which is implemented here as a state + // machine in a lambda, in an intermediate completion handler that meets the + // requirements of a conforming asynchronous operation. This includes + // tracking outstanding work against the I/O executors associated with the + // operation (in this example, this is the socket's executor). + // + // The first argument to our lambda is a reference to the enclosing + // intermediate completion handler. This intermediate completion handler is + // provided for us by the asio::async_compose function, and takes care + // of all the details required to implement a conforming asynchronous + // operation. When calling an underlying asynchronous operation, we pass it + // this enclosing intermediate completion handler as the completion token. + // + // All arguments to our lambda after the first must be defaulted to allow the + // state machine to be started, as well as to allow the completion handler to + // match the completion signature of both the async_write and + // steady_timer::async_wait operations. + return asio::async_compose< + CompletionToken, void(std::error_code)>( + [ + // The implementation holds a reference to the socket as it is used for + // multiple async_write operations. + &socket, + + // The allocated buffer for the encoded message. The std::unique_ptr + // smart pointer is move-only, and as a consequence our lambda + // implementation is also move-only. + encoded_message = std::move(encoded_message), + + // The repeat count remaining. + repeat_count, + + // A steady timer used for introducing a delay. + delay_timer = std::move(delay_timer), + + // To manage the cycle between the multiple underlying asychronous + // operations, our implementation is a state machine. + state = starting + ] + ( + auto& self, + const std::error_code& error = {}, + std::size_t = 0 + ) mutable + { + if (!error) + { + switch (state) + { + case starting: + case writing: + if (repeat_count > 0) + { + --repeat_count; + state = waiting; + delay_timer->expires_after(std::chrono::seconds(1)); + delay_timer->async_wait(std::move(self)); + return; // Composed operation not yet complete. + } + break; // Composed operation complete, continue below. + case waiting: + state = writing; + asio::async_write(socket, + asio::buffer(*encoded_message), std::move(self)); + return; // Composed operation not yet complete. + } + } + + // This point is reached only on completion of the entire composed + // operation. + + // Deallocate the encoded message and delay timer before calling the + // user-supplied completion handler. + encoded_message.reset(); + delay_timer.reset(); + + // Call the user-supplied handler with the result of the operation. + self.complete(error); + }, + token, socket); +} + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_messages(socket, "Testing callback\r\n", 5, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + asio::async_operation auto op = async_write_messages( + socket, "Testing deferred\r\n", 5, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_messages( + socket, "Testing future\r\n", 5, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Messages sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp20/operations/composed_8.cpp b/3rdparty/asio/src/examples/cpp20/operations/composed_8.cpp new file mode 100644 index 00000000000..2735d74d047 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/operations/composed_8.cpp @@ -0,0 +1,255 @@ +// +// composed_8.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <asio/compose.hpp> +#include <asio/coroutine.hpp> +#include <asio/deferred.hpp> +#include <asio/io_context.hpp> +#include <asio/ip/tcp.hpp> +#include <asio/steady_timer.hpp> +#include <asio/use_future.hpp> +#include <asio/write.hpp> +#include <functional> +#include <iostream> +#include <memory> +#include <sstream> +#include <string> +#include <type_traits> +#include <utility> + +using asio::ip::tcp; + +// NOTE: This example requires the new asio::async_compose function. For +// an example that works with the Networking TS style of completion tokens, +// please see an older version of asio. + +//------------------------------------------------------------------------------ + +// This composed operation shows composition of multiple underlying operations, +// using asio's stackless coroutines support to express the flow of control. It +// automatically serialises a message, using its I/O streams insertion +// operator, before sending it N times on the socket. To do this, it must +// allocate a buffer for the encoded message and ensure this buffer's validity +// until all underlying async_write operation complete. A one second delay is +// inserted prior to each write operation, using a steady_timer. + +#include <asio/yield.hpp> + +template <typename T, + asio::completion_token_for<void(std::error_code)> CompletionToken> +auto async_write_messages(tcp::socket& socket, + const T& message, std::size_t repeat_count, + CompletionToken&& token) + // The return type of the initiating function is deduced from the combination + // of: + // + // - the CompletionToken type, + // - the completion handler signature, and + // - the asynchronous operation's initiation function object. + // + // When the completion token is a simple callback, the return type is always + // void. In this example, when the completion token is asio::yield_context + // (used for stackful coroutines) the return type would also be void, as + // there is no non-error argument to the completion handler. When the + // completion token is asio::use_future it would be std::future<void>. When + // the completion token is asio::deferred, the return type differs for each + // asynchronous operation. + // + // In C++20 we can omit the return type as it is automatically deduced from + // the return type of asio::async_compose. +{ + // Encode the message and copy it into an allocated buffer. The buffer will + // be maintained for the lifetime of the composed asynchronous operation. + std::ostringstream os; + os << message; + std::unique_ptr<std::string> encoded_message(new std::string(os.str())); + + // Create a steady_timer to be used for the delay between messages. + std::unique_ptr<asio::steady_timer> delay_timer( + new asio::steady_timer(socket.get_executor())); + + // The asio::async_compose function takes: + // + // - our asynchronous operation implementation, + // - the completion token, + // - the completion handler signature, and + // - any I/O objects (or executors) used by the operation + // + // It then wraps our implementation, which is implemented here as a stackless + // coroutine in a lambda, in an intermediate completion handler that meets the + // requirements of a conforming asynchronous operation. This includes + // tracking outstanding work against the I/O executors associated with the + // operation (in this example, this is the socket's executor). + // + // The first argument to our lambda is a reference to the enclosing + // intermediate completion handler. This intermediate completion handler is + // provided for us by the asio::async_compose function, and takes care + // of all the details required to implement a conforming asynchronous + // operation. When calling an underlying asynchronous operation, we pass it + // this enclosing intermediate completion handler as the completion token. + // + // All arguments to our lambda after the first must be defaulted to allow the + // state machine to be started, as well as to allow the completion handler to + // match the completion signature of both the async_write and + // steady_timer::async_wait operations. + return asio::async_compose< + CompletionToken, void(std::error_code)>( + [ + // The implementation holds a reference to the socket as it is used for + // multiple async_write operations. + &socket, + + // The allocated buffer for the encoded message. The std::unique_ptr + // smart pointer is move-only, and as a consequence our lambda + // implementation is also move-only. + encoded_message = std::move(encoded_message), + + // The repeat count remaining. + repeat_count, + + // A steady timer used for introducing a delay. + delay_timer = std::move(delay_timer), + + // The coroutine state. + coro = asio::coroutine() + ] + ( + auto& self, + const std::error_code& error = {}, + std::size_t = 0 + ) mutable + { + reenter (coro) + { + while (repeat_count > 0) + { + --repeat_count; + + delay_timer->expires_after(std::chrono::seconds(1)); + yield delay_timer->async_wait(std::move(self)); + if (error) + break; + + yield asio::async_write(socket, + asio::buffer(*encoded_message), std::move(self)); + if (error) + break; + } + + // Deallocate the encoded message and delay timer before calling the + // user-supplied completion handler. + encoded_message.reset(); + delay_timer.reset(); + + // Call the user-supplied handler with the result of the operation. + self.complete(error); + } + }, + token, socket); +} + +#include <asio/unyield.hpp> + +//------------------------------------------------------------------------------ + +void test_callback() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using a lambda as a callback. + async_write_messages(socket, "Testing callback\r\n", 5, + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_deferred() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the deferred completion token. This + // token causes the operation's initiating function to package up the + // operation with its arguments to return a function object, which may then be + // used to launch the asynchronous operation. + asio::async_operation auto op = async_write_messages( + socket, "Testing deferred\r\n", 5, asio::deferred); + + // Launch the operation using a lambda as a callback. + std::move(op)( + [](const std::error_code& error) + { + if (!error) + { + std::cout << "Messages sent\n"; + } + else + { + std::cout << "Error: " << error.message() << "\n"; + } + }); + + io_context.run(); +} + +//------------------------------------------------------------------------------ + +void test_future() +{ + asio::io_context io_context; + + tcp::acceptor acceptor(io_context, {tcp::v4(), 55555}); + tcp::socket socket = acceptor.accept(); + + // Test our asynchronous operation using the use_future completion token. + // This token causes the operation's initiating function to return a future, + // which may be used to synchronously wait for the result of the operation. + std::future<void> f = async_write_messages( + socket, "Testing future\r\n", 5, asio::use_future); + + io_context.run(); + + try + { + // Get the result of the operation. + f.get(); + std::cout << "Messages sent\n"; + } + catch (const std::exception& e) + { + std::cout << "Error: " << e.what() << "\n"; + } +} + +//------------------------------------------------------------------------------ + +int main() +{ + test_callback(); + test_deferred(); + test_future(); +} diff --git a/3rdparty/asio/src/examples/cpp20/type_erasure/line_reader.hpp b/3rdparty/asio/src/examples/cpp20/type_erasure/line_reader.hpp new file mode 100644 index 00000000000..fa19aec6b13 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/type_erasure/line_reader.hpp @@ -0,0 +1,39 @@ +// +// line_reader.hpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef LINE_READER_HPP +#define LINE_READER_HPP + +#include <asio/any_completion_handler.hpp> +#include <asio/async_result.hpp> +#include <asio/error.hpp> +#include <string> + +class line_reader +{ +public: + virtual ~line_reader() {} + + template <typename CompletionToken> + auto async_read_line(std::string prompt, CompletionToken&& token) + { + return asio::async_initiate<CompletionToken, void(asio::error_code, std::string)>( + [](auto handler, line_reader* self, std::string prompt) + { + self->async_read_line_impl(std::move(prompt), std::move(handler)); + }, token, this, prompt); + } + +private: + virtual void async_read_line_impl(std::string prompt, + asio::any_completion_handler<void(asio::error_code, std::string)> handler) = 0; +}; + +#endif // LINE_READER_HPP diff --git a/3rdparty/asio/src/examples/cpp20/type_erasure/main.cpp b/3rdparty/asio/src/examples/cpp20/type_erasure/main.cpp new file mode 100644 index 00000000000..1b80dcd23ee --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/type_erasure/main.cpp @@ -0,0 +1,35 @@ +// +// main.cpp +// ~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "line_reader.hpp" +#include "sleep.hpp" +#include "stdin_line_reader.hpp" +#include <asio/co_spawn.hpp> +#include <asio/detached.hpp> +#include <asio/io_context.hpp> +#include <asio/use_awaitable.hpp> +#include <iostream> + +asio::awaitable<void> do_read(line_reader& reader) +{ + for (int i = 0; i < 10; ++i) + { + std::cout << co_await reader.async_read_line("Enter something: ", asio::use_awaitable); + co_await async_sleep(co_await asio::this_coro::executor, std::chrono::seconds(1), asio::use_awaitable); + } +} + +int main() +{ + asio::io_context ctx{1}; + stdin_line_reader reader{ctx.get_executor()}; + co_spawn(ctx, do_read(reader), asio::detached); + ctx.run(); +} diff --git a/3rdparty/asio/src/examples/cpp20/type_erasure/sleep.cpp b/3rdparty/asio/src/examples/cpp20/type_erasure/sleep.cpp new file mode 100644 index 00000000000..b605866ebd7 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/type_erasure/sleep.cpp @@ -0,0 +1,22 @@ +// +// sleep.cpp +// ~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "sleep.hpp" +#include <asio/consign.hpp> +#include <asio/steady_timer.hpp> +#include <memory> + +void async_sleep_impl( + asio::any_completion_handler<void(std::error_code)> handler, + asio::any_io_executor ex, std::chrono::nanoseconds duration) +{ + auto timer = std::make_shared<asio::steady_timer>(ex, duration); + timer->async_wait(asio::consign(std::move(handler), timer)); +} diff --git a/3rdparty/asio/src/examples/cpp20/type_erasure/sleep.hpp b/3rdparty/asio/src/examples/cpp20/type_erasure/sleep.hpp new file mode 100644 index 00000000000..7e057fc5862 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/type_erasure/sleep.hpp @@ -0,0 +1,32 @@ +// +// sleep.hpp +// ~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef SLEEP_HPP +#define SLEEP_HPP + +#include <asio/any_completion_handler.hpp> +#include <asio/any_io_executor.hpp> +#include <asio/async_result.hpp> +#include <asio/error.hpp> +#include <chrono> + +void async_sleep_impl( + asio::any_completion_handler<void(std::error_code)> handler, + asio::any_io_executor ex, std::chrono::nanoseconds duration); + +template <typename CompletionToken> +inline auto async_sleep(asio::any_io_executor ex, + std::chrono::nanoseconds duration, CompletionToken&& token) +{ + return asio::async_initiate<CompletionToken, void(std::error_code)>( + async_sleep_impl, token, std::move(ex), duration); +} + +#endif // SLEEP_HPP diff --git a/3rdparty/asio/src/examples/cpp20/type_erasure/stdin_line_reader.cpp b/3rdparty/asio/src/examples/cpp20/type_erasure/stdin_line_reader.cpp new file mode 100644 index 00000000000..7467e820e7a --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/type_erasure/stdin_line_reader.cpp @@ -0,0 +1,44 @@ +// +// stdin_line_reader.cpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "stdin_line_reader.hpp" +#include <asio/deferred.hpp> +#include <asio/read_until.hpp> +#include <iostream> + +stdin_line_reader::stdin_line_reader(asio::any_io_executor ex) + : stdin_(ex, ::dup(STDIN_FILENO)) +{ +} + +void stdin_line_reader::async_read_line_impl(std::string prompt, + asio::any_completion_handler<void(asio::error_code, std::string)> handler) +{ + std::cout << prompt; + std::cout.flush(); + + asio::async_read_until(stdin_, asio::dynamic_buffer(buffer_), '\n', + asio::deferred( + [this](asio::error_code ec, std::size_t n) + { + if (!ec) + { + std::string result = buffer_.substr(0, n); + buffer_.erase(0, n); + return asio::deferred.values(ec, std::move(result)); + } + else + { + return asio::deferred.values(ec, std::string{}); + } + } + ) + )(std::move(handler)); +} diff --git a/3rdparty/asio/src/examples/cpp20/type_erasure/stdin_line_reader.hpp b/3rdparty/asio/src/examples/cpp20/type_erasure/stdin_line_reader.hpp new file mode 100644 index 00000000000..fd54f707da0 --- /dev/null +++ b/3rdparty/asio/src/examples/cpp20/type_erasure/stdin_line_reader.hpp @@ -0,0 +1,30 @@ +// +// stdin_line_reader.hpp +// ~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef STDIN_LINE_READER_HPP +#define STDIN_LINE_READER_HPP + +#include "line_reader.hpp" +#include <asio/posix/stream_descriptor.hpp> + +class stdin_line_reader : public line_reader +{ +public: + explicit stdin_line_reader(asio::any_io_executor ex); + +private: + void async_read_line_impl(std::string prompt, + asio::any_completion_handler<void(asio::error_code, std::string)> handler) override; + + asio::posix::stream_descriptor stdin_; + std::string buffer_; +}; + +#endif |