diff --git a/MODULE.bazel b/MODULE.bazel index af851a7e4..f4629d8d8 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,5 +1,6 @@ module(name = "com_github_async_simple") +bazel_dep(name = "asio", version = "1.34.2") bazel_dep(name = "bazel_skylib", version = "1.8.2") bazel_dep(name = "libaio", version = "0.3.113.bcr.0") bazel_dep(name = "platforms", version = "1.0.0") diff --git a/cmake/Findasio.cmake b/cmake/Findasio.cmake new file mode 100644 index 000000000..77c6a63be --- /dev/null +++ b/cmake/Findasio.cmake @@ -0,0 +1,49 @@ +include(FetchContent) + +find_package(PkgConfig QUIET) +if(PkgConfig_FOUND) + pkg_check_modules(ASIO_PC QUIET asio) +endif() + +find_path( + ASIO_INCLUDE_DIR + NAMES asio.hpp + HINTS ${ASIO_PC_INCLUDE_DIRS} /usr/include /usr/local/include +) + +if(ASIO_INCLUDE_DIR) + message(STATUS "[Asio] Found system Asio at: ${ASIO_INCLUDE_DIR}") + + if(NOT TARGET asio::asio) + add_library(asio::asio INTERFACE IMPORTED GLOBAL) + target_include_directories(asio::asio INTERFACE "${ASIO_INCLUDE_DIR}") + target_compile_definitions(asio::asio INTERFACE ASIO_STANDALONE ASIO_NO_DEPRECATED) + endif() +else() + message(STATUS "[Asio] System Asio not found — fetching via FetchContent") + + FetchContent_Declare( + asio + GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git + GIT_TAG asio-1-34-2 + GIT_SHALLOW TRUE + ) + FetchContent_MakeAvailable(asio) + + if(NOT TARGET asio::asio) + add_library(asio::asio INTERFACE IMPORTED GLOBAL) + target_include_directories(asio::asio INTERFACE "${asio_SOURCE_DIR}/asio/include") + target_compile_definitions(asio::asio INTERFACE ASIO_STANDALONE ASIO_NO_DEPRECATED) + endif() + + set(ASIO_INCLUDE_DIR + "${asio_SOURCE_DIR}/asio/include" + CACHE PATH + "Asio include directory (fetched)" + FORCE + ) +endif() + +set(ASIO_FOUND TRUE CACHE BOOL "Asio available") +set(ASIO_INCLUDE_DIRS "${ASIO_INCLUDE_DIR}" CACHE PATH "Asio include dirs") +mark_as_advanced(ASIO_INCLUDE_DIR ASIO_INCLUDE_DIRS ASIO_FOUND) diff --git a/demo_example/BUILD.bazel b/demo_example/BUILD.bazel index d00f3079a..ef7650b9d 100644 --- a/demo_example/BUILD.bazel +++ b/demo_example/BUILD.bazel @@ -1,16 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS") -cc_library( - name = "asio", - hdrs = glob([ - "asio/**/*.hpp", - "asio/**/*.ipp", - ]), - includes = ["asio"], - visibility = ["//visibility:public"], -) - cc_library( name = "hdrs_dep", hdrs = [ @@ -18,9 +8,9 @@ cc_library( "asio_util.hpp", ], deps = [ - ":asio", "//:async_simple", "//:simple_executors", + "@asio", ], ) @@ -73,8 +63,7 @@ cc_library( name = "http_hdrs_dep", hdrs = glob([ "http/**/*.hpp", - "io_context_pool.hpp", - ]), + ]) + ["io_context_pool.hpp"], visibility = ["//visibility:public"], deps = [":hdrs_dep"], ) diff --git a/demo_example/CMakeLists.txt b/demo_example/CMakeLists.txt index e80c50317..05883fcc5 100644 --- a/demo_example/CMakeLists.txt +++ b/demo_example/CMakeLists.txt @@ -1,12 +1,11 @@ -if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" AND - NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") +if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") endif() add_executable(CountChar CountChar.cpp) target_link_libraries(CountChar async_simple) -if (${ASYNC_SIMPLE_BUILD_MODULES}) +if(${ASYNC_SIMPLE_BUILD_MODULES}) add_executable(CountCharUsingModules CountCharUsingModules.cpp) target_link_libraries(CountCharUsingModules async_simple) endif() @@ -15,58 +14,59 @@ add_executable(ReadFiles ReadFiles.cpp) target_link_libraries(ReadFiles async_simple) if(NOT ASYNC_SIMPLE_DISABLE_AIO AND LIBAIO_INCLUDE_DIR AND LIBAIO_LIBRARIES) - target_link_libraries(ReadFiles ${LIBAIO_LIBRARIES}) + target_link_libraries(ReadFiles ${LIBAIO_LIBRARIES}) endif() add_custom_command( - TARGET ReadFiles POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/Input - ${CMAKE_CURRENT_BINARY_DIR}/Input) + TARGET ReadFiles + POST_BUILD + COMMAND + ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Input + ${CMAKE_CURRENT_BINARY_DIR}/Input +) -include_directories(asio) +find_package(asio) add_executable(async_echo_server async_echo_server.cpp) -target_link_libraries(async_echo_server async_simple) +target_link_libraries(async_echo_server async_simple asio::asio) add_executable(async_echo_client async_echo_client.cpp) -target_link_libraries(async_echo_client async_simple) +target_link_libraries(async_echo_client async_simple asio::asio) add_executable(async_multiple_core_echo_server async_multiple_core_echo_server.cpp) -target_link_libraries(async_multiple_core_echo_server async_simple) +target_link_libraries(async_multiple_core_echo_server async_simple asio::asio) add_executable(block_echo_server block_echo_server.cpp) -target_link_libraries(block_echo_server ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(block_echo_server ${CMAKE_THREAD_LIBS_INIT} asio::asio) add_executable(block_echo_client block_echo_client.cpp) -target_link_libraries(block_echo_client ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(block_echo_client ${CMAKE_THREAD_LIBS_INIT} asio::asio) add_executable(http_server http/coroutine_http/http_server.cpp) -target_link_libraries(http_server async_simple) +target_link_libraries(http_server async_simple asio::asio) add_executable(multiple_core_http_server http/coroutine_http/multiple_core_http_server.cpp) -target_link_libraries(multiple_core_http_server async_simple) +target_link_libraries(multiple_core_http_server async_simple asio::asio) add_executable(http_client http/coroutine_http/http_client.cpp) -target_link_libraries(http_client async_simple) +target_link_libraries(http_client async_simple asio::asio) add_executable(block_http_server http/block_http/block_http_server.cpp) -target_link_libraries(block_http_server async_simple) +target_link_libraries(block_http_server async_simple asio::asio) add_executable(pmr_lazy pmr_lazy.cpp) -target_link_libraries(pmr_lazy async_simple) +target_link_libraries(pmr_lazy async_simple asio::asio) -SET(ENABLE_SSL OFF) +set(ENABLE_SSL OFF) -if (ENABLE_SSL) +if(ENABLE_SSL) find_package(OpenSSL REQUIRED) add_definitions(-DENABLE_SSL) message(STATUS "Use SSL") endif() add_executable(smtp_client smtp/smtp_client.cpp) -if (ENABLE_SSL) - target_link_libraries(smtp_client async_simple ${CMAKE_THREAD_LIBS_INIT} OpenSSL::SSL) -else() - target_link_libraries(smtp_client async_simple ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(smtp_client async_simple ${CMAKE_THREAD_LIBS_INIT} asio::asio) +if(ENABLE_SSL) + target_link_libraries(smtp_client OpenSSL::SSL) endif() diff --git a/demo_example/asio/COPYING b/demo_example/asio/COPYING deleted file mode 100644 index 532cec6c8..000000000 --- a/demo_example/asio/COPYING +++ /dev/null @@ -1,4 +0,0 @@ -Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) - -Distributed under the 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/demo_example/asio/LICENSE_1_0.txt b/demo_example/asio/LICENSE_1_0.txt deleted file mode 100644 index 36b7cd93c..000000000 --- a/demo_example/asio/LICENSE_1_0.txt +++ /dev/null @@ -1,23 +0,0 @@ -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/demo_example/asio/asio.hpp b/demo_example/asio/asio.hpp deleted file mode 100644 index e23913d94..000000000 --- a/demo_example/asio/asio.hpp +++ /dev/null @@ -1,201 +0,0 @@ -// -// asio.hpp -// ~~~~~~~~ -// -// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the 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 ASIO_HPP -#define ASIO_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/associated_allocator.hpp" -#include "asio/associated_executor.hpp" -#include "asio/associated_cancellation_slot.hpp" -#include "asio/associator.hpp" -#include "asio/async_result.hpp" -#include "asio/awaitable.hpp" -#include "asio/basic_datagram_socket.hpp" -#include "asio/basic_deadline_timer.hpp" -#include "asio/basic_file.hpp" -#include "asio/basic_io_object.hpp" -#include "asio/basic_random_access_file.hpp" -#include "asio/basic_raw_socket.hpp" -#include "asio/basic_readable_pipe.hpp" -#include "asio/basic_seq_packet_socket.hpp" -#include "asio/basic_serial_port.hpp" -#include "asio/basic_signal_set.hpp" -#include "asio/basic_socket.hpp" -#include "asio/basic_socket_acceptor.hpp" -#include "asio/basic_socket_iostream.hpp" -#include "asio/basic_socket_streambuf.hpp" -#include "asio/basic_stream_file.hpp" -#include "asio/basic_stream_socket.hpp" -#include "asio/basic_streambuf.hpp" -#include "asio/basic_waitable_timer.hpp" -#include "asio/basic_writable_pipe.hpp" -#include "asio/bind_cancellation_slot.hpp" -#include "asio/bind_executor.hpp" -#include "asio/buffer.hpp" -#include "asio/buffer_registration.hpp" -#include "asio/buffered_read_stream_fwd.hpp" -#include "asio/buffered_read_stream.hpp" -#include "asio/buffered_stream_fwd.hpp" -#include "asio/buffered_stream.hpp" -#include "asio/buffered_write_stream_fwd.hpp" -#include "asio/buffered_write_stream.hpp" -#include "asio/buffers_iterator.hpp" -#include "asio/cancellation_signal.hpp" -#include "asio/cancellation_state.hpp" -#include "asio/cancellation_type.hpp" -#include "asio/co_spawn.hpp" -#include "asio/completion_condition.hpp" -#include "asio/compose.hpp" -#include "asio/connect.hpp" -#include "asio/connect_pipe.hpp" -#include "asio/coroutine.hpp" -#include "asio/deadline_timer.hpp" -#include "asio/defer.hpp" -#include "asio/detached.hpp" -#include "asio/dispatch.hpp" -#include "asio/error.hpp" -#include "asio/error_code.hpp" -#include "asio/execution.hpp" -#include "asio/execution/allocator.hpp" -#include "asio/execution/any_executor.hpp" -#include "asio/execution/blocking.hpp" -#include "asio/execution/blocking_adaptation.hpp" -#include "asio/execution/bulk_execute.hpp" -#include "asio/execution/bulk_guarantee.hpp" -#include "asio/execution/connect.hpp" -#include "asio/execution/context.hpp" -#include "asio/execution/context_as.hpp" -#include "asio/execution/execute.hpp" -#include "asio/execution/executor.hpp" -#include "asio/execution/invocable_archetype.hpp" -#include "asio/execution/mapping.hpp" -#include "asio/execution/occupancy.hpp" -#include "asio/execution/operation_state.hpp" -#include "asio/execution/outstanding_work.hpp" -#include "asio/execution/prefer_only.hpp" -#include "asio/execution/receiver.hpp" -#include "asio/execution/receiver_invocation_error.hpp" -#include "asio/execution/relationship.hpp" -#include "asio/execution/schedule.hpp" -#include "asio/execution/scheduler.hpp" -#include "asio/execution/sender.hpp" -#include "asio/execution/set_done.hpp" -#include "asio/execution/set_error.hpp" -#include "asio/execution/set_value.hpp" -#include "asio/execution/start.hpp" -#include "asio/execution_context.hpp" -#include "asio/executor.hpp" -#include "asio/executor_work_guard.hpp" -#include "asio/file_base.hpp" -#include "asio/generic/basic_endpoint.hpp" -#include "asio/generic/datagram_protocol.hpp" -#include "asio/generic/raw_protocol.hpp" -#include "asio/generic/seq_packet_protocol.hpp" -#include "asio/generic/stream_protocol.hpp" -#include "asio/handler_alloc_hook.hpp" -#include "asio/handler_continuation_hook.hpp" -#include "asio/handler_invoke_hook.hpp" -#include "asio/high_resolution_timer.hpp" -#include "asio/io_context.hpp" -#include "asio/io_context_strand.hpp" -#include "asio/io_service.hpp" -#include "asio/io_service_strand.hpp" -#include "asio/ip/address.hpp" -#include "asio/ip/address_v4.hpp" -#include "asio/ip/address_v4_iterator.hpp" -#include "asio/ip/address_v4_range.hpp" -#include "asio/ip/address_v6.hpp" -#include "asio/ip/address_v6_iterator.hpp" -#include "asio/ip/address_v6_range.hpp" -#include "asio/ip/network_v4.hpp" -#include "asio/ip/network_v6.hpp" -#include "asio/ip/bad_address_cast.hpp" -#include "asio/ip/basic_endpoint.hpp" -#include "asio/ip/basic_resolver.hpp" -#include "asio/ip/basic_resolver_entry.hpp" -#include "asio/ip/basic_resolver_iterator.hpp" -#include "asio/ip/basic_resolver_query.hpp" -#include "asio/ip/host_name.hpp" -#include "asio/ip/icmp.hpp" -#include "asio/ip/multicast.hpp" -#include "asio/ip/resolver_base.hpp" -#include "asio/ip/resolver_query_base.hpp" -#include "asio/ip/tcp.hpp" -#include "asio/ip/udp.hpp" -#include "asio/ip/unicast.hpp" -#include "asio/ip/v6_only.hpp" -#include "asio/is_applicable_property.hpp" -#include "asio/is_executor.hpp" -#include "asio/is_read_buffered.hpp" -#include "asio/is_write_buffered.hpp" -#include "asio/local/basic_endpoint.hpp" -#include "asio/local/connect_pair.hpp" -#include "asio/local/datagram_protocol.hpp" -#include "asio/local/stream_protocol.hpp" -#include "asio/multiple_exceptions.hpp" -#include "asio/packaged_task.hpp" -#include "asio/placeholders.hpp" -#include "asio/posix/basic_descriptor.hpp" -#include "asio/posix/basic_stream_descriptor.hpp" -#include "asio/posix/descriptor.hpp" -#include "asio/posix/descriptor_base.hpp" -#include "asio/posix/stream_descriptor.hpp" -#include "asio/post.hpp" -#include "asio/prefer.hpp" -#include "asio/query.hpp" -#include "asio/random_access_file.hpp" -#include "asio/read.hpp" -#include "asio/read_at.hpp" -#include "asio/read_until.hpp" -#include "asio/readable_pipe.hpp" -#include "asio/redirect_error.hpp" -#include "asio/registered_buffer.hpp" -#include "asio/require.hpp" -#include "asio/require_concept.hpp" -#include "asio/serial_port.hpp" -#include "asio/serial_port_base.hpp" -#include "asio/signal_set.hpp" -#include "asio/socket_base.hpp" -#include "asio/static_thread_pool.hpp" -#include "asio/steady_timer.hpp" -#include "asio/strand.hpp" -#include "asio/stream_file.hpp" -#include "asio/streambuf.hpp" -#include "asio/system_context.hpp" -#include "asio/system_error.hpp" -#include "asio/system_executor.hpp" -#include "asio/system_timer.hpp" -#include "asio/this_coro.hpp" -#include "asio/thread.hpp" -#include "asio/thread_pool.hpp" -#include "asio/time_traits.hpp" -#include "asio/use_awaitable.hpp" -#include "asio/use_future.hpp" -#include "asio/uses_executor.hpp" -#include "asio/version.hpp" -#include "asio/wait_traits.hpp" -#include "asio/windows/basic_object_handle.hpp" -#include "asio/windows/basic_overlapped_handle.hpp" -#include "asio/windows/basic_random_access_handle.hpp" -#include "asio/windows/basic_stream_handle.hpp" -#include "asio/windows/object_handle.hpp" -#include "asio/windows/overlapped_handle.hpp" -#include "asio/windows/overlapped_ptr.hpp" -#include "asio/windows/random_access_handle.hpp" -#include "asio/windows/stream_handle.hpp" -#include "asio/writable_pipe.hpp" -#include "asio/write.hpp" -#include "asio/write_at.hpp" - -#endif // ASIO_HPP diff --git a/demo_example/asio/asio/any_io_executor.hpp b/demo_example/asio/asio/any_io_executor.hpp deleted file mode 100644 index 50b0b249b..000000000 --- a/demo_example/asio/asio/any_io_executor.hpp +++ /dev/null @@ -1,303 +0,0 @@ -// -// any_io_executor.hpp -// ~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the 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 ASIO_ANY_IO_EXECUTOR_HPP -#define ASIO_ANY_IO_EXECUTOR_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/config.hpp" -#if defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) -# include "asio/executor.hpp" -#else // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) -# include "asio/execution.hpp" -# include "asio/execution_context.hpp" -#endif // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) - -#include "asio/detail/push_options.hpp" - -namespace asio { - -#if defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) - -typedef executor any_io_executor; - -#else // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) - -/// Polymorphic executor type for use with I/O objects. -/** - * The @c any_io_executor type is a polymorphic executor that supports the set - * of properties required by I/O objects. It is defined as the - * execution::any_executor class template parameterised as follows: - * @code execution::any_executor< - * execution::context_as_t, - * execution::blocking_t::never_t, - * execution::prefer_only, - * execution::prefer_only, - * execution::prefer_only, - * execution::prefer_only, - * execution::prefer_only - * > @endcode - */ -class any_io_executor : -#if defined(GENERATING_DOCUMENTATION) - public execution::any_executor<...> -#else // defined(GENERATING_DOCUMENTATION) - public execution::any_executor< - execution::context_as_t, - execution::blocking_t::never_t, - execution::prefer_only, - execution::prefer_only, - execution::prefer_only, - execution::prefer_only, - execution::prefer_only - > -#endif // defined(GENERATING_DOCUMENTATION) -{ -public: -#if !defined(GENERATING_DOCUMENTATION) - typedef execution::any_executor< - execution::context_as_t, - execution::blocking_t::never_t, - execution::prefer_only, - execution::prefer_only, - execution::prefer_only, - execution::prefer_only, - execution::prefer_only - > base_type; - - typedef void supportable_properties_type( - execution::context_as_t, - execution::blocking_t::never_t, - execution::prefer_only, - execution::prefer_only, - execution::prefer_only, - execution::prefer_only, - execution::prefer_only - ); -#endif // !defined(GENERATING_DOCUMENTATION) - - /// Default constructor. - ASIO_DECL any_io_executor() ASIO_NOEXCEPT; - - /// Construct in an empty state. Equivalent effects to default constructor. - ASIO_DECL any_io_executor(nullptr_t) ASIO_NOEXCEPT; - - /// Copy constructor. - ASIO_DECL any_io_executor(const any_io_executor& e) ASIO_NOEXCEPT; - -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - /// Move constructor. - ASIO_DECL any_io_executor(any_io_executor&& e) ASIO_NOEXCEPT; -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - - /// Construct to point to the same target as another any_executor. -#if defined(GENERATING_DOCUMENTATION) - template - any_io_executor(execution::any_executor e); -#else // defined(GENERATING_DOCUMENTATION) - template - any_io_executor(OtherAnyExecutor e, - typename constraint< - conditional< - !is_same::value - && is_base_of::value, - typename execution::detail::supportable_properties< - 0, supportable_properties_type>::template - is_valid_target, - false_type - >::type::value - >::type = 0) - : base_type(ASIO_MOVE_CAST(OtherAnyExecutor)(e)) - { - } -#endif // defined(GENERATING_DOCUMENTATION) - - /// Construct a polymorphic wrapper for the specified executor. -#if defined(GENERATING_DOCUMENTATION) - template - any_io_executor(Executor e); -#else // defined(GENERATING_DOCUMENTATION) - template - any_io_executor(Executor e, - typename constraint< - conditional< - !is_same::value - && !is_base_of::value, - execution::detail::is_valid_target_executor< - Executor, supportable_properties_type>, - false_type - >::type::value - >::type = 0) - : base_type(ASIO_MOVE_CAST(Executor)(e)) - { - } -#endif // defined(GENERATING_DOCUMENTATION) - - /// Assignment operator. - ASIO_DECL any_io_executor& operator=( - const any_io_executor& e) ASIO_NOEXCEPT; - -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - /// Move assignment operator. - ASIO_DECL any_io_executor& operator=( - any_io_executor&& e) ASIO_NOEXCEPT; -#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - - /// Assignment operator that sets the polymorphic wrapper to the empty state. - ASIO_DECL any_io_executor& operator=(nullptr_t); - - /// Destructor. - ASIO_DECL ~any_io_executor(); - - /// Swap targets with another polymorphic wrapper. - ASIO_DECL void swap(any_io_executor& other) ASIO_NOEXCEPT; - - /// Obtain a polymorphic wrapper with the specified property. - /** - * Do not call this function directly. It is intended for use with the - * asio::require and asio::prefer customisation points. - * - * For example: - * @code any_io_executor ex = ...; - * auto ex2 = asio::require(ex, execution::blocking.possibly); @endcode - */ - template - any_io_executor require(const Property& p, - typename constraint< - traits::require_member::is_valid - >::type = 0) const - { - return static_cast(*this).require(p); - } - - /// Obtain a polymorphic wrapper with the specified property. - /** - * Do not call this function directly. It is intended for use with the - * asio::prefer customisation point. - * - * For example: - * @code any_io_executor ex = ...; - * auto ex2 = asio::prefer(ex, execution::blocking.possibly); @endcode - */ - template - any_io_executor prefer(const Property& p, - typename constraint< - traits::prefer_member::is_valid - >::type = 0) const - { - return static_cast(*this).prefer(p); - } -}; - -#if !defined(GENERATING_DOCUMENTATION) - -template <> -ASIO_DECL any_io_executor any_io_executor::require( - const execution::blocking_t::never_t&, int) const; - -template <> -ASIO_DECL any_io_executor any_io_executor::prefer( - const execution::blocking_t::possibly_t&, int) const; - -template <> -ASIO_DECL any_io_executor any_io_executor::prefer( - const execution::outstanding_work_t::tracked_t&, int) const; - -template <> -ASIO_DECL any_io_executor any_io_executor::prefer( - const execution::outstanding_work_t::untracked_t&, int) const; - -template <> -ASIO_DECL any_io_executor any_io_executor::prefer( - const execution::relationship_t::fork_t&, int) const; - -template <> -ASIO_DECL any_io_executor any_io_executor::prefer( - const execution::relationship_t::continuation_t&, int) const; - -namespace traits { - -#if !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) - -template <> -struct equality_comparable -{ - static const bool is_valid = true; - static const bool is_noexcept = true; -}; - -#endif // !defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) - -#if !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) - -template -struct execute_member -{ - static const bool is_valid = true; - static const bool is_noexcept = false; - typedef void result_type; -}; - -#endif // !defined(ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) - -#if !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) - -template -struct query_member : - query_member -{ -}; - -#endif // !defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) - -#if !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) - -template -struct require_member : - require_member -{ - typedef any_io_executor result_type; -}; - -#endif // !defined(ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) - -#if !defined(ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT) - -template -struct prefer_member : - prefer_member -{ - typedef any_io_executor result_type; -}; - -#endif // !defined(ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT) - -} // namespace traits - -#endif // !defined(GENERATING_DOCUMENTATION) - -#endif // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) - -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#if defined(ASIO_HEADER_ONLY) \ - && !defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) -# include "asio/impl/any_io_executor.ipp" -#endif // defined(ASIO_HEADER_ONLY) - // && !defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) - -#endif // ASIO_ANY_IO_EXECUTOR_HPP diff --git a/demo_example/asio/asio/associated_allocator.hpp b/demo_example/asio/asio/associated_allocator.hpp deleted file mode 100644 index 3f945834a..000000000 --- a/demo_example/asio/asio/associated_allocator.hpp +++ /dev/null @@ -1,177 +0,0 @@ -// -// associated_allocator.hpp -// ~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the 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 ASIO_ASSOCIATED_ALLOCATOR_HPP -#define ASIO_ASSOCIATED_ALLOCATOR_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/config.hpp" -#include -#include "asio/associator.hpp" -#include "asio/detail/functional.hpp" -#include "asio/detail/type_traits.hpp" - -#include "asio/detail/push_options.hpp" - -namespace asio { - -template -struct associated_allocator; - -namespace detail { - -template -struct has_allocator_type : false_type -{ -}; - -template -struct has_allocator_type::type> - : true_type -{ -}; - -template -struct associated_allocator_impl -{ - typedef E type; - - static type get(const T&, const E& e) ASIO_NOEXCEPT - { - return e; - } -}; - -template -struct associated_allocator_impl::type> -{ - typedef typename T::allocator_type type; - - static type get(const T& t, const E&) ASIO_NOEXCEPT - { - return t.get_allocator(); - } -}; - -template -struct associated_allocator_impl::value - >::type, - typename void_type< - typename associator::type - >::type> : associator -{ -}; - -} // namespace detail - -/// Traits type used to obtain the allocator associated with an object. -/** - * A program may specialise this traits type if the @c T template parameter in - * the specialisation is a user-defined type. The template parameter @c - * Allocator shall be a type meeting the Allocator requirements. - * - * Specialisations shall meet the following requirements, where @c t is a const - * reference to an object of type @c T, and @c a is an object of type @c - * Allocator. - * - * @li Provide a nested typedef @c type that identifies a type meeting the - * Allocator requirements. - * - * @li Provide a noexcept static member function named @c get, callable as @c - * get(t) and with return type @c type. - * - * @li Provide a noexcept static member function named @c get, callable as @c - * get(t,a) and with return type @c type. - */ -template > -struct associated_allocator -{ - /// If @c T has a nested type @c allocator_type, T::allocator_type. - /// Otherwise @c Allocator. -#if defined(GENERATING_DOCUMENTATION) - typedef see_below type; -#else // defined(GENERATING_DOCUMENTATION) - typedef typename detail::associated_allocator_impl::type type; -#endif // defined(GENERATING_DOCUMENTATION) - - /// If @c T has a nested type @c allocator_type, returns - /// t.get_allocator(). Otherwise returns @c a. - static type get(const T& t, - const Allocator& a = Allocator()) ASIO_NOEXCEPT - { - return detail::associated_allocator_impl::get(t, a); - } -}; - -/// Helper function to obtain an object's associated allocator. -/** - * @returns associated_allocator::get(t) - */ -template -inline typename associated_allocator::type -get_associated_allocator(const T& t) ASIO_NOEXCEPT -{ - return associated_allocator::get(t); -} - -/// Helper function to obtain an object's associated allocator. -/** - * @returns associated_allocator::get(t, a) - */ -template -inline typename associated_allocator::type -get_associated_allocator(const T& t, const Allocator& a) ASIO_NOEXCEPT -{ - return associated_allocator::get(t, a); -} - -#if defined(ASIO_HAS_ALIAS_TEMPLATES) - -template > -using associated_allocator_t - = typename associated_allocator::type; - -#endif // defined(ASIO_HAS_ALIAS_TEMPLATES) - -#if defined(ASIO_HAS_STD_REFERENCE_WRAPPER) \ - || defined(GENERATING_DOCUMENTATION) - -/// Specialisation of associated_allocator for @c std::reference_wrapper. -template -struct associated_allocator, Allocator> -{ - /// Forwards @c type to the associator specialisation for the unwrapped type - /// @c T. - typedef typename associated_allocator::type type; - - /// Forwards the request to get the allocator to the associator specialisation - /// for the unwrapped type @c T. - static type get(reference_wrapper t, - const Allocator& a = Allocator()) ASIO_NOEXCEPT - { - return associated_allocator::get(t.get(), a); - } -}; - -#endif // defined(ASIO_HAS_STD_REFERENCE_WRAPPER) - // || defined(GENERATING_DOCUMENTATION) - -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_ASSOCIATED_ALLOCATOR_HPP diff --git a/demo_example/asio/asio/associated_cancellation_slot.hpp b/demo_example/asio/asio/associated_cancellation_slot.hpp deleted file mode 100644 index 6a809e711..000000000 --- a/demo_example/asio/asio/associated_cancellation_slot.hpp +++ /dev/null @@ -1,177 +0,0 @@ -// -// associated_cancellation_slot.hpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the 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 ASIO_ASSOCIATED_CANCELLATION_SLOT_HPP -#define ASIO_ASSOCIATED_CANCELLATION_SLOT_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/config.hpp" -#include "asio/associator.hpp" -#include "asio/cancellation_signal.hpp" -#include "asio/detail/type_traits.hpp" - -#include "asio/detail/push_options.hpp" - -namespace asio { - -template -struct associated_cancellation_slot; - -namespace detail { - -template -struct has_cancellation_slot_type : false_type -{ -}; - -template -struct has_cancellation_slot_type::type> - : true_type -{ -}; - -template -struct associated_cancellation_slot_impl -{ - typedef void asio_associated_cancellation_slot_is_unspecialised; - - typedef S type; - - static type get(const T&, const S& s = S()) ASIO_NOEXCEPT - { - return s; - } -}; - -template -struct associated_cancellation_slot_impl::type> -{ - typedef typename T::cancellation_slot_type type; - - static type get(const T& t, const S& = S()) ASIO_NOEXCEPT - { - return t.get_cancellation_slot(); - } -}; - -template -struct associated_cancellation_slot_impl::value - >::type, - typename void_type< - typename associator::type - >::type> : associator -{ -}; - -} // namespace detail - -/// Traits type used to obtain the cancellation_slot associated with an object. -/** - * A program may specialise this traits type if the @c T template parameter in - * the specialisation is a user-defined type. The template parameter @c - * CancellationSlot shall be a type meeting the CancellationSlot requirements. - * - * Specialisations shall meet the following requirements, where @c t is a const - * reference to an object of type @c T, and @c s is an object of type @c - * CancellationSlot. - * - * @li Provide a nested typedef @c type that identifies a type meeting the - * CancellationSlot requirements. - * - * @li Provide a noexcept static member function named @c get, callable as @c - * get(t) and with return type @c type. - * - * @li Provide a noexcept static member function named @c get, callable as @c - * get(t,s) and with return type @c type. - */ -template -struct associated_cancellation_slot -#if !defined(GENERATING_DOCUMENTATION) - : detail::associated_cancellation_slot_impl -#endif // !defined(GENERATING_DOCUMENTATION) -{ -#if defined(GENERATING_DOCUMENTATION) - /// If @c T has a nested type @c cancellation_slot_type, - /// T::cancellation_slot_type. Otherwise - /// @c CancellationSlot. - typedef see_below type; - - /// If @c T has a nested type @c cancellation_slot_type, returns - /// t.get_cancellation_slot(). Otherwise returns @c s. - static type get(const T& t, - const CancellationSlot& s = CancellationSlot()) ASIO_NOEXCEPT; -#endif // defined(GENERATING_DOCUMENTATION) -}; - -/// Helper function to obtain an object's associated cancellation_slot. -/** - * @returns associated_cancellation_slot::get(t) - */ -template -inline typename associated_cancellation_slot::type -get_associated_cancellation_slot(const T& t) ASIO_NOEXCEPT -{ - return associated_cancellation_slot::get(t); -} - -/// Helper function to obtain an object's associated cancellation_slot. -/** - * @returns associated_cancellation_slot::get(t, st) - */ -template -inline typename associated_cancellation_slot::type -get_associated_cancellation_slot(const T& t, - const CancellationSlot& st) ASIO_NOEXCEPT -{ - return associated_cancellation_slot::get(t, st); -} - -#if defined(ASIO_HAS_ALIAS_TEMPLATES) - -template -using associated_cancellation_slot_t = - typename associated_cancellation_slot::type; - -#endif // defined(ASIO_HAS_ALIAS_TEMPLATES) - -namespace detail { - -template -struct associated_cancellation_slot_forwarding_base -{ -}; - -template -struct associated_cancellation_slot_forwarding_base::asio_associated_cancellation_slot_is_unspecialised, - void - >::value - >::type> -{ - typedef void asio_associated_cancellation_slot_is_unspecialised; -}; - -} // namespace detail -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_ASSOCIATED_CANCELLATION_SLOT_HPP diff --git a/demo_example/asio/asio/associated_executor.hpp b/demo_example/asio/asio/associated_executor.hpp deleted file mode 100644 index 1e62e37a1..000000000 --- a/demo_example/asio/asio/associated_executor.hpp +++ /dev/null @@ -1,222 +0,0 @@ -// -// associated_executor.hpp -// ~~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the 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 ASIO_ASSOCIATED_EXECUTOR_HPP -#define ASIO_ASSOCIATED_EXECUTOR_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/config.hpp" -#include "asio/associator.hpp" -#include "asio/detail/functional.hpp" -#include "asio/detail/type_traits.hpp" -#include "asio/execution/executor.hpp" -#include "asio/is_executor.hpp" -#include "asio/system_executor.hpp" - -#include "asio/detail/push_options.hpp" - -namespace asio { - -template -struct associated_executor; - -namespace detail { - -template -struct has_executor_type : false_type -{ -}; - -template -struct has_executor_type::type> - : true_type -{ -}; - -template -struct associated_executor_impl -{ - typedef void asio_associated_executor_is_unspecialised; - - typedef E type; - - static type get(const T&, const E& e = E()) ASIO_NOEXCEPT - { - return e; - } -}; - -template -struct associated_executor_impl::type> -{ - typedef typename T::executor_type type; - - static type get(const T& t, const E& = E()) ASIO_NOEXCEPT - { - return t.get_executor(); - } -}; - -template -struct associated_executor_impl::value - >::type, - typename void_type< - typename associator::type - >::type> : associator -{ -}; - -} // namespace detail - -/// Traits type used to obtain the executor associated with an object. -/** - * A program may specialise this traits type if the @c T template parameter in - * the specialisation is a user-defined type. The template parameter @c - * Executor shall be a type meeting the Executor requirements. - * - * Specialisations shall meet the following requirements, where @c t is a const - * reference to an object of type @c T, and @c e is an object of type @c - * Executor. - * - * @li Provide a nested typedef @c type that identifies a type meeting the - * Executor requirements. - * - * @li Provide a noexcept static member function named @c get, callable as @c - * get(t) and with return type @c type. - * - * @li Provide a noexcept static member function named @c get, callable as @c - * get(t,e) and with return type @c type. - */ -template -struct associated_executor -#if !defined(GENERATING_DOCUMENTATION) - : detail::associated_executor_impl -#endif // !defined(GENERATING_DOCUMENTATION) -{ -#if defined(GENERATING_DOCUMENTATION) - /// If @c T has a nested type @c executor_type, T::executor_type. - /// Otherwise @c Executor. - typedef see_below type; - - /// If @c T has a nested type @c executor_type, returns - /// t.get_executor(). Otherwise returns @c ex. - static type get(const T& t, - const Executor& ex = Executor()) ASIO_NOEXCEPT; -#endif // defined(GENERATING_DOCUMENTATION) -}; - -/// Helper function to obtain an object's associated executor. -/** - * @returns associated_executor::get(t) - */ -template -inline typename associated_executor::type -get_associated_executor(const T& t) ASIO_NOEXCEPT -{ - return associated_executor::get(t); -} - -/// Helper function to obtain an object's associated executor. -/** - * @returns associated_executor::get(t, ex) - */ -template -inline typename associated_executor::type -get_associated_executor(const T& t, const Executor& ex, - typename constraint< - is_executor::value || execution::is_executor::value - >::type = 0) ASIO_NOEXCEPT -{ - return associated_executor::get(t, ex); -} - -/// Helper function to obtain an object's associated executor. -/** - * @returns associated_executor::get(t, ctx.get_executor()) - */ -template -inline typename associated_executor::type -get_associated_executor(const T& t, ExecutionContext& ctx, - typename constraint::value>::type = 0) ASIO_NOEXCEPT -{ - return associated_executor::get(t, ctx.get_executor()); -} - -#if defined(ASIO_HAS_ALIAS_TEMPLATES) - -template -using associated_executor_t = typename associated_executor::type; - -#endif // defined(ASIO_HAS_ALIAS_TEMPLATES) - -namespace detail { - -template -struct associated_executor_forwarding_base -{ -}; - -template -struct associated_executor_forwarding_base::asio_associated_executor_is_unspecialised, - void - >::value - >::type> -{ - typedef void asio_associated_executor_is_unspecialised; -}; - -} // namespace detail - -#if defined(ASIO_HAS_STD_REFERENCE_WRAPPER) \ - || defined(GENERATING_DOCUMENTATION) - -/// Specialisation of associated_executor for @c std::reference_wrapper. -template -struct associated_executor, Executor> -#if !defined(GENERATING_DOCUMENTATION) - : detail::associated_executor_forwarding_base -#endif // !defined(GENERATING_DOCUMENTATION) -{ - /// Forwards @c type to the associator specialisation for the unwrapped type - /// @c T. - typedef typename associated_executor::type type; - - /// Forwards the request to get the executor to the associator specialisation - /// for the unwrapped type @c T. - static type get(reference_wrapper t, - const Executor& ex = Executor()) ASIO_NOEXCEPT - { - return associated_executor::get(t.get(), ex); - } -}; - -#endif // defined(ASIO_HAS_STD_REFERENCE_WRAPPER) - // || defined(GENERATING_DOCUMENTATION) - -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_ASSOCIATED_EXECUTOR_HPP diff --git a/demo_example/asio/asio/associator.hpp b/demo_example/asio/asio/associator.hpp deleted file mode 100644 index 0f93b1206..000000000 --- a/demo_example/asio/asio/associator.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// -// associator.hpp -// ~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the 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 ASIO_ASSOCIATOR_HPP -#define ASIO_ASSOCIATOR_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/config.hpp" - -#include "asio/detail/push_options.hpp" - -namespace asio { - -/// Used to generically specialise associators for a type. -template