From 0f7191ad54f7ac9e30a975949eeeb90e7ffec64a Mon Sep 17 00:00:00 2001 From: DcruBro Date: Thu, 6 Nov 2025 15:51:56 +0100 Subject: [PATCH] Initial Commit --- .gitignore | 15 + ATTRIBUTIONS.md | 10 + CMakeLists.txt | 103 + LICENSE | 674 +++ README.md | 54 + include/asio/any_completion_executor.hpp | 336 ++ include/asio/any_completion_handler.hpp | 822 ++++ include/asio/any_io_executor.hpp | 351 ++ include/asio/append.hpp | 65 + include/asio/as_tuple.hpp | 152 + include/asio/asio.hpp | 202 + include/asio/associated_allocator.hpp | 214 + include/asio/associated_cancellation_slot.hpp | 221 + include/asio/associated_executor.hpp | 235 + .../asio/associated_immediate_executor.hpp | 281 ++ include/asio/associator.hpp | 35 + include/asio/async_result.hpp | 968 ++++ include/asio/awaitable.hpp | 145 + include/asio/basic_datagram_socket.hpp | 1362 ++++++ include/asio/basic_deadline_timer.hpp | 715 +++ include/asio/basic_file.hpp | 936 ++++ include/asio/basic_io_object.hpp | 287 ++ include/asio/basic_random_access_file.hpp | 689 +++ include/asio/basic_raw_socket.hpp | 1356 ++++++ include/asio/basic_readable_pipe.hpp | 626 +++ include/asio/basic_seq_packet_socket.hpp | 823 ++++ include/asio/basic_serial_port.hpp | 987 ++++ include/asio/basic_signal_set.hpp | 653 +++ include/asio/basic_socket.hpp | 1936 ++++++++ include/asio/basic_socket_acceptor.hpp | 2708 +++++++++++ include/asio/basic_socket_iostream.hpp | 266 ++ include/asio/basic_socket_streambuf.hpp | 545 +++ include/asio/basic_stream_file.hpp | 744 +++ include/asio/basic_stream_socket.hpp | 1163 +++++ include/asio/basic_streambuf.hpp | 450 ++ include/asio/basic_streambuf_fwd.hpp | 36 + include/asio/basic_waitable_timer.hpp | 645 +++ include/asio/basic_writable_pipe.hpp | 622 +++ include/asio/bind_allocator.hpp | 603 +++ include/asio/bind_cancellation_slot.hpp | 620 +++ include/asio/bind_executor.hpp | 671 +++ include/asio/bind_immediate_executor.hpp | 623 +++ include/asio/buffer.hpp | 2881 ++++++++++++ include/asio/buffer_registration.hpp | 318 ++ include/asio/buffered_read_stream.hpp | 273 ++ include/asio/buffered_read_stream_fwd.hpp | 25 + include/asio/buffered_stream.hpp | 292 ++ include/asio/buffered_stream_fwd.hpp | 25 + include/asio/buffered_write_stream.hpp | 265 ++ include/asio/buffered_write_stream_fwd.hpp | 25 + include/asio/buffers_iterator.hpp | 501 ++ include/asio/cancel_after.hpp | 301 ++ include/asio/cancel_at.hpp | 294 ++ include/asio/cancellation_signal.hpp | 245 + include/asio/cancellation_state.hpp | 235 + include/asio/cancellation_type.hpp | 157 + include/asio/co_composed.hpp | 1319 ++++++ include/asio/co_spawn.hpp | 523 +++ include/asio/completion_condition.hpp | 267 ++ include/asio/compose.hpp | 128 + include/asio/composed.hpp | 413 ++ include/asio/config.hpp | 193 + include/asio/connect.hpp | 1020 +++++ include/asio/connect_pipe.hpp | 83 + include/asio/consign.hpp | 75 + include/asio/coroutine.hpp | 328 ++ include/asio/deadline_timer.hpp | 43 + include/asio/default_completion_token.hpp | 89 + include/asio/defer.hpp | 218 + include/asio/deferred.hpp | 719 +++ include/asio/detached.hpp | 105 + include/asio/detail/array.hpp | 30 + include/asio/detail/array_fwd.hpp | 32 + include/asio/detail/assert.hpp | 32 + include/asio/detail/atomic_count.hpp | 59 + .../detail/base_from_cancellation_state.hpp | 164 + .../asio/detail/base_from_completion_cond.hpp | 69 + include/asio/detail/bind_handler.hpp | 711 +++ include/asio/detail/blocking_executor_op.hpp | 107 + include/asio/detail/buffer_resize_guard.hpp | 66 + .../asio/detail/buffer_sequence_adapter.hpp | 697 +++ .../asio/detail/buffered_stream_storage.hpp | 126 + include/asio/detail/call_stack.hpp | 125 + include/asio/detail/chrono.hpp | 45 + include/asio/detail/chrono_time_traits.hpp | 190 + include/asio/detail/completion_handler.hpp | 88 + include/asio/detail/completion_message.hpp | 127 + include/asio/detail/completion_payload.hpp | 220 + .../detail/completion_payload_handler.hpp | 79 + include/asio/detail/composed_work.hpp | 252 + include/asio/detail/concurrency_hint.hpp | 94 + .../detail/conditionally_enabled_event.hpp | 120 + .../detail/conditionally_enabled_mutex.hpp | 170 + include/asio/detail/config.hpp | 1431 ++++++ include/asio/detail/consuming_buffers.hpp | 405 ++ include/asio/detail/cstddef.hpp | 27 + include/asio/detail/cstdint.hpp | 40 + include/asio/detail/date_time_fwd.hpp | 34 + .../asio/detail/deadline_timer_service.hpp | 345 ++ include/asio/detail/dependent_type.hpp | 36 + include/asio/detail/descriptor_ops.hpp | 179 + include/asio/detail/descriptor_read_op.hpp | 188 + include/asio/detail/descriptor_write_op.hpp | 187 + include/asio/detail/dev_poll_reactor.hpp | 248 + include/asio/detail/epoll_reactor.hpp | 300 ++ include/asio/detail/event.hpp | 46 + .../detail/eventfd_select_interrupter.hpp | 83 + include/asio/detail/exception.hpp | 29 + include/asio/detail/executor_function.hpp | 152 + include/asio/detail/executor_op.hpp | 84 + include/asio/detail/fd_set_adapter.hpp | 39 + include/asio/detail/fenced_block.hpp | 40 + include/asio/detail/functional.hpp | 33 + include/asio/detail/future.hpp | 32 + include/asio/detail/global.hpp | 50 + include/asio/detail/handler_alloc_helpers.hpp | 123 + include/asio/detail/handler_cont_helpers.hpp | 45 + include/asio/detail/handler_tracking.hpp | 264 ++ .../asio/detail/handler_type_requirements.hpp | 531 +++ include/asio/detail/handler_work.hpp | 511 +++ include/asio/detail/hash_map.hpp | 331 ++ .../detail/impl/buffer_sequence_adapter.ipp | 118 + include/asio/detail/impl/descriptor_ops.ipp | 994 ++++ include/asio/detail/impl/dev_poll_reactor.hpp | 117 + include/asio/detail/impl/dev_poll_reactor.ipp | 469 ++ include/asio/detail/impl/epoll_reactor.hpp | 114 + include/asio/detail/impl/epoll_reactor.ipp | 840 ++++ .../impl/eventfd_select_interrupter.ipp | 171 + include/asio/detail/impl/handler_tracking.ipp | 387 ++ .../impl/io_uring_descriptor_service.ipp | 205 + .../detail/impl/io_uring_file_service.ipp | 140 + include/asio/detail/impl/io_uring_service.hpp | 118 + include/asio/detail/impl/io_uring_service.ipp | 918 ++++ .../impl/io_uring_socket_service_base.ipp | 249 + include/asio/detail/impl/kqueue_reactor.hpp | 117 + include/asio/detail/impl/kqueue_reactor.ipp | 614 +++ include/asio/detail/impl/null_event.ipp | 74 + .../detail/impl/pipe_select_interrupter.ipp | 129 + include/asio/detail/impl/posix_event.ipp | 63 + include/asio/detail/impl/posix_mutex.ipp | 46 + .../detail/impl/posix_serial_port_service.ipp | 168 + include/asio/detail/impl/posix_thread.ipp | 84 + include/asio/detail/impl/posix_tss_ptr.ipp | 46 + .../impl/reactive_descriptor_service.ipp | 232 + .../impl/reactive_socket_service_base.ipp | 312 ++ .../detail/impl/resolver_service_base.ipp | 79 + .../asio/detail/impl/resolver_thread_pool.ipp | 124 + include/asio/detail/impl/scheduler.ipp | 696 +++ include/asio/detail/impl/select_reactor.hpp | 130 + include/asio/detail/impl/select_reactor.ipp | 389 ++ include/asio/detail/impl/service_registry.hpp | 117 + include/asio/detail/impl/service_registry.ipp | 205 + .../asio/detail/impl/signal_set_service.ipp | 825 ++++ include/asio/detail/impl/socket_ops.ipp | 4044 +++++++++++++++++ .../detail/impl/socket_select_interrupter.ipp | 185 + .../detail/impl/strand_executor_service.hpp | 346 ++ .../detail/impl/strand_executor_service.ipp | 159 + include/asio/detail/impl/strand_service.hpp | 86 + include/asio/detail/impl/strand_service.ipp | 205 + include/asio/detail/impl/thread_context.ipp | 35 + include/asio/detail/impl/throw_error.ipp | 49 + include/asio/detail/impl/timer_queue_set.ipp | 101 + include/asio/detail/impl/win_event.ipp | 76 + .../detail/impl/win_iocp_file_service.ipp | 288 ++ .../detail/impl/win_iocp_handle_service.ipp | 619 +++ .../asio/detail/impl/win_iocp_io_context.hpp | 123 + .../asio/detail/impl/win_iocp_io_context.ipp | 636 +++ .../impl/win_iocp_serial_port_service.ipp | 200 + .../impl/win_iocp_socket_service_base.ipp | 821 ++++ include/asio/detail/impl/win_mutex.ipp | 84 + .../detail/impl/win_object_handle_service.ipp | 452 ++ include/asio/detail/impl/win_static_mutex.ipp | 136 + include/asio/detail/impl/win_thread.ipp | 151 + include/asio/detail/impl/win_tss_ptr.ipp | 57 + .../impl/winrt_ssocket_service_base.ipp | 626 +++ .../detail/impl/winrt_timer_scheduler.hpp | 98 + .../detail/impl/winrt_timer_scheduler.ipp | 114 + include/asio/detail/impl/winsock_init.ipp | 82 + include/asio/detail/initiate_defer.hpp | 207 + include/asio/detail/initiate_dispatch.hpp | 193 + include/asio/detail/initiate_post.hpp | 207 + include/asio/detail/initiation_base.hpp | 62 + include/asio/detail/io_control.hpp | 84 + include/asio/detail/io_object_impl.hpp | 177 + .../detail/io_uring_descriptor_read_at_op.hpp | 195 + .../detail/io_uring_descriptor_read_op.hpp | 190 + .../detail/io_uring_descriptor_service.hpp | 687 +++ .../io_uring_descriptor_write_at_op.hpp | 189 + .../detail/io_uring_descriptor_write_op.hpp | 185 + include/asio/detail/io_uring_file_service.hpp | 261 ++ .../asio/detail/io_uring_null_buffers_op.hpp | 114 + include/asio/detail/io_uring_operation.hpp | 84 + include/asio/detail/io_uring_service.hpp | 324 ++ .../asio/detail/io_uring_socket_accept_op.hpp | 280 ++ .../detail/io_uring_socket_connect_op.hpp | 140 + .../asio/detail/io_uring_socket_recv_op.hpp | 205 + .../detail/io_uring_socket_recvfrom_op.hpp | 206 + .../detail/io_uring_socket_recvmsg_op.hpp | 192 + .../asio/detail/io_uring_socket_send_op.hpp | 191 + .../asio/detail/io_uring_socket_sendto_op.hpp | 194 + .../asio/detail/io_uring_socket_service.hpp | 629 +++ .../detail/io_uring_socket_service_base.hpp | 663 +++ include/asio/detail/io_uring_wait_op.hpp | 112 + include/asio/detail/is_buffer_sequence.hpp | 296 ++ include/asio/detail/is_executor.hpp | 126 + include/asio/detail/keyword_tss_ptr.hpp | 70 + include/asio/detail/kqueue_reactor.hpp | 277 ++ include/asio/detail/limits.hpp | 21 + .../asio/detail/local_free_on_block_exit.hpp | 59 + include/asio/detail/memory.hpp | 154 + include/asio/detail/mutex.hpp | 46 + include/asio/detail/non_const_lvalue.hpp | 43 + include/asio/detail/noncopyable.hpp | 43 + include/asio/detail/null_event.hpp | 106 + include/asio/detail/null_fenced_block.hpp | 47 + include/asio/detail/null_global.hpp | 59 + include/asio/detail/null_mutex.hpp | 66 + include/asio/detail/null_reactor.hpp | 83 + include/asio/detail/null_signal_blocker.hpp | 69 + include/asio/detail/null_socket_service.hpp | 519 +++ include/asio/detail/null_static_mutex.hpp | 66 + include/asio/detail/null_thread.hpp | 95 + include/asio/detail/null_tss_ptr.hpp | 68 + include/asio/detail/object_pool.hpp | 127 + include/asio/detail/old_win_sdk_compat.hpp | 214 + include/asio/detail/op_queue.hpp | 162 + include/asio/detail/operation.hpp | 38 + .../asio/detail/pipe_select_interrupter.hpp | 89 + include/asio/detail/pop_options.hpp | 157 + include/asio/detail/posix_event.hpp | 175 + include/asio/detail/posix_fd_set_adapter.hpp | 118 + include/asio/detail/posix_global.hpp | 80 + include/asio/detail/posix_mutex.hpp | 82 + .../asio/detail/posix_serial_port_service.hpp | 249 + include/asio/detail/posix_signal_blocker.hpp | 85 + include/asio/detail/posix_static_mutex.hpp | 64 + include/asio/detail/posix_thread.hpp | 144 + include/asio/detail/posix_tss_ptr.hpp | 79 + include/asio/detail/push_options.hpp | 228 + .../detail/reactive_descriptor_service.hpp | 570 +++ .../asio/detail/reactive_null_buffers_op.hpp | 131 + .../asio/detail/reactive_socket_accept_op.hpp | 323 ++ .../detail/reactive_socket_connect_op.hpp | 162 + .../asio/detail/reactive_socket_recv_op.hpp | 197 + .../detail/reactive_socket_recvfrom_op.hpp | 203 + .../detail/reactive_socket_recvmsg_op.hpp | 184 + .../asio/detail/reactive_socket_send_op.hpp | 200 + .../asio/detail/reactive_socket_sendto_op.hpp | 194 + .../asio/detail/reactive_socket_service.hpp | 633 +++ .../detail/reactive_socket_service_base.hpp | 755 +++ include/asio/detail/reactive_wait_op.hpp | 131 + include/asio/detail/reactor.hpp | 54 + include/asio/detail/reactor_op.hpp | 71 + include/asio/detail/reactor_op_queue.hpp | 212 + include/asio/detail/recycling_allocator.hpp | 114 + include/asio/detail/regex_fwd.hpp | 35 + include/asio/detail/resolve_endpoint_op.hpp | 140 + include/asio/detail/resolve_op.hpp | 45 + include/asio/detail/resolve_query_op.hpp | 150 + include/asio/detail/resolver_service.hpp | 140 + include/asio/detail/resolver_service_base.hpp | 125 + include/asio/detail/resolver_thread_pool.hpp | 105 + include/asio/detail/scheduler.hpp | 243 + include/asio/detail/scheduler_operation.hpp | 78 + include/asio/detail/scheduler_task.hpp | 49 + include/asio/detail/scheduler_thread_info.hpp | 40 + include/asio/detail/scoped_lock.hpp | 101 + include/asio/detail/scoped_ptr.hpp | 87 + include/asio/detail/select_interrupter.hpp | 46 + include/asio/detail/select_reactor.hpp | 292 ++ include/asio/detail/service_registry.hpp | 173 + include/asio/detail/signal_blocker.hpp | 44 + include/asio/detail/signal_handler.hpp | 90 + include/asio/detail/signal_init.hpp | 47 + include/asio/detail/signal_op.hpp | 53 + include/asio/detail/signal_set_service.hpp | 292 ++ include/asio/detail/socket_holder.hpp | 98 + include/asio/detail/socket_ops.hpp | 375 ++ include/asio/detail/socket_option.hpp | 316 ++ .../asio/detail/socket_select_interrupter.hpp | 91 + include/asio/detail/socket_types.hpp | 431 ++ include/asio/detail/source_location.hpp | 45 + include/asio/detail/static_mutex.hpp | 50 + include/asio/detail/std_event.hpp | 183 + include/asio/detail/std_fenced_block.hpp | 57 + include/asio/detail/std_global.hpp | 65 + include/asio/detail/std_mutex.hpp | 74 + include/asio/detail/std_static_mutex.hpp | 76 + include/asio/detail/std_thread.hpp | 96 + .../asio/detail/strand_executor_service.hpp | 172 + include/asio/detail/strand_service.hpp | 143 + include/asio/detail/string_view.hpp | 47 + include/asio/detail/thread.hpp | 58 + include/asio/detail/thread_context.hpp | 51 + include/asio/detail/thread_group.hpp | 104 + include/asio/detail/thread_info_base.hpp | 260 ++ include/asio/detail/throw_error.hpp | 62 + include/asio/detail/throw_exception.hpp | 55 + include/asio/detail/timed_cancel_op.hpp | 361 ++ include/asio/detail/timer_queue.hpp | 393 ++ include/asio/detail/timer_queue_base.hpp | 68 + include/asio/detail/timer_queue_set.hpp | 66 + include/asio/detail/timer_scheduler.hpp | 37 + include/asio/detail/timer_scheduler_fwd.hpp | 42 + include/asio/detail/tss_ptr.hpp | 69 + include/asio/detail/type_traits.hpp | 190 + include/asio/detail/utility.hpp | 83 + include/asio/detail/wait_handler.hpp | 90 + include/asio/detail/wait_op.hpp | 49 + include/asio/detail/win_event.hpp | 164 + include/asio/detail/win_fd_set_adapter.hpp | 149 + include/asio/detail/win_global.hpp | 71 + include/asio/detail/win_iocp_file_service.hpp | 287 ++ .../asio/detail/win_iocp_handle_read_op.hpp | 119 + .../asio/detail/win_iocp_handle_service.hpp | 431 ++ .../asio/detail/win_iocp_handle_write_op.hpp | 114 + include/asio/detail/win_iocp_io_context.hpp | 347 ++ .../asio/detail/win_iocp_null_buffers_op.hpp | 129 + include/asio/detail/win_iocp_operation.hpp | 96 + .../asio/detail/win_iocp_overlapped_op.hpp | 100 + .../asio/detail/win_iocp_overlapped_ptr.hpp | 171 + .../detail/win_iocp_serial_port_service.hpp | 233 + .../asio/detail/win_iocp_socket_accept_op.hpp | 339 ++ .../detail/win_iocp_socket_connect_op.hpp | 138 + .../asio/detail/win_iocp_socket_recv_op.hpp | 126 + .../detail/win_iocp_socket_recvfrom_op.hpp | 135 + .../detail/win_iocp_socket_recvmsg_op.hpp | 127 + .../asio/detail/win_iocp_socket_send_op.hpp | 120 + .../asio/detail/win_iocp_socket_service.hpp | 680 +++ .../detail/win_iocp_socket_service_base.hpp | 829 ++++ include/asio/detail/win_iocp_thread_info.hpp | 34 + include/asio/detail/win_iocp_wait_op.hpp | 130 + include/asio/detail/win_mutex.hpp | 84 + .../asio/detail/win_object_handle_service.hpp | 194 + include/asio/detail/win_static_mutex.hpp | 74 + include/asio/detail/win_thread.hpp | 183 + include/asio/detail/win_tss_ptr.hpp | 79 + include/asio/detail/winapp_thread.hpp | 171 + include/asio/detail/wince_thread.hpp | 171 + include/asio/detail/winrt_async_manager.hpp | 305 ++ include/asio/detail/winrt_async_op.hpp | 65 + include/asio/detail/winrt_resolve_op.hpp | 125 + .../asio/detail/winrt_resolver_service.hpp | 212 + .../asio/detail/winrt_socket_connect_op.hpp | 98 + include/asio/detail/winrt_socket_recv_op.hpp | 119 + include/asio/detail/winrt_socket_send_op.hpp | 110 + include/asio/detail/winrt_ssocket_service.hpp | 250 + .../detail/winrt_ssocket_service_base.hpp | 362 ++ include/asio/detail/winrt_timer_scheduler.hpp | 148 + include/asio/detail/winrt_utils.hpp | 106 + include/asio/detail/winsock_init.hpp | 128 + include/asio/detail/work_dispatcher.hpp | 143 + include/asio/detail/wrapped_handler.hpp | 208 + include/asio/dispatch.hpp | 197 + include/asio/disposition.hpp | 282 ++ include/asio/error.hpp | 389 ++ include/asio/error_code.hpp | 39 + include/asio/execution.hpp | 33 + include/asio/execution/allocator.hpp | 278 ++ include/asio/execution/any_executor.hpp | 1933 ++++++++ include/asio/execution/bad_executor.hpp | 46 + include/asio/execution/blocking.hpp | 1360 ++++++ .../asio/execution/blocking_adaptation.hpp | 1119 +++++ include/asio/execution/context.hpp | 191 + include/asio/execution/context_as.hpp | 190 + include/asio/execution/executor.hpp | 116 + include/asio/execution/impl/bad_executor.ipp | 40 + .../asio/execution/invocable_archetype.hpp | 43 + include/asio/execution/mapping.hpp | 1002 ++++ include/asio/execution/occupancy.hpp | 184 + include/asio/execution/outstanding_work.hpp | 753 +++ include/asio/execution/prefer_only.hpp | 328 ++ include/asio/execution/relationship.hpp | 751 +++ include/asio/execution_context.hpp | 587 +++ include/asio/executor.hpp | 363 ++ include/asio/executor_work_guard.hpp | 362 ++ include/asio/experimental/as_single.hpp | 132 + .../asio/experimental/awaitable_operators.hpp | 536 +++ include/asio/experimental/basic_channel.hpp | 514 +++ .../experimental/basic_concurrent_channel.hpp | 514 +++ .../experimental/cancellation_condition.hpp | 139 + include/asio/experimental/channel.hpp | 76 + include/asio/experimental/channel_error.hpp | 82 + include/asio/experimental/channel_traits.hpp | 301 ++ include/asio/experimental/co_composed.hpp | 33 + include/asio/experimental/co_spawn.hpp | 187 + .../asio/experimental/concurrent_channel.hpp | 76 + include/asio/experimental/coro.hpp | 293 ++ include/asio/experimental/coro_traits.hpp | 228 + .../experimental/detail/channel_operation.hpp | 361 ++ .../detail/channel_receive_op.hpp | 126 + .../detail/channel_send_functions.hpp | 200 + .../experimental/detail/channel_send_op.hpp | 147 + .../experimental/detail/channel_service.hpp | 679 +++ .../detail/coro_completion_handler.hpp | 169 + .../detail/coro_promise_allocator.hpp | 141 + .../experimental/detail/has_signature.hpp | 54 + .../detail/impl/channel_service.hpp | 623 +++ .../experimental/detail/partial_promise.hpp | 195 + include/asio/experimental/impl/as_single.hpp | 181 + .../asio/experimental/impl/channel_error.ipp | 61 + include/asio/experimental/impl/coro.hpp | 1222 +++++ .../asio/experimental/impl/parallel_group.hpp | 789 ++++ include/asio/experimental/impl/promise.hpp | 255 ++ include/asio/experimental/impl/use_coro.hpp | 214 + .../asio/experimental/impl/use_promise.hpp | 66 + include/asio/experimental/parallel_group.hpp | 455 ++ include/asio/experimental/promise.hpp | 224 + include/asio/experimental/use_coro.hpp | 189 + include/asio/experimental/use_promise.hpp | 111 + include/asio/file_base.hpp | 166 + include/asio/generic/basic_endpoint.hpp | 189 + include/asio/generic/datagram_protocol.hpp | 123 + include/asio/generic/detail/endpoint.hpp | 133 + include/asio/generic/detail/impl/endpoint.ipp | 110 + include/asio/generic/raw_protocol.hpp | 121 + include/asio/generic/seq_packet_protocol.hpp | 122 + include/asio/generic/stream_protocol.hpp | 127 + include/asio/handler_continuation_hook.hpp | 54 + include/asio/high_resolution_timer.hpp | 39 + include/asio/immediate.hpp | 142 + include/asio/impl/any_completion_executor.ipp | 126 + include/asio/impl/any_io_executor.ipp | 134 + include/asio/impl/append.hpp | 169 + include/asio/impl/as_tuple.hpp | 276 ++ include/asio/impl/awaitable.hpp | 1103 +++++ include/asio/impl/awaitable.ipp | 48 + include/asio/impl/buffered_read_stream.hpp | 404 ++ include/asio/impl/buffered_write_stream.hpp | 384 ++ include/asio/impl/cancel_after.hpp | 268 ++ include/asio/impl/cancel_at.hpp | 268 ++ include/asio/impl/cancellation_signal.ipp | 96 + include/asio/impl/co_spawn.hpp | 455 ++ include/asio/impl/config.hpp | 102 + include/asio/impl/config.ipp | 345 ++ include/asio/impl/connect.hpp | 645 +++ include/asio/impl/connect_pipe.hpp | 73 + include/asio/impl/connect_pipe.ipp | 150 + include/asio/impl/consign.hpp | 144 + include/asio/impl/deferred.hpp | 147 + include/asio/impl/detached.hpp | 77 + include/asio/impl/error.ipp | 128 + include/asio/impl/error_code.ipp | 207 + include/asio/impl/execution_context.hpp | 145 + include/asio/impl/execution_context.ipp | 120 + include/asio/impl/executor.hpp | 317 ++ include/asio/impl/executor.ipp | 43 + include/asio/impl/io_context.hpp | 343 ++ include/asio/impl/io_context.ipp | 127 + include/asio/impl/multiple_exceptions.ipp | 45 + include/asio/impl/prepend.hpp | 170 + include/asio/impl/read.hpp | 902 ++++ include/asio/impl/read_at.hpp | 562 +++ include/asio/impl/read_until.hpp | 2668 +++++++++++ include/asio/impl/redirect_error.hpp | 287 ++ include/asio/impl/serial_port_base.hpp | 59 + include/asio/impl/serial_port_base.ipp | 554 +++ include/asio/impl/spawn.hpp | 1115 +++++ include/asio/impl/src.hpp | 96 + include/asio/impl/system_context.hpp | 34 + include/asio/impl/system_context.ipp | 93 + include/asio/impl/system_executor.hpp | 179 + include/asio/impl/thread_pool.hpp | 319 ++ include/asio/impl/thread_pool.ipp | 145 + include/asio/impl/use_awaitable.hpp | 234 + include/asio/impl/use_future.hpp | 642 +++ include/asio/impl/write.hpp | 780 ++++ include/asio/impl/write_at.hpp | 480 ++ include/asio/io_context.hpp | 1321 ++++++ include/asio/io_context_strand.hpp | 294 ++ include/asio/ip/address.hpp | 255 ++ include/asio/ip/address_v4.hpp | 365 ++ include/asio/ip/address_v4_iterator.hpp | 156 + include/asio/ip/address_v4_range.hpp | 128 + include/asio/ip/address_v6.hpp | 366 ++ include/asio/ip/address_v6_iterator.hpp | 178 + include/asio/ip/address_v6_range.hpp | 124 + include/asio/ip/bad_address_cast.hpp | 63 + include/asio/ip/basic_endpoint.hpp | 282 ++ include/asio/ip/basic_resolver.hpp | 1016 +++++ include/asio/ip/basic_resolver_entry.hpp | 113 + include/asio/ip/basic_resolver_iterator.hpp | 188 + include/asio/ip/basic_resolver_query.hpp | 260 ++ include/asio/ip/basic_resolver_results.hpp | 303 ++ include/asio/ip/detail/endpoint.hpp | 145 + include/asio/ip/detail/impl/endpoint.ipp | 195 + include/asio/ip/detail/socket_option.hpp | 566 +++ include/asio/ip/host_name.hpp | 42 + include/asio/ip/icmp.hpp | 115 + include/asio/ip/impl/address.hpp | 39 + include/asio/ip/impl/address.ipp | 226 + include/asio/ip/impl/address_v4.hpp | 39 + include/asio/ip/impl/address_v4.ipp | 150 + include/asio/ip/impl/address_v6.hpp | 39 + include/asio/ip/impl/address_v6.ipp | 281 ++ include/asio/ip/impl/basic_endpoint.hpp | 43 + include/asio/ip/impl/host_name.ipp | 54 + include/asio/ip/impl/network_v4.hpp | 54 + include/asio/ip/impl/network_v4.ipp | 218 + include/asio/ip/impl/network_v6.hpp | 53 + include/asio/ip/impl/network_v6.ipp | 187 + include/asio/ip/multicast.hpp | 191 + include/asio/ip/network_v4.hpp | 257 ++ include/asio/ip/network_v6.hpp | 231 + include/asio/ip/resolver_base.hpp | 129 + include/asio/ip/resolver_query_base.hpp | 43 + include/asio/ip/tcp.hpp | 155 + include/asio/ip/udp.hpp | 111 + include/asio/ip/unicast.hpp | 70 + include/asio/ip/v6_only.hpp | 69 + include/asio/is_applicable_property.hpp | 61 + include/asio/is_contiguous_iterator.hpp | 45 + include/asio/is_executor.hpp | 46 + include/asio/is_read_buffered.hpp | 59 + include/asio/is_write_buffered.hpp | 59 + include/asio/local/basic_endpoint.hpp | 243 + include/asio/local/connect_pair.hpp | 101 + include/asio/local/datagram_protocol.hpp | 80 + include/asio/local/detail/endpoint.hpp | 139 + include/asio/local/detail/impl/endpoint.ipp | 131 + include/asio/local/seq_packet_protocol.hpp | 84 + include/asio/local/stream_protocol.hpp | 90 + include/asio/multiple_exceptions.hpp | 52 + include/asio/packaged_task.hpp | 66 + include/asio/placeholders.hpp | 81 + include/asio/posix/basic_descriptor.hpp | 773 ++++ .../asio/posix/basic_stream_descriptor.hpp | 559 +++ include/asio/posix/descriptor.hpp | 37 + include/asio/posix/descriptor_base.hpp | 90 + include/asio/posix/stream_descriptor.hpp | 37 + include/asio/post.hpp | 213 + include/asio/prefer.hpp | 577 +++ include/asio/prepend.hpp | 66 + include/asio/query.hpp | 311 ++ include/asio/random_access_file.hpp | 35 + include/asio/read.hpp | 1547 +++++++ include/asio/read_at.hpp | 828 ++++ include/asio/read_until.hpp | 3202 +++++++++++++ include/asio/readable_pipe.hpp | 35 + include/asio/recycling_allocator.hpp | 138 + include/asio/redirect_error.hpp | 104 + include/asio/registered_buffer.hpp | 344 ++ include/asio/require.hpp | 433 ++ include/asio/require_concept.hpp | 343 ++ include/asio/serial_port.hpp | 36 + include/asio/serial_port_base.hpp | 167 + include/asio/signal_set.hpp | 28 + include/asio/signal_set_base.hpp | 171 + include/asio/socket_base.hpp | 548 +++ include/asio/spawn.hpp | 690 +++ include/asio/ssl.hpp | 27 + include/asio/ssl/context.hpp | 762 ++++ include/asio/ssl/context_base.hpp | 209 + .../asio/ssl/detail/buffered_handshake_op.hpp | 119 + include/asio/ssl/detail/engine.hpp | 169 + include/asio/ssl/detail/handshake_op.hpp | 67 + include/asio/ssl/detail/impl/engine.ipp | 383 ++ include/asio/ssl/detail/impl/openssl_init.ipp | 169 + include/asio/ssl/detail/io.hpp | 376 ++ include/asio/ssl/detail/openssl_init.hpp | 101 + include/asio/ssl/detail/openssl_types.hpp | 34 + include/asio/ssl/detail/password_callback.hpp | 66 + include/asio/ssl/detail/read_op.hpp | 72 + include/asio/ssl/detail/shutdown_op.hpp | 69 + include/asio/ssl/detail/stream_core.hpp | 168 + include/asio/ssl/detail/verify_callback.hpp | 62 + include/asio/ssl/detail/write_op.hpp | 76 + include/asio/ssl/error.hpp | 123 + include/asio/ssl/host_name_verification.hpp | 90 + include/asio/ssl/impl/context.hpp | 67 + include/asio/ssl/impl/context.ipp | 1322 ++++++ include/asio/ssl/impl/error.ipp | 124 + .../asio/ssl/impl/host_name_verification.ipp | 73 + include/asio/ssl/impl/src.hpp | 28 + include/asio/ssl/stream.hpp | 1042 +++++ include/asio/ssl/stream_base.hpp | 52 + include/asio/ssl/verify_context.hpp | 67 + include/asio/ssl/verify_mode.hpp | 63 + include/asio/static_thread_pool.hpp | 31 + include/asio/steady_timer.hpp | 37 + include/asio/strand.hpp | 557 +++ include/asio/stream_file.hpp | 35 + include/asio/streambuf.hpp | 33 + include/asio/system_context.hpp | 90 + include/asio/system_error.hpp | 31 + include/asio/system_executor.hpp | 671 +++ include/asio/system_timer.hpp | 37 + include/asio/this_coro.hpp | 267 ++ include/asio/thread.hpp | 92 + include/asio/thread_pool.hpp | 1041 +++++ include/asio/time_traits.hpp | 90 + include/asio/traits/equality_comparable.hpp | 100 + include/asio/traits/execute_member.hpp | 104 + include/asio/traits/prefer_free.hpp | 104 + include/asio/traits/prefer_member.hpp | 104 + include/asio/traits/query_free.hpp | 104 + include/asio/traits/query_member.hpp | 104 + .../traits/query_static_constexpr_member.hpp | 101 + include/asio/traits/require_concept_free.hpp | 104 + .../asio/traits/require_concept_member.hpp | 104 + include/asio/traits/require_free.hpp | 104 + include/asio/traits/require_member.hpp | 104 + include/asio/traits/static_query.hpp | 102 + include/asio/traits/static_require.hpp | 115 + .../asio/traits/static_require_concept.hpp | 116 + include/asio/ts/buffer.hpp | 24 + include/asio/ts/executor.hpp | 35 + include/asio/ts/internet.hpp | 40 + include/asio/ts/io_context.hpp | 20 + include/asio/ts/net.hpp | 26 + include/asio/ts/netfwd.hpp | 213 + include/asio/ts/socket.hpp | 27 + include/asio/ts/timer.hpp | 26 + include/asio/unyield.hpp | 21 + include/asio/use_awaitable.hpp | 161 + include/asio/use_future.hpp | 150 + include/asio/uses_executor.hpp | 67 + include/asio/version.hpp | 23 + include/asio/wait_traits.hpp | 56 + include/asio/windows/basic_object_handle.hpp | 485 ++ .../asio/windows/basic_overlapped_handle.hpp | 455 ++ .../windows/basic_random_access_handle.hpp | 567 +++ include/asio/windows/basic_stream_handle.hpp | 551 +++ include/asio/windows/object_handle.hpp | 38 + include/asio/windows/overlapped_handle.hpp | 39 + include/asio/windows/overlapped_ptr.hpp | 145 + include/asio/windows/random_access_handle.hpp | 37 + include/asio/windows/stream_handle.hpp | 37 + include/asio/writable_pipe.hpp | 35 + include/asio/write.hpp | 1526 +++++++ include/asio/write_at.hpp | 841 ++++ include/asio/yield.hpp | 23 + .../columnlynx/client/net/tcp/tcp_client.hpp | 112 + .../columnlynx/common/libsodium_wrapper.hpp | 27 + .../columnlynx/common/net/tcp/net_helper.hpp | 19 + .../common/net/tcp/tcp_message_handler.hpp | 44 + .../common/net/tcp/tcp_message_type.hpp | 32 + include/columnlynx/common/panic_handler.hpp | 214 + include/columnlynx/common/utils.hpp | 25 + .../server/net/tcp/tcp_connection.hpp | 101 + .../columnlynx/server/net/tcp/tcp_server.hpp | 38 + src/client/main.cpp | 60 + src/common/libsodium_wrapper.cpp | 34 + src/common/tcp_message_handler.cpp | 103 + src/common/utils.cpp | 46 + src/server/main.cpp | 39 + src/server/server/net/tcp/tcp_server.cpp | 45 + third_party/asio/LICENSE_1_0.txt | 23 + 648 files changed, 170981 insertions(+) create mode 100644 .gitignore create mode 100644 ATTRIBUTIONS.md create mode 100644 CMakeLists.txt create mode 100644 LICENSE create mode 100644 README.md create mode 100644 include/asio/any_completion_executor.hpp create mode 100644 include/asio/any_completion_handler.hpp create mode 100644 include/asio/any_io_executor.hpp create mode 100644 include/asio/append.hpp create mode 100644 include/asio/as_tuple.hpp create mode 100644 include/asio/asio.hpp create mode 100644 include/asio/associated_allocator.hpp create mode 100644 include/asio/associated_cancellation_slot.hpp create mode 100644 include/asio/associated_executor.hpp create mode 100644 include/asio/associated_immediate_executor.hpp create mode 100644 include/asio/associator.hpp create mode 100644 include/asio/async_result.hpp create mode 100644 include/asio/awaitable.hpp create mode 100644 include/asio/basic_datagram_socket.hpp create mode 100644 include/asio/basic_deadline_timer.hpp create mode 100644 include/asio/basic_file.hpp create mode 100644 include/asio/basic_io_object.hpp create mode 100644 include/asio/basic_random_access_file.hpp create mode 100644 include/asio/basic_raw_socket.hpp create mode 100644 include/asio/basic_readable_pipe.hpp create mode 100644 include/asio/basic_seq_packet_socket.hpp create mode 100644 include/asio/basic_serial_port.hpp create mode 100644 include/asio/basic_signal_set.hpp create mode 100644 include/asio/basic_socket.hpp create mode 100644 include/asio/basic_socket_acceptor.hpp create mode 100644 include/asio/basic_socket_iostream.hpp create mode 100644 include/asio/basic_socket_streambuf.hpp create mode 100644 include/asio/basic_stream_file.hpp create mode 100644 include/asio/basic_stream_socket.hpp create mode 100644 include/asio/basic_streambuf.hpp create mode 100644 include/asio/basic_streambuf_fwd.hpp create mode 100644 include/asio/basic_waitable_timer.hpp create mode 100644 include/asio/basic_writable_pipe.hpp create mode 100644 include/asio/bind_allocator.hpp create mode 100644 include/asio/bind_cancellation_slot.hpp create mode 100644 include/asio/bind_executor.hpp create mode 100644 include/asio/bind_immediate_executor.hpp create mode 100644 include/asio/buffer.hpp create mode 100644 include/asio/buffer_registration.hpp create mode 100644 include/asio/buffered_read_stream.hpp create mode 100644 include/asio/buffered_read_stream_fwd.hpp create mode 100644 include/asio/buffered_stream.hpp create mode 100644 include/asio/buffered_stream_fwd.hpp create mode 100644 include/asio/buffered_write_stream.hpp create mode 100644 include/asio/buffered_write_stream_fwd.hpp create mode 100644 include/asio/buffers_iterator.hpp create mode 100644 include/asio/cancel_after.hpp create mode 100644 include/asio/cancel_at.hpp create mode 100644 include/asio/cancellation_signal.hpp create mode 100644 include/asio/cancellation_state.hpp create mode 100644 include/asio/cancellation_type.hpp create mode 100644 include/asio/co_composed.hpp create mode 100644 include/asio/co_spawn.hpp create mode 100644 include/asio/completion_condition.hpp create mode 100644 include/asio/compose.hpp create mode 100644 include/asio/composed.hpp create mode 100644 include/asio/config.hpp create mode 100644 include/asio/connect.hpp create mode 100644 include/asio/connect_pipe.hpp create mode 100644 include/asio/consign.hpp create mode 100644 include/asio/coroutine.hpp create mode 100644 include/asio/deadline_timer.hpp create mode 100644 include/asio/default_completion_token.hpp create mode 100644 include/asio/defer.hpp create mode 100644 include/asio/deferred.hpp create mode 100644 include/asio/detached.hpp create mode 100644 include/asio/detail/array.hpp create mode 100644 include/asio/detail/array_fwd.hpp create mode 100644 include/asio/detail/assert.hpp create mode 100644 include/asio/detail/atomic_count.hpp create mode 100644 include/asio/detail/base_from_cancellation_state.hpp create mode 100644 include/asio/detail/base_from_completion_cond.hpp create mode 100644 include/asio/detail/bind_handler.hpp create mode 100644 include/asio/detail/blocking_executor_op.hpp create mode 100644 include/asio/detail/buffer_resize_guard.hpp create mode 100644 include/asio/detail/buffer_sequence_adapter.hpp create mode 100644 include/asio/detail/buffered_stream_storage.hpp create mode 100644 include/asio/detail/call_stack.hpp create mode 100644 include/asio/detail/chrono.hpp create mode 100644 include/asio/detail/chrono_time_traits.hpp create mode 100644 include/asio/detail/completion_handler.hpp create mode 100644 include/asio/detail/completion_message.hpp create mode 100644 include/asio/detail/completion_payload.hpp create mode 100644 include/asio/detail/completion_payload_handler.hpp create mode 100644 include/asio/detail/composed_work.hpp create mode 100644 include/asio/detail/concurrency_hint.hpp create mode 100644 include/asio/detail/conditionally_enabled_event.hpp create mode 100644 include/asio/detail/conditionally_enabled_mutex.hpp create mode 100644 include/asio/detail/config.hpp create mode 100644 include/asio/detail/consuming_buffers.hpp create mode 100644 include/asio/detail/cstddef.hpp create mode 100644 include/asio/detail/cstdint.hpp create mode 100644 include/asio/detail/date_time_fwd.hpp create mode 100644 include/asio/detail/deadline_timer_service.hpp create mode 100644 include/asio/detail/dependent_type.hpp create mode 100644 include/asio/detail/descriptor_ops.hpp create mode 100644 include/asio/detail/descriptor_read_op.hpp create mode 100644 include/asio/detail/descriptor_write_op.hpp create mode 100644 include/asio/detail/dev_poll_reactor.hpp create mode 100644 include/asio/detail/epoll_reactor.hpp create mode 100644 include/asio/detail/event.hpp create mode 100644 include/asio/detail/eventfd_select_interrupter.hpp create mode 100644 include/asio/detail/exception.hpp create mode 100644 include/asio/detail/executor_function.hpp create mode 100644 include/asio/detail/executor_op.hpp create mode 100644 include/asio/detail/fd_set_adapter.hpp create mode 100644 include/asio/detail/fenced_block.hpp create mode 100644 include/asio/detail/functional.hpp create mode 100644 include/asio/detail/future.hpp create mode 100644 include/asio/detail/global.hpp create mode 100644 include/asio/detail/handler_alloc_helpers.hpp create mode 100644 include/asio/detail/handler_cont_helpers.hpp create mode 100644 include/asio/detail/handler_tracking.hpp create mode 100644 include/asio/detail/handler_type_requirements.hpp create mode 100644 include/asio/detail/handler_work.hpp create mode 100644 include/asio/detail/hash_map.hpp create mode 100644 include/asio/detail/impl/buffer_sequence_adapter.ipp create mode 100644 include/asio/detail/impl/descriptor_ops.ipp create mode 100644 include/asio/detail/impl/dev_poll_reactor.hpp create mode 100644 include/asio/detail/impl/dev_poll_reactor.ipp create mode 100644 include/asio/detail/impl/epoll_reactor.hpp create mode 100644 include/asio/detail/impl/epoll_reactor.ipp create mode 100644 include/asio/detail/impl/eventfd_select_interrupter.ipp create mode 100644 include/asio/detail/impl/handler_tracking.ipp create mode 100644 include/asio/detail/impl/io_uring_descriptor_service.ipp create mode 100644 include/asio/detail/impl/io_uring_file_service.ipp create mode 100644 include/asio/detail/impl/io_uring_service.hpp create mode 100644 include/asio/detail/impl/io_uring_service.ipp create mode 100644 include/asio/detail/impl/io_uring_socket_service_base.ipp create mode 100644 include/asio/detail/impl/kqueue_reactor.hpp create mode 100644 include/asio/detail/impl/kqueue_reactor.ipp create mode 100644 include/asio/detail/impl/null_event.ipp create mode 100644 include/asio/detail/impl/pipe_select_interrupter.ipp create mode 100644 include/asio/detail/impl/posix_event.ipp create mode 100644 include/asio/detail/impl/posix_mutex.ipp create mode 100644 include/asio/detail/impl/posix_serial_port_service.ipp create mode 100644 include/asio/detail/impl/posix_thread.ipp create mode 100644 include/asio/detail/impl/posix_tss_ptr.ipp create mode 100644 include/asio/detail/impl/reactive_descriptor_service.ipp create mode 100644 include/asio/detail/impl/reactive_socket_service_base.ipp create mode 100644 include/asio/detail/impl/resolver_service_base.ipp create mode 100644 include/asio/detail/impl/resolver_thread_pool.ipp create mode 100644 include/asio/detail/impl/scheduler.ipp create mode 100644 include/asio/detail/impl/select_reactor.hpp create mode 100644 include/asio/detail/impl/select_reactor.ipp create mode 100644 include/asio/detail/impl/service_registry.hpp create mode 100644 include/asio/detail/impl/service_registry.ipp create mode 100644 include/asio/detail/impl/signal_set_service.ipp create mode 100644 include/asio/detail/impl/socket_ops.ipp create mode 100644 include/asio/detail/impl/socket_select_interrupter.ipp create mode 100644 include/asio/detail/impl/strand_executor_service.hpp create mode 100644 include/asio/detail/impl/strand_executor_service.ipp create mode 100644 include/asio/detail/impl/strand_service.hpp create mode 100644 include/asio/detail/impl/strand_service.ipp create mode 100644 include/asio/detail/impl/thread_context.ipp create mode 100644 include/asio/detail/impl/throw_error.ipp create mode 100644 include/asio/detail/impl/timer_queue_set.ipp create mode 100644 include/asio/detail/impl/win_event.ipp create mode 100644 include/asio/detail/impl/win_iocp_file_service.ipp create mode 100644 include/asio/detail/impl/win_iocp_handle_service.ipp create mode 100644 include/asio/detail/impl/win_iocp_io_context.hpp create mode 100644 include/asio/detail/impl/win_iocp_io_context.ipp create mode 100644 include/asio/detail/impl/win_iocp_serial_port_service.ipp create mode 100644 include/asio/detail/impl/win_iocp_socket_service_base.ipp create mode 100644 include/asio/detail/impl/win_mutex.ipp create mode 100644 include/asio/detail/impl/win_object_handle_service.ipp create mode 100644 include/asio/detail/impl/win_static_mutex.ipp create mode 100644 include/asio/detail/impl/win_thread.ipp create mode 100644 include/asio/detail/impl/win_tss_ptr.ipp create mode 100644 include/asio/detail/impl/winrt_ssocket_service_base.ipp create mode 100644 include/asio/detail/impl/winrt_timer_scheduler.hpp create mode 100644 include/asio/detail/impl/winrt_timer_scheduler.ipp create mode 100644 include/asio/detail/impl/winsock_init.ipp create mode 100644 include/asio/detail/initiate_defer.hpp create mode 100644 include/asio/detail/initiate_dispatch.hpp create mode 100644 include/asio/detail/initiate_post.hpp create mode 100644 include/asio/detail/initiation_base.hpp create mode 100644 include/asio/detail/io_control.hpp create mode 100644 include/asio/detail/io_object_impl.hpp create mode 100644 include/asio/detail/io_uring_descriptor_read_at_op.hpp create mode 100644 include/asio/detail/io_uring_descriptor_read_op.hpp create mode 100644 include/asio/detail/io_uring_descriptor_service.hpp create mode 100644 include/asio/detail/io_uring_descriptor_write_at_op.hpp create mode 100644 include/asio/detail/io_uring_descriptor_write_op.hpp create mode 100644 include/asio/detail/io_uring_file_service.hpp create mode 100644 include/asio/detail/io_uring_null_buffers_op.hpp create mode 100644 include/asio/detail/io_uring_operation.hpp create mode 100644 include/asio/detail/io_uring_service.hpp create mode 100644 include/asio/detail/io_uring_socket_accept_op.hpp create mode 100644 include/asio/detail/io_uring_socket_connect_op.hpp create mode 100644 include/asio/detail/io_uring_socket_recv_op.hpp create mode 100644 include/asio/detail/io_uring_socket_recvfrom_op.hpp create mode 100644 include/asio/detail/io_uring_socket_recvmsg_op.hpp create mode 100644 include/asio/detail/io_uring_socket_send_op.hpp create mode 100644 include/asio/detail/io_uring_socket_sendto_op.hpp create mode 100644 include/asio/detail/io_uring_socket_service.hpp create mode 100644 include/asio/detail/io_uring_socket_service_base.hpp create mode 100644 include/asio/detail/io_uring_wait_op.hpp create mode 100644 include/asio/detail/is_buffer_sequence.hpp create mode 100644 include/asio/detail/is_executor.hpp create mode 100644 include/asio/detail/keyword_tss_ptr.hpp create mode 100644 include/asio/detail/kqueue_reactor.hpp create mode 100644 include/asio/detail/limits.hpp create mode 100644 include/asio/detail/local_free_on_block_exit.hpp create mode 100644 include/asio/detail/memory.hpp create mode 100644 include/asio/detail/mutex.hpp create mode 100644 include/asio/detail/non_const_lvalue.hpp create mode 100644 include/asio/detail/noncopyable.hpp create mode 100644 include/asio/detail/null_event.hpp create mode 100644 include/asio/detail/null_fenced_block.hpp create mode 100644 include/asio/detail/null_global.hpp create mode 100644 include/asio/detail/null_mutex.hpp create mode 100644 include/asio/detail/null_reactor.hpp create mode 100644 include/asio/detail/null_signal_blocker.hpp create mode 100644 include/asio/detail/null_socket_service.hpp create mode 100644 include/asio/detail/null_static_mutex.hpp create mode 100644 include/asio/detail/null_thread.hpp create mode 100644 include/asio/detail/null_tss_ptr.hpp create mode 100644 include/asio/detail/object_pool.hpp create mode 100644 include/asio/detail/old_win_sdk_compat.hpp create mode 100644 include/asio/detail/op_queue.hpp create mode 100644 include/asio/detail/operation.hpp create mode 100644 include/asio/detail/pipe_select_interrupter.hpp create mode 100644 include/asio/detail/pop_options.hpp create mode 100644 include/asio/detail/posix_event.hpp create mode 100644 include/asio/detail/posix_fd_set_adapter.hpp create mode 100644 include/asio/detail/posix_global.hpp create mode 100644 include/asio/detail/posix_mutex.hpp create mode 100644 include/asio/detail/posix_serial_port_service.hpp create mode 100644 include/asio/detail/posix_signal_blocker.hpp create mode 100644 include/asio/detail/posix_static_mutex.hpp create mode 100644 include/asio/detail/posix_thread.hpp create mode 100644 include/asio/detail/posix_tss_ptr.hpp create mode 100644 include/asio/detail/push_options.hpp create mode 100644 include/asio/detail/reactive_descriptor_service.hpp create mode 100644 include/asio/detail/reactive_null_buffers_op.hpp create mode 100644 include/asio/detail/reactive_socket_accept_op.hpp create mode 100644 include/asio/detail/reactive_socket_connect_op.hpp create mode 100644 include/asio/detail/reactive_socket_recv_op.hpp create mode 100644 include/asio/detail/reactive_socket_recvfrom_op.hpp create mode 100644 include/asio/detail/reactive_socket_recvmsg_op.hpp create mode 100644 include/asio/detail/reactive_socket_send_op.hpp create mode 100644 include/asio/detail/reactive_socket_sendto_op.hpp create mode 100644 include/asio/detail/reactive_socket_service.hpp create mode 100644 include/asio/detail/reactive_socket_service_base.hpp create mode 100644 include/asio/detail/reactive_wait_op.hpp create mode 100644 include/asio/detail/reactor.hpp create mode 100644 include/asio/detail/reactor_op.hpp create mode 100644 include/asio/detail/reactor_op_queue.hpp create mode 100644 include/asio/detail/recycling_allocator.hpp create mode 100644 include/asio/detail/regex_fwd.hpp create mode 100644 include/asio/detail/resolve_endpoint_op.hpp create mode 100644 include/asio/detail/resolve_op.hpp create mode 100644 include/asio/detail/resolve_query_op.hpp create mode 100644 include/asio/detail/resolver_service.hpp create mode 100644 include/asio/detail/resolver_service_base.hpp create mode 100644 include/asio/detail/resolver_thread_pool.hpp create mode 100644 include/asio/detail/scheduler.hpp create mode 100644 include/asio/detail/scheduler_operation.hpp create mode 100644 include/asio/detail/scheduler_task.hpp create mode 100644 include/asio/detail/scheduler_thread_info.hpp create mode 100644 include/asio/detail/scoped_lock.hpp create mode 100644 include/asio/detail/scoped_ptr.hpp create mode 100644 include/asio/detail/select_interrupter.hpp create mode 100644 include/asio/detail/select_reactor.hpp create mode 100644 include/asio/detail/service_registry.hpp create mode 100644 include/asio/detail/signal_blocker.hpp create mode 100644 include/asio/detail/signal_handler.hpp create mode 100644 include/asio/detail/signal_init.hpp create mode 100644 include/asio/detail/signal_op.hpp create mode 100644 include/asio/detail/signal_set_service.hpp create mode 100644 include/asio/detail/socket_holder.hpp create mode 100644 include/asio/detail/socket_ops.hpp create mode 100644 include/asio/detail/socket_option.hpp create mode 100644 include/asio/detail/socket_select_interrupter.hpp create mode 100644 include/asio/detail/socket_types.hpp create mode 100644 include/asio/detail/source_location.hpp create mode 100644 include/asio/detail/static_mutex.hpp create mode 100644 include/asio/detail/std_event.hpp create mode 100644 include/asio/detail/std_fenced_block.hpp create mode 100644 include/asio/detail/std_global.hpp create mode 100644 include/asio/detail/std_mutex.hpp create mode 100644 include/asio/detail/std_static_mutex.hpp create mode 100644 include/asio/detail/std_thread.hpp create mode 100644 include/asio/detail/strand_executor_service.hpp create mode 100644 include/asio/detail/strand_service.hpp create mode 100644 include/asio/detail/string_view.hpp create mode 100644 include/asio/detail/thread.hpp create mode 100644 include/asio/detail/thread_context.hpp create mode 100644 include/asio/detail/thread_group.hpp create mode 100644 include/asio/detail/thread_info_base.hpp create mode 100644 include/asio/detail/throw_error.hpp create mode 100644 include/asio/detail/throw_exception.hpp create mode 100644 include/asio/detail/timed_cancel_op.hpp create mode 100644 include/asio/detail/timer_queue.hpp create mode 100644 include/asio/detail/timer_queue_base.hpp create mode 100644 include/asio/detail/timer_queue_set.hpp create mode 100644 include/asio/detail/timer_scheduler.hpp create mode 100644 include/asio/detail/timer_scheduler_fwd.hpp create mode 100644 include/asio/detail/tss_ptr.hpp create mode 100644 include/asio/detail/type_traits.hpp create mode 100644 include/asio/detail/utility.hpp create mode 100644 include/asio/detail/wait_handler.hpp create mode 100644 include/asio/detail/wait_op.hpp create mode 100644 include/asio/detail/win_event.hpp create mode 100644 include/asio/detail/win_fd_set_adapter.hpp create mode 100644 include/asio/detail/win_global.hpp create mode 100644 include/asio/detail/win_iocp_file_service.hpp create mode 100644 include/asio/detail/win_iocp_handle_read_op.hpp create mode 100644 include/asio/detail/win_iocp_handle_service.hpp create mode 100644 include/asio/detail/win_iocp_handle_write_op.hpp create mode 100644 include/asio/detail/win_iocp_io_context.hpp create mode 100644 include/asio/detail/win_iocp_null_buffers_op.hpp create mode 100644 include/asio/detail/win_iocp_operation.hpp create mode 100644 include/asio/detail/win_iocp_overlapped_op.hpp create mode 100644 include/asio/detail/win_iocp_overlapped_ptr.hpp create mode 100644 include/asio/detail/win_iocp_serial_port_service.hpp create mode 100644 include/asio/detail/win_iocp_socket_accept_op.hpp create mode 100644 include/asio/detail/win_iocp_socket_connect_op.hpp create mode 100644 include/asio/detail/win_iocp_socket_recv_op.hpp create mode 100644 include/asio/detail/win_iocp_socket_recvfrom_op.hpp create mode 100644 include/asio/detail/win_iocp_socket_recvmsg_op.hpp create mode 100644 include/asio/detail/win_iocp_socket_send_op.hpp create mode 100644 include/asio/detail/win_iocp_socket_service.hpp create mode 100644 include/asio/detail/win_iocp_socket_service_base.hpp create mode 100644 include/asio/detail/win_iocp_thread_info.hpp create mode 100644 include/asio/detail/win_iocp_wait_op.hpp create mode 100644 include/asio/detail/win_mutex.hpp create mode 100644 include/asio/detail/win_object_handle_service.hpp create mode 100644 include/asio/detail/win_static_mutex.hpp create mode 100644 include/asio/detail/win_thread.hpp create mode 100644 include/asio/detail/win_tss_ptr.hpp create mode 100644 include/asio/detail/winapp_thread.hpp create mode 100644 include/asio/detail/wince_thread.hpp create mode 100644 include/asio/detail/winrt_async_manager.hpp create mode 100644 include/asio/detail/winrt_async_op.hpp create mode 100644 include/asio/detail/winrt_resolve_op.hpp create mode 100644 include/asio/detail/winrt_resolver_service.hpp create mode 100644 include/asio/detail/winrt_socket_connect_op.hpp create mode 100644 include/asio/detail/winrt_socket_recv_op.hpp create mode 100644 include/asio/detail/winrt_socket_send_op.hpp create mode 100644 include/asio/detail/winrt_ssocket_service.hpp create mode 100644 include/asio/detail/winrt_ssocket_service_base.hpp create mode 100644 include/asio/detail/winrt_timer_scheduler.hpp create mode 100644 include/asio/detail/winrt_utils.hpp create mode 100644 include/asio/detail/winsock_init.hpp create mode 100644 include/asio/detail/work_dispatcher.hpp create mode 100644 include/asio/detail/wrapped_handler.hpp create mode 100644 include/asio/dispatch.hpp create mode 100644 include/asio/disposition.hpp create mode 100644 include/asio/error.hpp create mode 100644 include/asio/error_code.hpp create mode 100644 include/asio/execution.hpp create mode 100644 include/asio/execution/allocator.hpp create mode 100644 include/asio/execution/any_executor.hpp create mode 100644 include/asio/execution/bad_executor.hpp create mode 100644 include/asio/execution/blocking.hpp create mode 100644 include/asio/execution/blocking_adaptation.hpp create mode 100644 include/asio/execution/context.hpp create mode 100644 include/asio/execution/context_as.hpp create mode 100644 include/asio/execution/executor.hpp create mode 100644 include/asio/execution/impl/bad_executor.ipp create mode 100644 include/asio/execution/invocable_archetype.hpp create mode 100644 include/asio/execution/mapping.hpp create mode 100644 include/asio/execution/occupancy.hpp create mode 100644 include/asio/execution/outstanding_work.hpp create mode 100644 include/asio/execution/prefer_only.hpp create mode 100644 include/asio/execution/relationship.hpp create mode 100644 include/asio/execution_context.hpp create mode 100644 include/asio/executor.hpp create mode 100644 include/asio/executor_work_guard.hpp create mode 100644 include/asio/experimental/as_single.hpp create mode 100644 include/asio/experimental/awaitable_operators.hpp create mode 100644 include/asio/experimental/basic_channel.hpp create mode 100644 include/asio/experimental/basic_concurrent_channel.hpp create mode 100644 include/asio/experimental/cancellation_condition.hpp create mode 100644 include/asio/experimental/channel.hpp create mode 100644 include/asio/experimental/channel_error.hpp create mode 100644 include/asio/experimental/channel_traits.hpp create mode 100644 include/asio/experimental/co_composed.hpp create mode 100644 include/asio/experimental/co_spawn.hpp create mode 100644 include/asio/experimental/concurrent_channel.hpp create mode 100644 include/asio/experimental/coro.hpp create mode 100644 include/asio/experimental/coro_traits.hpp create mode 100644 include/asio/experimental/detail/channel_operation.hpp create mode 100644 include/asio/experimental/detail/channel_receive_op.hpp create mode 100644 include/asio/experimental/detail/channel_send_functions.hpp create mode 100644 include/asio/experimental/detail/channel_send_op.hpp create mode 100644 include/asio/experimental/detail/channel_service.hpp create mode 100644 include/asio/experimental/detail/coro_completion_handler.hpp create mode 100644 include/asio/experimental/detail/coro_promise_allocator.hpp create mode 100644 include/asio/experimental/detail/has_signature.hpp create mode 100644 include/asio/experimental/detail/impl/channel_service.hpp create mode 100644 include/asio/experimental/detail/partial_promise.hpp create mode 100644 include/asio/experimental/impl/as_single.hpp create mode 100644 include/asio/experimental/impl/channel_error.ipp create mode 100644 include/asio/experimental/impl/coro.hpp create mode 100644 include/asio/experimental/impl/parallel_group.hpp create mode 100644 include/asio/experimental/impl/promise.hpp create mode 100644 include/asio/experimental/impl/use_coro.hpp create mode 100644 include/asio/experimental/impl/use_promise.hpp create mode 100644 include/asio/experimental/parallel_group.hpp create mode 100644 include/asio/experimental/promise.hpp create mode 100644 include/asio/experimental/use_coro.hpp create mode 100644 include/asio/experimental/use_promise.hpp create mode 100644 include/asio/file_base.hpp create mode 100644 include/asio/generic/basic_endpoint.hpp create mode 100644 include/asio/generic/datagram_protocol.hpp create mode 100644 include/asio/generic/detail/endpoint.hpp create mode 100644 include/asio/generic/detail/impl/endpoint.ipp create mode 100644 include/asio/generic/raw_protocol.hpp create mode 100644 include/asio/generic/seq_packet_protocol.hpp create mode 100644 include/asio/generic/stream_protocol.hpp create mode 100644 include/asio/handler_continuation_hook.hpp create mode 100644 include/asio/high_resolution_timer.hpp create mode 100644 include/asio/immediate.hpp create mode 100644 include/asio/impl/any_completion_executor.ipp create mode 100644 include/asio/impl/any_io_executor.ipp create mode 100644 include/asio/impl/append.hpp create mode 100644 include/asio/impl/as_tuple.hpp create mode 100644 include/asio/impl/awaitable.hpp create mode 100644 include/asio/impl/awaitable.ipp create mode 100644 include/asio/impl/buffered_read_stream.hpp create mode 100644 include/asio/impl/buffered_write_stream.hpp create mode 100644 include/asio/impl/cancel_after.hpp create mode 100644 include/asio/impl/cancel_at.hpp create mode 100644 include/asio/impl/cancellation_signal.ipp create mode 100644 include/asio/impl/co_spawn.hpp create mode 100644 include/asio/impl/config.hpp create mode 100644 include/asio/impl/config.ipp create mode 100644 include/asio/impl/connect.hpp create mode 100644 include/asio/impl/connect_pipe.hpp create mode 100644 include/asio/impl/connect_pipe.ipp create mode 100644 include/asio/impl/consign.hpp create mode 100644 include/asio/impl/deferred.hpp create mode 100644 include/asio/impl/detached.hpp create mode 100644 include/asio/impl/error.ipp create mode 100644 include/asio/impl/error_code.ipp create mode 100644 include/asio/impl/execution_context.hpp create mode 100644 include/asio/impl/execution_context.ipp create mode 100644 include/asio/impl/executor.hpp create mode 100644 include/asio/impl/executor.ipp create mode 100644 include/asio/impl/io_context.hpp create mode 100644 include/asio/impl/io_context.ipp create mode 100644 include/asio/impl/multiple_exceptions.ipp create mode 100644 include/asio/impl/prepend.hpp create mode 100644 include/asio/impl/read.hpp create mode 100644 include/asio/impl/read_at.hpp create mode 100644 include/asio/impl/read_until.hpp create mode 100644 include/asio/impl/redirect_error.hpp create mode 100644 include/asio/impl/serial_port_base.hpp create mode 100644 include/asio/impl/serial_port_base.ipp create mode 100644 include/asio/impl/spawn.hpp create mode 100644 include/asio/impl/src.hpp create mode 100644 include/asio/impl/system_context.hpp create mode 100644 include/asio/impl/system_context.ipp create mode 100644 include/asio/impl/system_executor.hpp create mode 100644 include/asio/impl/thread_pool.hpp create mode 100644 include/asio/impl/thread_pool.ipp create mode 100644 include/asio/impl/use_awaitable.hpp create mode 100644 include/asio/impl/use_future.hpp create mode 100644 include/asio/impl/write.hpp create mode 100644 include/asio/impl/write_at.hpp create mode 100644 include/asio/io_context.hpp create mode 100644 include/asio/io_context_strand.hpp create mode 100644 include/asio/ip/address.hpp create mode 100644 include/asio/ip/address_v4.hpp create mode 100644 include/asio/ip/address_v4_iterator.hpp create mode 100644 include/asio/ip/address_v4_range.hpp create mode 100644 include/asio/ip/address_v6.hpp create mode 100644 include/asio/ip/address_v6_iterator.hpp create mode 100644 include/asio/ip/address_v6_range.hpp create mode 100644 include/asio/ip/bad_address_cast.hpp create mode 100644 include/asio/ip/basic_endpoint.hpp create mode 100644 include/asio/ip/basic_resolver.hpp create mode 100644 include/asio/ip/basic_resolver_entry.hpp create mode 100644 include/asio/ip/basic_resolver_iterator.hpp create mode 100644 include/asio/ip/basic_resolver_query.hpp create mode 100644 include/asio/ip/basic_resolver_results.hpp create mode 100644 include/asio/ip/detail/endpoint.hpp create mode 100644 include/asio/ip/detail/impl/endpoint.ipp create mode 100644 include/asio/ip/detail/socket_option.hpp create mode 100644 include/asio/ip/host_name.hpp create mode 100644 include/asio/ip/icmp.hpp create mode 100644 include/asio/ip/impl/address.hpp create mode 100644 include/asio/ip/impl/address.ipp create mode 100644 include/asio/ip/impl/address_v4.hpp create mode 100644 include/asio/ip/impl/address_v4.ipp create mode 100644 include/asio/ip/impl/address_v6.hpp create mode 100644 include/asio/ip/impl/address_v6.ipp create mode 100644 include/asio/ip/impl/basic_endpoint.hpp create mode 100644 include/asio/ip/impl/host_name.ipp create mode 100644 include/asio/ip/impl/network_v4.hpp create mode 100644 include/asio/ip/impl/network_v4.ipp create mode 100644 include/asio/ip/impl/network_v6.hpp create mode 100644 include/asio/ip/impl/network_v6.ipp create mode 100644 include/asio/ip/multicast.hpp create mode 100644 include/asio/ip/network_v4.hpp create mode 100644 include/asio/ip/network_v6.hpp create mode 100644 include/asio/ip/resolver_base.hpp create mode 100644 include/asio/ip/resolver_query_base.hpp create mode 100644 include/asio/ip/tcp.hpp create mode 100644 include/asio/ip/udp.hpp create mode 100644 include/asio/ip/unicast.hpp create mode 100644 include/asio/ip/v6_only.hpp create mode 100644 include/asio/is_applicable_property.hpp create mode 100644 include/asio/is_contiguous_iterator.hpp create mode 100644 include/asio/is_executor.hpp create mode 100644 include/asio/is_read_buffered.hpp create mode 100644 include/asio/is_write_buffered.hpp create mode 100644 include/asio/local/basic_endpoint.hpp create mode 100644 include/asio/local/connect_pair.hpp create mode 100644 include/asio/local/datagram_protocol.hpp create mode 100644 include/asio/local/detail/endpoint.hpp create mode 100644 include/asio/local/detail/impl/endpoint.ipp create mode 100644 include/asio/local/seq_packet_protocol.hpp create mode 100644 include/asio/local/stream_protocol.hpp create mode 100644 include/asio/multiple_exceptions.hpp create mode 100644 include/asio/packaged_task.hpp create mode 100644 include/asio/placeholders.hpp create mode 100644 include/asio/posix/basic_descriptor.hpp create mode 100644 include/asio/posix/basic_stream_descriptor.hpp create mode 100644 include/asio/posix/descriptor.hpp create mode 100644 include/asio/posix/descriptor_base.hpp create mode 100644 include/asio/posix/stream_descriptor.hpp create mode 100644 include/asio/post.hpp create mode 100644 include/asio/prefer.hpp create mode 100644 include/asio/prepend.hpp create mode 100644 include/asio/query.hpp create mode 100644 include/asio/random_access_file.hpp create mode 100644 include/asio/read.hpp create mode 100644 include/asio/read_at.hpp create mode 100644 include/asio/read_until.hpp create mode 100644 include/asio/readable_pipe.hpp create mode 100644 include/asio/recycling_allocator.hpp create mode 100644 include/asio/redirect_error.hpp create mode 100644 include/asio/registered_buffer.hpp create mode 100644 include/asio/require.hpp create mode 100644 include/asio/require_concept.hpp create mode 100644 include/asio/serial_port.hpp create mode 100644 include/asio/serial_port_base.hpp create mode 100644 include/asio/signal_set.hpp create mode 100644 include/asio/signal_set_base.hpp create mode 100644 include/asio/socket_base.hpp create mode 100644 include/asio/spawn.hpp create mode 100644 include/asio/ssl.hpp create mode 100644 include/asio/ssl/context.hpp create mode 100644 include/asio/ssl/context_base.hpp create mode 100644 include/asio/ssl/detail/buffered_handshake_op.hpp create mode 100644 include/asio/ssl/detail/engine.hpp create mode 100644 include/asio/ssl/detail/handshake_op.hpp create mode 100644 include/asio/ssl/detail/impl/engine.ipp create mode 100644 include/asio/ssl/detail/impl/openssl_init.ipp create mode 100644 include/asio/ssl/detail/io.hpp create mode 100644 include/asio/ssl/detail/openssl_init.hpp create mode 100644 include/asio/ssl/detail/openssl_types.hpp create mode 100644 include/asio/ssl/detail/password_callback.hpp create mode 100644 include/asio/ssl/detail/read_op.hpp create mode 100644 include/asio/ssl/detail/shutdown_op.hpp create mode 100644 include/asio/ssl/detail/stream_core.hpp create mode 100644 include/asio/ssl/detail/verify_callback.hpp create mode 100644 include/asio/ssl/detail/write_op.hpp create mode 100644 include/asio/ssl/error.hpp create mode 100644 include/asio/ssl/host_name_verification.hpp create mode 100644 include/asio/ssl/impl/context.hpp create mode 100644 include/asio/ssl/impl/context.ipp create mode 100644 include/asio/ssl/impl/error.ipp create mode 100644 include/asio/ssl/impl/host_name_verification.ipp create mode 100644 include/asio/ssl/impl/src.hpp create mode 100644 include/asio/ssl/stream.hpp create mode 100644 include/asio/ssl/stream_base.hpp create mode 100644 include/asio/ssl/verify_context.hpp create mode 100644 include/asio/ssl/verify_mode.hpp create mode 100644 include/asio/static_thread_pool.hpp create mode 100644 include/asio/steady_timer.hpp create mode 100644 include/asio/strand.hpp create mode 100644 include/asio/stream_file.hpp create mode 100644 include/asio/streambuf.hpp create mode 100644 include/asio/system_context.hpp create mode 100644 include/asio/system_error.hpp create mode 100644 include/asio/system_executor.hpp create mode 100644 include/asio/system_timer.hpp create mode 100644 include/asio/this_coro.hpp create mode 100644 include/asio/thread.hpp create mode 100644 include/asio/thread_pool.hpp create mode 100644 include/asio/time_traits.hpp create mode 100644 include/asio/traits/equality_comparable.hpp create mode 100644 include/asio/traits/execute_member.hpp create mode 100644 include/asio/traits/prefer_free.hpp create mode 100644 include/asio/traits/prefer_member.hpp create mode 100644 include/asio/traits/query_free.hpp create mode 100644 include/asio/traits/query_member.hpp create mode 100644 include/asio/traits/query_static_constexpr_member.hpp create mode 100644 include/asio/traits/require_concept_free.hpp create mode 100644 include/asio/traits/require_concept_member.hpp create mode 100644 include/asio/traits/require_free.hpp create mode 100644 include/asio/traits/require_member.hpp create mode 100644 include/asio/traits/static_query.hpp create mode 100644 include/asio/traits/static_require.hpp create mode 100644 include/asio/traits/static_require_concept.hpp create mode 100644 include/asio/ts/buffer.hpp create mode 100644 include/asio/ts/executor.hpp create mode 100644 include/asio/ts/internet.hpp create mode 100644 include/asio/ts/io_context.hpp create mode 100644 include/asio/ts/net.hpp create mode 100644 include/asio/ts/netfwd.hpp create mode 100644 include/asio/ts/socket.hpp create mode 100644 include/asio/ts/timer.hpp create mode 100644 include/asio/unyield.hpp create mode 100644 include/asio/use_awaitable.hpp create mode 100644 include/asio/use_future.hpp create mode 100644 include/asio/uses_executor.hpp create mode 100644 include/asio/version.hpp create mode 100644 include/asio/wait_traits.hpp create mode 100644 include/asio/windows/basic_object_handle.hpp create mode 100644 include/asio/windows/basic_overlapped_handle.hpp create mode 100644 include/asio/windows/basic_random_access_handle.hpp create mode 100644 include/asio/windows/basic_stream_handle.hpp create mode 100644 include/asio/windows/object_handle.hpp create mode 100644 include/asio/windows/overlapped_handle.hpp create mode 100644 include/asio/windows/overlapped_ptr.hpp create mode 100644 include/asio/windows/random_access_handle.hpp create mode 100644 include/asio/windows/stream_handle.hpp create mode 100644 include/asio/writable_pipe.hpp create mode 100644 include/asio/write.hpp create mode 100644 include/asio/write_at.hpp create mode 100644 include/asio/yield.hpp create mode 100644 include/columnlynx/client/net/tcp/tcp_client.hpp create mode 100644 include/columnlynx/common/libsodium_wrapper.hpp create mode 100644 include/columnlynx/common/net/tcp/net_helper.hpp create mode 100644 include/columnlynx/common/net/tcp/tcp_message_handler.hpp create mode 100644 include/columnlynx/common/net/tcp/tcp_message_type.hpp create mode 100644 include/columnlynx/common/panic_handler.hpp create mode 100644 include/columnlynx/common/utils.hpp create mode 100644 include/columnlynx/server/net/tcp/tcp_connection.hpp create mode 100644 include/columnlynx/server/net/tcp/tcp_server.hpp create mode 100644 src/client/main.cpp create mode 100644 src/common/libsodium_wrapper.cpp create mode 100644 src/common/tcp_message_handler.cpp create mode 100644 src/common/utils.cpp create mode 100644 src/server/main.cpp create mode 100644 src/server/server/net/tcp/tcp_server.cpp create mode 100644 third_party/asio/LICENSE_1_0.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da5e8e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps +CMakeUserPresets.json + +build/ +.vscode/ \ No newline at end of file diff --git a/ATTRIBUTIONS.md b/ATTRIBUTIONS.md new file mode 100644 index 0000000..0c3ce1e --- /dev/null +++ b/ATTRIBUTIONS.md @@ -0,0 +1,10 @@ +# Third-Party Attributions + +## ASIO C++ Library +- **Name:** ASIO (standalone) +- **Website:** https://think-async.com/Asio/ +- **Copyright:** (c) 2003-2024 Christopher M. Kohlhoff +- **License:** Boost Software License, Version 1.0 +- **License Text:** See `third_party/asio/LICENSE_1_0.txt` + +This project uses the standalone version of the ASIO C++ library for asynchronous networking. \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e64b48b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,103 @@ +cmake_minimum_required(VERSION 3.16) + +# Version structure: +# MAJOR.MINOR.PATCH +# If MAJOR is 0, and MINOR is 0, Version is ALPHA +# If MAJOR is 0, and MINOR > 0, Version is BETA + +project(ColumnLynx + VERSION 0.0.1 + LANGUAGES CXX +) + +# --------------------------------------------------------- +# General C++ setup +# --------------------------------------------------------- +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +include(FetchContent) + +FetchContent_Declare( + Sodium + GIT_REPOSITORY https://github.com/robinlinden/libsodium-cmake.git + GIT_TAG e5b985ad0dd235d8c4307ea3a385b45e76c74c6a # Last updated at 2025-04-13 +) + +set(SODIUM_DISABLE_TESTS ON CACHE BOOL "" FORCE) +set(SODIUM_STATIC ON CACHE BOOL "" FORCE) + +FetchContent_MakeAvailable(Sodium) + +# --------------------------------------------------------- +# macOS: Build universal (ARM + x86_64) +# --------------------------------------------------------- +if(APPLE) + set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "Build architectures" FORCE) +endif() + +# --------------------------------------------------------- +# Platform-specific options +# --------------------------------------------------------- +if(WIN32) + add_compile_definitions(_WIN32_WINNT=0x0A00 NOMINMAX WIN32_LEAN_AND_MEAN) +elseif(UNIX) + add_compile_options(-Wall -Wextra -Wpedantic -std=c++20) + add_link_options(-pthread) +endif() + +# --------------------------------------------------------- +# Output directories +# --------------------------------------------------------- +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + +foreach(OUTPUTCONFIG DEBUG RELEASE RELWITHDEBINFO MINSIZEREL) + string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG_UPPER) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG_UPPER} ${CMAKE_BINARY_DIR}/bin) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG_UPPER} ${CMAKE_BINARY_DIR}/lib) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG_UPPER} ${CMAKE_BINARY_DIR}/lib) +endforeach() + +# --------------------------------------------------------- +# Common static library (shared code) +# --------------------------------------------------------- +file(GLOB_RECURSE COMMON_SRC CONFIGURE_DEPENDS src/common/*.cpp) +add_library(common STATIC ${COMMON_SRC}) +target_link_libraries(common PUBLIC sodium) +target_include_directories(common PUBLIC + ${PROJECT_SOURCE_DIR}/include + ${sodium_SOURCE_DIR}/src/libsodium/include + ${sodium_BINARY_DIR}/src/libsodium/include +) +target_compile_definitions(common PUBLIC ASIO_STANDALONE) + +# --------------------------------------------------------- +# Client executable +# --------------------------------------------------------- +file(GLOB_RECURSE CLIENT_SRC CONFIGURE_DEPENDS src/client/*.cpp) +add_executable(client ${CLIENT_SRC}) +target_link_libraries(client PRIVATE common sodium) +target_include_directories(client PRIVATE + ${PROJECT_SOURCE_DIR}/include + ${sodium_SOURCE_DIR}/src/libsodium/include + ${sodium_BINARY_DIR}/src/libsodium/include +) +target_compile_definitions(client PRIVATE ASIO_STANDALONE) +set_target_properties(client PROPERTIES OUTPUT_NAME "columnlynx_client") + +# --------------------------------------------------------- +# Server executable +# --------------------------------------------------------- +file(GLOB_RECURSE SERVER_SRC CONFIGURE_DEPENDS src/server/*.cpp) +add_executable(server ${SERVER_SRC}) +target_link_libraries(server PRIVATE common sodium) +target_include_directories(server PRIVATE + ${PROJECT_SOURCE_DIR}/include + ${sodium_SOURCE_DIR}/src/libsodium/include + ${sodium_BINARY_DIR}/src/libsodium/include +) +target_compile_definitions(server PRIVATE ASIO_STANDALONE) +set_target_properties(server PROPERTIES OUTPUT_NAME "columnlynx_server") \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3d408d0 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# ColumnLynx + +ColumnLynx is a VPN protocol designed to be as lightweight as possible. + +## How does it work + +ColumnLynx makes use of both **TCP** and **UDP**. **TCP** is used for the initial handshake and commands, which **UDP** is used for actual packet transmission. + +It operates on port **48042** for both TCP and UDP. + +## Packet Structure + +### TCP Packets + +TCP Packets generally follow the structure **Packet ID + Data** + +#### Packet ID + +The **Packet ID** is an **8 bit unsigned integer** that is predefined from either the **Client to Server** or **Server to Client** enum set, however they are uniquely numbered as to not collide with each other. + +**Server to Client** IDs are always below **0xA0** (exclusive) and **Client to Server** IDs are always above **0xA0** (exclusive). **0xFE** and **OxFF** are shared for **GRACEFUL_DISCONNECT** and **KILL_CONNECTION** respectively. + + +#### Data + +The data section is unspecified. It may change depending on the **Packet ID**. It is encoded as a **raw byte array** + +### UDP Packets + +*WIP, fill in later* + +## Legal + +Copyright (C) 2025 Jonas Korene Novak + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +DcruBro is the online pseudonym of Jonas Korene Novak. Both refer to the same individual and may be used interchangeably for copyright attribution purposes. + +### Licensing + +This project includes the [ASIO C++ Library](https://think-async.com/Asio/), +distributed under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt). \ No newline at end of file diff --git a/include/asio/any_completion_executor.hpp b/include/asio/any_completion_executor.hpp new file mode 100644 index 0000000..c270b8d --- /dev/null +++ b/include/asio/any_completion_executor.hpp @@ -0,0 +1,336 @@ +// +// any_completion_executor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the 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_COMPLETION_EXECUTOR_HPP +#define ASIO_ANY_COMPLETION_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" +#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_completion_executor; + +#else // defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) + +/// Polymorphic executor type for use with I/O objects. +/** + * The @c any_completion_executor type is a polymorphic executor that supports + * the set of properties required for the execution of completion handlers. It + * is defined as the execution::any_executor class template parameterised as + * follows: + * @code execution::any_executor< + * execution::prefer_only, + * execution::prefer_only + * execution::prefer_only, + * execution::prefer_only + * > @endcode + */ +class any_completion_executor : +#if defined(GENERATING_DOCUMENTATION) + public execution::any_executor<...> +#else // defined(GENERATING_DOCUMENTATION) + public execution::any_executor< + 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::prefer_only, + execution::prefer_only, + execution::prefer_only, + execution::prefer_only + > base_type; + + typedef void supportable_properties_type( + execution::prefer_only, + execution::prefer_only, + execution::prefer_only, + execution::prefer_only + ); +#endif // !defined(GENERATING_DOCUMENTATION) + + /// Default constructor. + ASIO_DECL any_completion_executor() noexcept; + + /// Construct in an empty state. Equivalent effects to default constructor. + ASIO_DECL any_completion_executor(nullptr_t) noexcept; + + /// Copy constructor. + ASIO_DECL any_completion_executor( + const any_completion_executor& e) noexcept; + + /// Move constructor. + ASIO_DECL any_completion_executor( + any_completion_executor&& e) noexcept; + + /// Construct to point to the same target as another any_executor. +#if defined(GENERATING_DOCUMENTATION) + template + any_completion_executor( + execution::any_executor e); +#else // defined(GENERATING_DOCUMENTATION) + template + any_completion_executor(OtherAnyExecutor e, + constraint_t< + 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 + > = 0) + : base_type(static_cast(e)) + { + } +#endif // defined(GENERATING_DOCUMENTATION) + + /// Construct to point to the same target as another any_executor. +#if defined(GENERATING_DOCUMENTATION) + template + any_completion_executor(std::nothrow_t, + execution::any_executor e); +#else // defined(GENERATING_DOCUMENTATION) + template + any_completion_executor(std::nothrow_t, OtherAnyExecutor e, + constraint_t< + 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 + > = 0) noexcept + : base_type(std::nothrow, static_cast(e)) + { + } +#endif // defined(GENERATING_DOCUMENTATION) + + /// Construct to point to the same target as another any_executor. + ASIO_DECL any_completion_executor(std::nothrow_t, + const any_completion_executor& e) noexcept; + + /// Construct to point to the same target as another any_executor. + ASIO_DECL any_completion_executor(std::nothrow_t, + any_completion_executor&& e) noexcept; + + /// Construct a polymorphic wrapper for the specified executor. +#if defined(GENERATING_DOCUMENTATION) + template + any_completion_executor(Executor e); +#else // defined(GENERATING_DOCUMENTATION) + template + any_completion_executor(Executor e, + constraint_t< + conditional< + !is_same::value + && !is_base_of::value, + execution::detail::is_valid_target_executor< + Executor, supportable_properties_type>, + false_type + >::type::value + > = 0) + : base_type(static_cast(e)) + { + } +#endif // defined(GENERATING_DOCUMENTATION) + + /// Construct a polymorphic wrapper for the specified executor. +#if defined(GENERATING_DOCUMENTATION) + template + any_completion_executor(std::nothrow_t, Executor e); +#else // defined(GENERATING_DOCUMENTATION) + template + any_completion_executor(std::nothrow_t, Executor e, + constraint_t< + conditional< + !is_same::value + && !is_base_of::value, + execution::detail::is_valid_target_executor< + Executor, supportable_properties_type>, + false_type + >::type::value + > = 0) noexcept + : base_type(std::nothrow, static_cast(e)) + { + } +#endif // defined(GENERATING_DOCUMENTATION) + + /// Assignment operator. + ASIO_DECL any_completion_executor& operator=( + const any_completion_executor& e) noexcept; + + /// Move assignment operator. + ASIO_DECL any_completion_executor& operator=( + any_completion_executor&& e) noexcept; + + /// Assignment operator that sets the polymorphic wrapper to the empty state. + ASIO_DECL any_completion_executor& operator=(nullptr_t); + + /// Destructor. + ASIO_DECL ~any_completion_executor(); + + /// Swap targets with another polymorphic wrapper. + ASIO_DECL void swap(any_completion_executor& other) 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_completion_executor ex = ...; + * auto ex2 = asio::require(ex, execution::relationship.fork); @endcode + */ + template + any_completion_executor require(const Property& p, + constraint_t< + traits::require_member::is_valid + > = 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_completion_executor ex = ...; + * auto ex2 = asio::prefer(ex, execution::relationship.fork); @endcode + */ + template + any_completion_executor prefer(const Property& p, + constraint_t< + traits::prefer_member::is_valid + > = 0) const + { + return static_cast(*this).prefer(p); + } +}; + +#if !defined(GENERATING_DOCUMENTATION) + +template <> +ASIO_DECL any_completion_executor any_completion_executor::prefer( + const execution::outstanding_work_t::tracked_t&, int) const; + +template <> +ASIO_DECL any_completion_executor any_completion_executor::prefer( + const execution::outstanding_work_t::untracked_t&, int) const; + +template <> +ASIO_DECL any_completion_executor any_completion_executor::prefer( + const execution::relationship_t::fork_t&, int) const; + +template <> +ASIO_DECL any_completion_executor any_completion_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_completion_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_completion_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_completion_executor.ipp" +#endif // defined(ASIO_HEADER_ONLY) + // && !defined(ASIO_USE_TS_EXECUTOR_AS_DEFAULT) + +#endif // ASIO_ANY_COMPLETION_EXECUTOR_HPP diff --git a/include/asio/any_completion_handler.hpp b/include/asio/any_completion_handler.hpp new file mode 100644 index 0000000..1114a09 --- /dev/null +++ b/include/asio/any_completion_handler.hpp @@ -0,0 +1,822 @@ +// +// any_completion_handler.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the 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_COMPLETION_HANDLER_HPP +#define ASIO_ANY_COMPLETION_HANDLER_HPP + +#include "asio/detail/config.hpp" +#include +#include +#include +#include +#include "asio/any_completion_executor.hpp" +#include "asio/any_io_executor.hpp" +#include "asio/associated_allocator.hpp" +#include "asio/associated_cancellation_slot.hpp" +#include "asio/associated_executor.hpp" +#include "asio/associated_immediate_executor.hpp" +#include "asio/cancellation_state.hpp" +#include "asio/recycling_allocator.hpp" + +#include "asio/detail/push_options.hpp" + +namespace asio { +namespace detail { + +class any_completion_handler_impl_base +{ +public: + template + explicit any_completion_handler_impl_base(S&& slot) + : cancel_state_(static_cast(slot), enable_total_cancellation()) + { + } + + cancellation_slot get_cancellation_slot() const noexcept + { + return cancel_state_.slot(); + } + +private: + cancellation_state cancel_state_; +}; + +template +class any_completion_handler_impl : + public any_completion_handler_impl_base +{ +public: + template + any_completion_handler_impl(S&& slot, H&& h) + : any_completion_handler_impl_base(static_cast(slot)), + handler_(static_cast(h)) + { + } + + struct uninit_deleter + { + typename std::allocator_traits< + associated_allocator_t>>::template + rebind_alloc alloc; + + void operator()(any_completion_handler_impl* ptr) + { + std::allocator_traits::deallocate(alloc, ptr, 1); + } + }; + + struct deleter + { + typename std::allocator_traits< + associated_allocator_t>>::template + rebind_alloc alloc; + + void operator()(any_completion_handler_impl* ptr) + { + std::allocator_traits::destroy(alloc, ptr); + std::allocator_traits::deallocate(alloc, ptr, 1); + } + }; + + template + static any_completion_handler_impl* create(S&& slot, H&& h) + { + uninit_deleter d{ + (get_associated_allocator)(h, + asio::recycling_allocator())}; + + std::unique_ptr uninit_ptr( + std::allocator_traits::allocate(d.alloc, 1), d); + + any_completion_handler_impl* ptr = + new (uninit_ptr.get()) any_completion_handler_impl( + static_cast(slot), static_cast(h)); + + uninit_ptr.release(); + return ptr; + } + + void destroy() + { + deleter d{ + (get_associated_allocator)(handler_, + asio::recycling_allocator())}; + + d(this); + } + + any_completion_executor executor( + const any_completion_executor& candidate) const noexcept + { + return any_completion_executor(std::nothrow, + (get_associated_executor)(handler_, candidate)); + } + + any_completion_executor immediate_executor( + const any_io_executor& candidate) const noexcept + { + return any_completion_executor(std::nothrow, + (get_associated_immediate_executor)(handler_, candidate)); + } + + void* allocate(std::size_t size, std::size_t align_size) const + { + typename std::allocator_traits< + associated_allocator_t>>::template + rebind_alloc alloc( + (get_associated_allocator)(handler_, + asio::recycling_allocator())); + + std::size_t space = size + align_size - 1; + unsigned char* base = + std::allocator_traits::allocate( + alloc, space + sizeof(std::ptrdiff_t)); + + void* p = base; + if (detail::align(align_size, size, p, space)) + { + std::ptrdiff_t off = static_cast(p) - base; + std::memcpy(static_cast(p) + size, &off, sizeof(off)); + return p; + } + + std::bad_alloc ex; + asio::detail::throw_exception(ex); + return nullptr; + } + + void deallocate(void* p, std::size_t size, std::size_t align) const + { + if (p) + { + typename std::allocator_traits< + associated_allocator_t>>::template + rebind_alloc alloc( + (get_associated_allocator)(handler_, + asio::recycling_allocator())); + + std::ptrdiff_t off; + std::memcpy(&off, static_cast(p) + size, sizeof(off)); + unsigned char* base = static_cast(p) - off; + + std::allocator_traits::deallocate( + alloc, base, size + align -1 + sizeof(std::ptrdiff_t)); + } + } + + template + void call(Args&&... args) + { + deleter d{ + (get_associated_allocator)(handler_, + asio::recycling_allocator())}; + + std::unique_ptr ptr(this, d); + Handler handler(static_cast(handler_)); + ptr.reset(); + + static_cast(handler)( + static_cast(args)...); + } + +private: + Handler handler_; +}; + +template +class any_completion_handler_call_fn; + +template +class any_completion_handler_call_fn +{ +public: + using type = void(*)(any_completion_handler_impl_base*, Args...); + + constexpr any_completion_handler_call_fn(type fn) + : call_fn_(fn) + { + } + + void call(any_completion_handler_impl_base* impl, Args... args) const + { + call_fn_(impl, static_cast(args)...); + } + + template + static void impl(any_completion_handler_impl_base* impl, Args... args) + { + static_cast*>(impl)->call( + static_cast(args)...); + } + +private: + type call_fn_; +}; + +template +class any_completion_handler_call_fns; + +template +class any_completion_handler_call_fns : + public any_completion_handler_call_fn +{ +public: + using any_completion_handler_call_fn< + Signature>::any_completion_handler_call_fn; + using any_completion_handler_call_fn::call; +}; + +template +class any_completion_handler_call_fns : + public any_completion_handler_call_fn, + public any_completion_handler_call_fns +{ +public: + template + constexpr any_completion_handler_call_fns(CallFn fn, CallFns... fns) + : any_completion_handler_call_fn(fn), + any_completion_handler_call_fns(fns...) + { + } + + using any_completion_handler_call_fn::call; + using any_completion_handler_call_fns::call; +}; + +class any_completion_handler_destroy_fn +{ +public: + using type = void(*)(any_completion_handler_impl_base*); + + constexpr any_completion_handler_destroy_fn(type fn) + : destroy_fn_(fn) + { + } + + void destroy(any_completion_handler_impl_base* impl) const + { + destroy_fn_(impl); + } + + template + static void impl(any_completion_handler_impl_base* impl) + { + static_cast*>(impl)->destroy(); + } + +private: + type destroy_fn_; +}; + +class any_completion_handler_executor_fn +{ +public: + using type = any_completion_executor(*)( + any_completion_handler_impl_base*, const any_completion_executor&); + + constexpr any_completion_handler_executor_fn(type fn) + : executor_fn_(fn) + { + } + + any_completion_executor executor(any_completion_handler_impl_base* impl, + const any_completion_executor& candidate) const + { + return executor_fn_(impl, candidate); + } + + template + static any_completion_executor impl(any_completion_handler_impl_base* impl, + const any_completion_executor& candidate) + { + return static_cast*>(impl)->executor( + candidate); + } + +private: + type executor_fn_; +}; + +class any_completion_handler_immediate_executor_fn +{ +public: + using type = any_completion_executor(*)( + any_completion_handler_impl_base*, const any_io_executor&); + + constexpr any_completion_handler_immediate_executor_fn(type fn) + : immediate_executor_fn_(fn) + { + } + + any_completion_executor immediate_executor( + any_completion_handler_impl_base* impl, + const any_io_executor& candidate) const + { + return immediate_executor_fn_(impl, candidate); + } + + template + static any_completion_executor impl(any_completion_handler_impl_base* impl, + const any_io_executor& candidate) + { + return static_cast*>( + impl)->immediate_executor(candidate); + } + +private: + type immediate_executor_fn_; +}; + +class any_completion_handler_allocate_fn +{ +public: + using type = void*(*)(any_completion_handler_impl_base*, + std::size_t, std::size_t); + + constexpr any_completion_handler_allocate_fn(type fn) + : allocate_fn_(fn) + { + } + + void* allocate(any_completion_handler_impl_base* impl, + std::size_t size, std::size_t align) const + { + return allocate_fn_(impl, size, align); + } + + template + static void* impl(any_completion_handler_impl_base* impl, + std::size_t size, std::size_t align) + { + return static_cast*>(impl)->allocate( + size, align); + } + +private: + type allocate_fn_; +}; + +class any_completion_handler_deallocate_fn +{ +public: + using type = void(*)(any_completion_handler_impl_base*, + void*, std::size_t, std::size_t); + + constexpr any_completion_handler_deallocate_fn(type fn) + : deallocate_fn_(fn) + { + } + + void deallocate(any_completion_handler_impl_base* impl, + void* p, std::size_t size, std::size_t align) const + { + deallocate_fn_(impl, p, size, align); + } + + template + static void impl(any_completion_handler_impl_base* impl, + void* p, std::size_t size, std::size_t align) + { + static_cast*>(impl)->deallocate( + p, size, align); + } + +private: + type deallocate_fn_; +}; + +template +class any_completion_handler_fn_table + : private any_completion_handler_destroy_fn, + private any_completion_handler_executor_fn, + private any_completion_handler_immediate_executor_fn, + private any_completion_handler_allocate_fn, + private any_completion_handler_deallocate_fn, + private any_completion_handler_call_fns +{ +public: + template + constexpr any_completion_handler_fn_table( + any_completion_handler_destroy_fn::type destroy_fn, + any_completion_handler_executor_fn::type executor_fn, + any_completion_handler_immediate_executor_fn::type immediate_executor_fn, + any_completion_handler_allocate_fn::type allocate_fn, + any_completion_handler_deallocate_fn::type deallocate_fn, + CallFns... call_fns) + : any_completion_handler_destroy_fn(destroy_fn), + any_completion_handler_executor_fn(executor_fn), + any_completion_handler_immediate_executor_fn(immediate_executor_fn), + any_completion_handler_allocate_fn(allocate_fn), + any_completion_handler_deallocate_fn(deallocate_fn), + any_completion_handler_call_fns(call_fns...) + { + } + + using any_completion_handler_destroy_fn::destroy; + using any_completion_handler_executor_fn::executor; + using any_completion_handler_immediate_executor_fn::immediate_executor; + using any_completion_handler_allocate_fn::allocate; + using any_completion_handler_deallocate_fn::deallocate; + using any_completion_handler_call_fns::call; +}; + +template +struct any_completion_handler_fn_table_instance +{ + static constexpr any_completion_handler_fn_table + value = any_completion_handler_fn_table( + &any_completion_handler_destroy_fn::impl, + &any_completion_handler_executor_fn::impl, + &any_completion_handler_immediate_executor_fn::impl, + &any_completion_handler_allocate_fn::impl, + &any_completion_handler_deallocate_fn::impl, + &any_completion_handler_call_fn::template impl...); +}; + +template +constexpr any_completion_handler_fn_table +any_completion_handler_fn_table_instance::value; + +} // namespace detail + +template +class any_completion_handler; + +/// An allocator type that forwards memory allocation operations through an +/// instance of @c any_completion_handler. +template +class any_completion_handler_allocator +{ +private: + template + friend class any_completion_handler; + + template + friend class any_completion_handler_allocator; + + const detail::any_completion_handler_fn_table* fn_table_; + detail::any_completion_handler_impl_base* impl_; + + constexpr any_completion_handler_allocator(int, + const any_completion_handler& h) noexcept + : fn_table_(h.fn_table_), + impl_(h.impl_) + { + } + +public: + /// The type of objects that may be allocated by the allocator. + typedef T value_type; + + /// Rebinds an allocator to another value type. + template + struct rebind + { + /// Specifies the type of the rebound allocator. + typedef any_completion_handler_allocator other; + }; + + /// Construct from another @c any_completion_handler_allocator. + template + constexpr any_completion_handler_allocator( + const any_completion_handler_allocator& a) + noexcept + : fn_table_(a.fn_table_), + impl_(a.impl_) + { + } + + /// Equality operator. + constexpr bool operator==( + const any_completion_handler_allocator& other) const noexcept + { + return fn_table_ == other.fn_table_ && impl_ == other.impl_; + } + + /// Inequality operator. + constexpr bool operator!=( + const any_completion_handler_allocator& other) const noexcept + { + return fn_table_ != other.fn_table_ || impl_ != other.impl_; + } + + /// Allocate space for @c n objects of the allocator's value type. + T* allocate(std::size_t n) const + { + if (fn_table_) + { + return static_cast( + fn_table_->allocate( + impl_, sizeof(T) * n, alignof(T))); + } + std::bad_alloc ex; + asio::detail::throw_exception(ex); + return nullptr; + } + + /// Deallocate space for @c n objects of the allocator's value type. + void deallocate(T* p, std::size_t n) const + { + fn_table_->deallocate(impl_, p, sizeof(T) * n, alignof(T)); + } +}; + +/// A protoco-allocator type that may be rebound to obtain an allocator that +/// forwards memory allocation operations through an instance of +/// @c any_completion_handler. +template +class any_completion_handler_allocator +{ +private: + template + friend class any_completion_handler; + + template + friend class any_completion_handler_allocator; + + const detail::any_completion_handler_fn_table* fn_table_; + detail::any_completion_handler_impl_base* impl_; + + constexpr any_completion_handler_allocator(int, + const any_completion_handler& h) noexcept + : fn_table_(h.fn_table_), + impl_(h.impl_) + { + } + +public: + /// @c void as no objects can be allocated through a proto-allocator. + typedef void value_type; + + /// Rebinds an allocator to another value type. + template + struct rebind + { + /// Specifies the type of the rebound allocator. + typedef any_completion_handler_allocator other; + }; + + /// Construct from another @c any_completion_handler_allocator. + template + constexpr any_completion_handler_allocator( + const any_completion_handler_allocator& a) + noexcept + : fn_table_(a.fn_table_), + impl_(a.impl_) + { + } + + /// Equality operator. + constexpr bool operator==( + const any_completion_handler_allocator& other) const noexcept + { + return fn_table_ == other.fn_table_ && impl_ == other.impl_; + } + + /// Inequality operator. + constexpr bool operator!=( + const any_completion_handler_allocator& other) const noexcept + { + return fn_table_ != other.fn_table_ || impl_ != other.impl_; + } +}; + +/// Polymorphic wrapper for completion handlers. +/** + * The @c any_completion_handler class template is a polymorphic wrapper for + * completion handlers that propagates the associated executor, associated + * allocator, and associated cancellation slot through a type-erasing interface. + * + * When using @c any_completion_handler, specify one or more completion + * signatures as template parameters. These will dictate the arguments that may + * be passed to the handler through the polymorphic interface. + * + * Typical uses for @c any_completion_handler include: + * + * @li Separate compilation of asynchronous operation implementations. + * + * @li Enabling interoperability between asynchronous operations and virtual + * functions. + */ +template +class any_completion_handler +{ +#if !defined(GENERATING_DOCUMENTATION) +private: + template + friend class any_completion_handler_allocator; + + template + friend struct associated_executor; + + template + friend struct associated_immediate_executor; + + const detail::any_completion_handler_fn_table* fn_table_; + detail::any_completion_handler_impl_base* impl_; +#endif // !defined(GENERATING_DOCUMENTATION) + +public: + /// The associated allocator type. + using allocator_type = any_completion_handler_allocator; + + /// The associated cancellation slot type. + using cancellation_slot_type = cancellation_slot; + + /// Construct an @c any_completion_handler in an empty state, without a target + /// object. + constexpr any_completion_handler() + : fn_table_(nullptr), + impl_(nullptr) + { + } + + /// Construct an @c any_completion_handler in an empty state, without a target + /// object. + constexpr any_completion_handler(nullptr_t) + : fn_table_(nullptr), + impl_(nullptr) + { + } + + /// Construct an @c any_completion_handler to contain the specified target. + template > + any_completion_handler(H&& h, + constraint_t< + !is_same, any_completion_handler>::value + > = 0) + : fn_table_( + &detail::any_completion_handler_fn_table_instance< + Handler, Signatures...>::value), + impl_(detail::any_completion_handler_impl::create( + (get_associated_cancellation_slot)(h), static_cast(h))) + { + } + + /// Move-construct an @c any_completion_handler from another. + /** + * After the operation, the moved-from object @c other has no target. + */ + any_completion_handler(any_completion_handler&& other) noexcept + : fn_table_(other.fn_table_), + impl_(other.impl_) + { + other.fn_table_ = nullptr; + other.impl_ = nullptr; + } + + /// Move-assign an @c any_completion_handler from another. + /** + * After the operation, the moved-from object @c other has no target. + */ + any_completion_handler& operator=( + any_completion_handler&& other) noexcept + { + any_completion_handler( + static_cast(other)).swap(*this); + return *this; + } + + /// Assignment operator that sets the polymorphic wrapper to the empty state. + any_completion_handler& operator=(nullptr_t) noexcept + { + any_completion_handler().swap(*this); + return *this; + } + + /// Destructor. + ~any_completion_handler() + { + if (impl_) + fn_table_->destroy(impl_); + } + + /// Test if the polymorphic wrapper is empty. + constexpr explicit operator bool() const noexcept + { + return impl_ != nullptr; + } + + /// Test if the polymorphic wrapper is non-empty. + constexpr bool operator!() const noexcept + { + return impl_ == nullptr; + } + + /// Swap the content of an @c any_completion_handler with another. + void swap(any_completion_handler& other) noexcept + { + std::swap(fn_table_, other.fn_table_); + std::swap(impl_, other.impl_); + } + + /// Get the associated allocator. + allocator_type get_allocator() const noexcept + { + return allocator_type(0, *this); + } + + /// Get the associated cancellation slot. + cancellation_slot_type get_cancellation_slot() const noexcept + { + return impl_ ? impl_->get_cancellation_slot() : cancellation_slot_type(); + } + + /// Function call operator. + /** + * Invokes target completion handler with the supplied arguments. + * + * This function may only be called once, as the target handler is moved from. + * The polymorphic wrapper is left in an empty state. + * + * Throws @c std::bad_function_call if the polymorphic wrapper is empty. + */ + template + auto operator()(Args&&... args) + -> decltype(fn_table_->call(impl_, static_cast(args)...)) + { + if (detail::any_completion_handler_impl_base* impl = impl_) + { + impl_ = nullptr; + return fn_table_->call(impl, static_cast(args)...); + } + std::bad_function_call ex; + asio::detail::throw_exception(ex); + } + + /// Equality operator. + friend constexpr bool operator==( + const any_completion_handler& a, nullptr_t) noexcept + { + return a.impl_ == nullptr; + } + + /// Equality operator. + friend constexpr bool operator==( + nullptr_t, const any_completion_handler& b) noexcept + { + return nullptr == b.impl_; + } + + /// Inequality operator. + friend constexpr bool operator!=( + const any_completion_handler& a, nullptr_t) noexcept + { + return a.impl_ != nullptr; + } + + /// Inequality operator. + friend constexpr bool operator!=( + nullptr_t, const any_completion_handler& b) noexcept + { + return nullptr != b.impl_; + } +}; + +template +struct associated_executor, Candidate> +{ + using type = any_completion_executor; + + static type get(const any_completion_handler& handler, + const Candidate& candidate = Candidate()) noexcept + { + any_completion_executor any_candidate(std::nothrow, candidate); + return handler.fn_table_ + ? handler.fn_table_->executor(handler.impl_, any_candidate) + : any_candidate; + } +}; + +template +struct associated_immediate_executor< + any_completion_handler, Candidate> +{ + using type = any_completion_executor; + + static type get(const any_completion_handler& handler, + const Candidate& candidate = Candidate()) noexcept + { + any_io_executor any_candidate(std::nothrow, candidate); + return handler.fn_table_ + ? handler.fn_table_->immediate_executor(handler.impl_, any_candidate) + : any_candidate; + } +}; + +} // namespace asio + +#include "asio/detail/pop_options.hpp" + +#endif // ASIO_ANY_COMPLETION_HANDLER_HPP diff --git a/include/asio/any_io_executor.hpp b/include/asio/any_io_executor.hpp new file mode 100644 index 0000000..a6c9c8d --- /dev/null +++ b/include/asio/any_io_executor.hpp @@ -0,0 +1,351 @@ +// +// any_io_executor.hpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the 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() noexcept; + + /// Construct in an empty state. Equivalent effects to default constructor. + ASIO_DECL any_io_executor(nullptr_t) noexcept; + + /// Copy constructor. + ASIO_DECL any_io_executor(const any_io_executor& e) noexcept; + + /// Move constructor. + ASIO_DECL any_io_executor(any_io_executor&& e) noexcept; + + /// 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, + constraint_t< + conditional_t< + !is_same::value + && is_base_of::value, + typename execution::detail::supportable_properties< + 0, supportable_properties_type>::template + is_valid_target, + false_type + >::value + > = 0) + : base_type(static_cast(e)) + { + } +#endif // defined(GENERATING_DOCUMENTATION) + + /// Construct to point to the same target as another any_executor. +#if defined(GENERATING_DOCUMENTATION) + template + any_io_executor(std::nothrow_t, + execution::any_executor e); +#else // defined(GENERATING_DOCUMENTATION) + template + any_io_executor(std::nothrow_t, OtherAnyExecutor e, + constraint_t< + conditional_t< + !is_same::value + && is_base_of::value, + typename execution::detail::supportable_properties< + 0, supportable_properties_type>::template + is_valid_target, + false_type + >::value + > = 0) noexcept + : base_type(std::nothrow, static_cast(e)) + { + } +#endif // defined(GENERATING_DOCUMENTATION) + + /// Construct to point to the same target as another any_executor. + ASIO_DECL any_io_executor(std::nothrow_t, + const any_io_executor& e) noexcept; + + /// Construct to point to the same target as another any_executor. + ASIO_DECL any_io_executor(std::nothrow_t, any_io_executor&& e) noexcept; + + /// 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, + constraint_t< + conditional_t< + !is_same::value + && !is_base_of::value, + execution::detail::is_valid_target_executor< + Executor, supportable_properties_type>, + false_type + >::value + > = 0) + : base_type(static_cast(e)) + { + } +#endif // defined(GENERATING_DOCUMENTATION) + + /// Construct a polymorphic wrapper for the specified executor. +#if defined(GENERATING_DOCUMENTATION) + template + any_io_executor(std::nothrow_t, Executor e); +#else // defined(GENERATING_DOCUMENTATION) + template + any_io_executor(std::nothrow_t, Executor e, + constraint_t< + conditional_t< + !is_same::value + && !is_base_of::value, + execution::detail::is_valid_target_executor< + Executor, supportable_properties_type>, + false_type + >::value + > = 0) noexcept + : base_type(std::nothrow, static_cast(e)) + { + } +#endif // defined(GENERATING_DOCUMENTATION) + + /// Assignment operator. + ASIO_DECL any_io_executor& operator=( + const any_io_executor& e) noexcept; + + /// Move assignment operator. + ASIO_DECL any_io_executor& operator=(any_io_executor&& e) noexcept; + + /// 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) 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, + constraint_t< + traits::require_member::is_valid + > = 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, + constraint_t< + traits::prefer_member::is_valid + > = 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/include/asio/append.hpp b/include/asio/append.hpp new file mode 100644 index 0000000..e0167e1 --- /dev/null +++ b/include/asio/append.hpp @@ -0,0 +1,65 @@ +// +// append.hpp +// ~~~~~~~~~~ +// +// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the 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_APPEND_HPP +#define ASIO_APPEND_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/detail/type_traits.hpp" + +#include "asio/detail/push_options.hpp" + +namespace asio { + +/// Completion token type used to specify that the completion handler +/// arguments should be passed additional values after the results of the +/// operation. +template +class append_t +{ +public: + /// Constructor. + template + constexpr explicit append_t(T&& completion_token, V&&... values) + : token_(static_cast(completion_token)), + values_(static_cast(values)...) + { + } + +//private: + CompletionToken token_; + std::tuple values_; +}; + +/// Completion token type used to specify that the completion handler +/// arguments should be passed additional values after the results of the +/// operation. +template +ASIO_NODISCARD inline constexpr +append_t, decay_t...> +append(CompletionToken&& completion_token, Values&&... values) +{ + return append_t, decay_t...>( + static_cast(completion_token), + static_cast(values)...); +} + +} // namespace asio + +#include "asio/detail/pop_options.hpp" + +#include "asio/impl/append.hpp" + +#endif // ASIO_APPEND_HPP diff --git a/include/asio/as_tuple.hpp b/include/asio/as_tuple.hpp new file mode 100644 index 0000000..d3250b7 --- /dev/null +++ b/include/asio/as_tuple.hpp @@ -0,0 +1,152 @@ +// +// as_tuple.hpp +// ~~~~~~~~~~~~ +// +// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the 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_AS_TUPLE_HPP +#define ASIO_AS_TUPLE_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/type_traits.hpp" + +#include "asio/detail/push_options.hpp" + +namespace asio { + +/// A @ref completion_token adapter used to specify that the completion handler +/// arguments should be combined into a single tuple argument. +/** + * The as_tuple_t class is used to indicate that any arguments to the + * completion handler should be combined and passed as a single tuple argument. + * The arguments are first moved into a @c std::tuple and that tuple is then + * passed to the completion handler. + */ +template +class as_tuple_t +{ +public: + /// Tag type used to prevent the "default" constructor from being used for + /// conversions. + struct default_constructor_tag {}; + + /// Default constructor. + /** + * This constructor is only valid if the underlying completion token is + * default constructible and move constructible. The underlying completion + * token is itself defaulted as an argument to allow it to capture a source + * location. + */ + constexpr as_tuple_t( + default_constructor_tag = default_constructor_tag(), + CompletionToken token = CompletionToken()) + : token_(static_cast(token)) + { + } + + /// Constructor. + template + constexpr explicit as_tuple_t( + T&& completion_token) + : token_(static_cast(completion_token)) + { + } + + /// Adapts an executor to add the @c as_tuple_t completion token as the + /// default. + template + struct executor_with_default : InnerExecutor + { + /// Specify @c as_tuple_t as the default completion token type. + typedef as_tuple_t default_completion_token_type; + + /// Construct the adapted executor from the inner executor type. + template + executor_with_default(const InnerExecutor1& ex, + constraint_t< + conditional_t< + !is_same::value, + is_convertible, + false_type + >::value + > = 0) noexcept + : InnerExecutor(ex) + { + } + }; + + /// Type alias to adapt an I/O object to use @c as_tuple_t as its + /// default completion token type. + template + using as_default_on_t = typename T::template rebind_executor< + executor_with_default>::other; + + /// Function helper to adapt an I/O object to use @c as_tuple_t as its + /// default completion token type. + template + static typename decay_t::template rebind_executor< + executor_with_default::executor_type> + >::other + as_default_on(T&& object) + { + return typename decay_t::template rebind_executor< + executor_with_default::executor_type> + >::other(static_cast(object)); + } + +//private: + CompletionToken token_; +}; + +/// A function object type that adapts a @ref completion_token to specify that +/// the completion handler arguments should be combined into a single tuple +/// argument. +/** + * May also be used directly as a completion token, in which case it adapts the + * asynchronous operation's default completion token (or asio::deferred + * if no default is available). + */ +struct partial_as_tuple +{ + /// Default constructor. + constexpr partial_as_tuple() + { + } + + /// Adapt a @ref completion_token to specify that the completion handler + /// arguments should be combined into a single tuple argument. + template + ASIO_NODISCARD inline + constexpr as_tuple_t> + operator()(CompletionToken&& completion_token) const + { + return as_tuple_t>( + static_cast(completion_token)); + } +}; + +/// A function object that adapts a @ref completion_token to specify that the +/// completion handler arguments should be combined into a single tuple +/// argument. +/** + * May also be used directly as a completion token, in which case it adapts the + * asynchronous operation's default completion token (or asio::deferred + * if no default is available). + */ +ASIO_INLINE_VARIABLE constexpr partial_as_tuple as_tuple; + +} // namespace asio + +#include "asio/detail/pop_options.hpp" + +#include "asio/impl/as_tuple.hpp" + +#endif // ASIO_AS_TUPLE_HPP diff --git a/include/asio/asio.hpp b/include/asio/asio.hpp new file mode 100644 index 0000000..2398b71 --- /dev/null +++ b/include/asio/asio.hpp @@ -0,0 +1,202 @@ +// +// asio.hpp +// ~~~~~~~~ +// +// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the 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/any_completion_executor.hpp" +#include "asio/any_completion_handler.hpp" +#include "asio/any_io_executor.hpp" +#include "asio/append.hpp" +#include "asio/as_tuple.hpp" +#include "asio/associated_allocator.hpp" +#include "asio/associated_cancellation_slot.hpp" +#include "asio/associated_executor.hpp" +#include "asio/associated_immediate_executor.hpp" +#include "asio/associator.hpp" +#include "asio/async_result.hpp" +#include "asio/awaitable.hpp" +#include "asio/basic_datagram_socket.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_allocator.hpp" +#include "asio/bind_cancellation_slot.hpp" +#include "asio/bind_executor.hpp" +#include "asio/bind_immediate_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/cancel_after.hpp" +#include "asio/cancel_at.hpp" +#include "asio/cancellation_signal.hpp" +#include "asio/cancellation_state.hpp" +#include "asio/cancellation_type.hpp" +#include "asio/co_composed.hpp" +#include "asio/co_spawn.hpp" +#include "asio/completion_condition.hpp" +#include "asio/compose.hpp" +#include "asio/composed.hpp" +#include "asio/config.hpp" +#include "asio/connect.hpp" +#include "asio/connect_pipe.hpp" +#include "asio/consign.hpp" +#include "asio/coroutine.hpp" +#include "asio/defer.hpp" +#include "asio/deferred.hpp" +#include "asio/default_completion_token.hpp" +#include "asio/detached.hpp" +#include "asio/dispatch.hpp" +#include "asio/disposition.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/context.hpp" +#include "asio/execution/context_as.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/outstanding_work.hpp" +#include "asio/execution/prefer_only.hpp" +#include "asio/execution/relationship.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_continuation_hook.hpp" +#include "asio/high_resolution_timer.hpp" +#include "asio/immediate.hpp" +#include "asio/io_context.hpp" +#include "asio/io_context_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_contiguous_iterator.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/seq_packet_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/prepend.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/recycling_allocator.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/signal_set_base.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/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/include/asio/associated_allocator.hpp b/include/asio/associated_allocator.hpp new file mode 100644 index 0000000..c15ff6d --- /dev/null +++ b/include/asio/associated_allocator.hpp @@ -0,0 +1,214 @@ +// +// associated_allocator.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the 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> : true_type +{ +}; + +template +struct associated_allocator_impl +{ + typedef void asio_associated_allocator_is_unspecialised; + + typedef A type; + + static type get(const T&) noexcept + { + return type(); + } + + static const type& get(const T&, const A& a) noexcept + { + return a; + } +}; + +template +struct associated_allocator_impl> +{ + typedef typename T::allocator_type type; + + static auto get(const T& t) noexcept + -> decltype(t.get_allocator()) + { + return t.get_allocator(); + } + + static auto get(const T& t, const A&) noexcept + -> decltype(t.get_allocator()) + { + return t.get_allocator(); + } +}; + +template +struct associated_allocator_impl::value + >, + void_t< + typename associator::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 or a (possibly const) reference to @c + * type. + * + * @li Provide a noexcept static member function named @c get, callable as @c + * get(t,a) and with return type @c type or a (possibly const) reference to @c + * type. + */ +template > +struct associated_allocator +#if !defined(GENERATING_DOCUMENTATION) + : detail::associated_allocator_impl +#endif // !defined(GENERATING_DOCUMENTATION) +{ +#if defined(GENERATING_DOCUMENTATION) + /// If @c T has a nested type @c allocator_type, T::allocator_type. + /// Otherwise @c Allocator. + typedef see_below type; + + /// If @c T has a nested type @c allocator_type, returns + /// t.get_allocator(). Otherwise returns @c type(). + static decltype(auto) get(const T& t) noexcept; + + /// If @c T has a nested type @c allocator_type, returns + /// t.get_allocator(). Otherwise returns @c a. + static decltype(auto) get(const T& t, const Allocator& a) noexcept; +#endif // defined(GENERATING_DOCUMENTATION) +}; + +/// Helper function to obtain an object's associated allocator. +/** + * @returns associated_allocator::get(t) + */ +template +ASIO_NODISCARD inline typename associated_allocator::type +get_associated_allocator(const T& t) noexcept +{ + return associated_allocator::get(t); +} + +/// Helper function to obtain an object's associated allocator. +/** + * @returns associated_allocator::get(t, a) + */ +template +ASIO_NODISCARD inline auto get_associated_allocator( + const T& t, const Allocator& a) noexcept + -> decltype(associated_allocator::get(t, a)) +{ + return associated_allocator::get(t, a); +} + +template > +using associated_allocator_t + = typename associated_allocator::type; + +namespace detail { + +template +struct associated_allocator_forwarding_base +{ +}; + +template +struct associated_allocator_forwarding_base::asio_associated_allocator_is_unspecialised, + void + >::value + >> +{ + typedef void asio_associated_allocator_is_unspecialised; +}; + +} // namespace detail + +/// Specialisation of associated_allocator for @c std::reference_wrapper. +template +struct associated_allocator, Allocator> +#if !defined(GENERATING_DOCUMENTATION) + : detail::associated_allocator_forwarding_base +#endif // !defined(GENERATING_DOCUMENTATION) +{ + /// 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) noexcept + { + return associated_allocator::get(t.get()); + } + + /// Forwards the request to get the allocator to the associator specialisation + /// for the unwrapped type @c T. + static auto get(reference_wrapper t, const Allocator& a) noexcept + -> decltype(associated_allocator::get(t.get(), a)) + { + return associated_allocator::get(t.get(), a); + } +}; + +} // namespace asio + +#include "asio/detail/pop_options.hpp" + +#endif // ASIO_ASSOCIATED_ALLOCATOR_HPP diff --git a/include/asio/associated_cancellation_slot.hpp b/include/asio/associated_cancellation_slot.hpp new file mode 100644 index 0000000..79dccec --- /dev/null +++ b/include/asio/associated_cancellation_slot.hpp @@ -0,0 +1,221 @@ +// +// associated_cancellation_slot.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the 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/functional.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> + : true_type +{ +}; + +template +struct associated_cancellation_slot_impl +{ + typedef void asio_associated_cancellation_slot_is_unspecialised; + + typedef S type; + + static type get(const T&) noexcept + { + return type(); + } + + static const type& get(const T&, const S& s) noexcept + { + return s; + } +}; + +template +struct associated_cancellation_slot_impl> +{ + typedef typename T::cancellation_slot_type type; + + static auto get(const T& t) noexcept + -> decltype(t.get_cancellation_slot()) + { + return t.get_cancellation_slot(); + } + + static auto get(const T& t, const S&) noexcept + -> decltype(t.get_cancellation_slot()) + { + return t.get_cancellation_slot(); + } +}; + +template +struct associated_cancellation_slot_impl::value + >, + void_t< + typename associator::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 or a (possibly const) reference to @c + * type. + * + * @li Provide a noexcept static member function named @c get, callable as @c + * get(t,s) and with return type @c type or a (possibly const) reference to @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 type(). + static decltype(auto) get(const T& t) noexcept; + + /// If @c T has a nested type @c cancellation_slot_type, returns + /// t.get_cancellation_slot(). Otherwise returns @c s. + static decltype(auto) get(const T& t, + const CancellationSlot& s) noexcept; +#endif // defined(GENERATING_DOCUMENTATION) +}; + +/// Helper function to obtain an object's associated cancellation_slot. +/** + * @returns associated_cancellation_slot::get(t) + */ +template +ASIO_NODISCARD inline typename associated_cancellation_slot::type +get_associated_cancellation_slot(const T& t) 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 +ASIO_NODISCARD inline auto get_associated_cancellation_slot( + const T& t, const CancellationSlot& st) noexcept + -> decltype(associated_cancellation_slot::get(t, st)) +{ + return associated_cancellation_slot::get(t, st); +} + +template +using associated_cancellation_slot_t = + typename associated_cancellation_slot::type; + +namespace detail { + +template +struct associated_cancellation_slot_forwarding_base +{ +}; + +template +struct associated_cancellation_slot_forwarding_base::asio_associated_cancellation_slot_is_unspecialised, + void + >::value + >> +{ + typedef void asio_associated_cancellation_slot_is_unspecialised; +}; + +} // namespace detail + +/// Specialisation of associated_cancellation_slot for @c +/// std::reference_wrapper. +template +struct associated_cancellation_slot, CancellationSlot> +#if !defined(GENERATING_DOCUMENTATION) + : detail::associated_cancellation_slot_forwarding_base +#endif // !defined(GENERATING_DOCUMENTATION) +{ + /// Forwards @c type to the associator specialisation for the unwrapped type + /// @c T. + typedef typename associated_cancellation_slot::type type; + + /// Forwards the request to get the cancellation slot to the associator + /// specialisation for the unwrapped type @c T. + static type get(reference_wrapper t) noexcept + { + return associated_cancellation_slot::get(t.get()); + } + + /// Forwards the request to get the cancellation slot to the associator + /// specialisation for the unwrapped type @c T. + static auto get(reference_wrapper t, const CancellationSlot& s) noexcept + -> decltype( + associated_cancellation_slot::get(t.get(), s)) + { + return associated_cancellation_slot::get(t.get(), s); + } +}; + +} // namespace asio + +#include "asio/detail/pop_options.hpp" + +#endif // ASIO_ASSOCIATED_CANCELLATION_SLOT_HPP diff --git a/include/asio/associated_executor.hpp b/include/asio/associated_executor.hpp new file mode 100644 index 0000000..5e0746f --- /dev/null +++ b/include/asio/associated_executor.hpp @@ -0,0 +1,235 @@ +// +// associated_executor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the 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> + : true_type +{ +}; + +template +struct associated_executor_impl +{ + typedef void asio_associated_executor_is_unspecialised; + + typedef E type; + + static type get(const T&) noexcept + { + return type(); + } + + static const type& get(const T&, const E& e) noexcept + { + return e; + } +}; + +template +struct associated_executor_impl> +{ + typedef typename T::executor_type type; + + static auto get(const T& t) noexcept + -> decltype(t.get_executor()) + { + return t.get_executor(); + } + + static auto get(const T& t, const E&) noexcept + -> decltype(t.get_executor()) + { + return t.get_executor(); + } +}; + +template +struct associated_executor_impl::value + >, + void_t< + typename associator::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 or a (possibly const) reference to @c + * type. + * + * @li Provide a noexcept static member function named @c get, callable as @c + * get(t,e) and with return type @c type or a (possibly const) reference to @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 type(). + static decltype(auto) get(const T& t) noexcept; + + /// If @c T has a nested type @c executor_type, returns + /// t.get_executor(). Otherwise returns @c ex. + static decltype(auto) get(const T& t, const Executor& ex) noexcept; +#endif // defined(GENERATING_DOCUMENTATION) +}; + +/// Helper function to obtain an object's associated executor. +/** + * @returns associated_executor::get(t) + */ +template +ASIO_NODISCARD inline typename associated_executor::type +get_associated_executor(const T& t) noexcept +{ + return associated_executor::get(t); +} + +/// Helper function to obtain an object's associated executor. +/** + * @returns associated_executor::get(t, ex) + */ +template +ASIO_NODISCARD inline auto get_associated_executor( + const T& t, const Executor& ex, + constraint_t< + is_executor::value || execution::is_executor::value + > = 0) noexcept + -> decltype(associated_executor::get(t, ex)) +{ + return associated_executor::get(t, ex); +} + +/// Helper function to obtain an object's associated executor. +/** + * @returns associated_executor::get(t, ctx.get_executor()) + */ +template +ASIO_NODISCARD inline typename associated_executor::type +get_associated_executor(const T& t, ExecutionContext& ctx, + constraint_t::value> = 0) noexcept +{ + return associated_executor::get(t, ctx.get_executor()); +} + +template +using associated_executor_t = typename associated_executor::type; + +namespace detail { + +template +struct associated_executor_forwarding_base +{ +}; + +template +struct associated_executor_forwarding_base::asio_associated_executor_is_unspecialised, + void + >::value + >> +{ + typedef void asio_associated_executor_is_unspecialised; +}; + +} // namespace detail + +/// 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) noexcept + { + return associated_executor::get(t.get()); + } + + /// Forwards the request to get the executor to the associator specialisation + /// for the unwrapped type @c T. + static auto get(reference_wrapper t, const Executor& ex) noexcept + -> decltype(associated_executor::get(t.get(), ex)) + { + return associated_executor::get(t.get(), ex); + } +}; + +} // namespace asio + +#include "asio/detail/pop_options.hpp" + +#endif // ASIO_ASSOCIATED_EXECUTOR_HPP diff --git a/include/asio/associated_immediate_executor.hpp b/include/asio/associated_immediate_executor.hpp new file mode 100644 index 0000000..9b1e0c6 --- /dev/null +++ b/include/asio/associated_immediate_executor.hpp @@ -0,0 +1,281 @@ +// +// associated_immediate_executor.hpp +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the 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_IMMEDIATE_EXECUTOR_HPP +#define ASIO_ASSOCIATED_IMMEDIATE_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/blocking.hpp" +#include "asio/execution/executor.hpp" +#include "asio/execution_context.hpp" +#include "asio/is_executor.hpp" +#include "asio/require.hpp" + +#include "asio/detail/push_options.hpp" + +namespace asio { + +template +struct associated_immediate_executor; + +namespace detail { + +template +struct has_immediate_executor_type : false_type +{ +}; + +template +struct has_immediate_executor_type> + : true_type +{ +}; + +template +struct default_immediate_executor +{ + typedef decay_t> type; + + static auto get(const E& e) noexcept + -> decltype(asio::require(e, execution::blocking.never)) + { + return asio::require(e, execution::blocking.never); + } +}; + +template +struct default_immediate_executor::value + >, + enable_if_t< + is_executor::value + >> +{ + class type : public E + { + public: + template + explicit type(const Executor1& e, + constraint_t< + conditional_t< + !is_same::value, + is_convertible, + false_type + >::value + > = 0) noexcept + : E(e) + { + } + + type(const type& other) noexcept + : E(static_cast(other)) + { + } + + type(type&& other) noexcept + : E(static_cast(other)) + { + } + + template + void dispatch(Function&& f, const Allocator& a) const + { + this->post(static_cast(f), a); + } + + friend bool operator==(const type& a, const type& b) noexcept + { + return static_cast(a) == static_cast(b); + } + + friend bool operator!=(const type& a, const type& b) noexcept + { + return static_cast(a) != static_cast(b); + } + }; + + static type get(const E& e) noexcept + { + return type(e); + } +}; + +template +struct associated_immediate_executor_impl +{ + typedef void asio_associated_immediate_executor_is_unspecialised; + + typedef typename default_immediate_executor::type type; + + static auto get(const T&, const E& e) noexcept + -> decltype(default_immediate_executor::get(e)) + { + return default_immediate_executor::get(e); + } +}; + +template +struct associated_immediate_executor_impl> +{ + typedef typename T::immediate_executor_type type; + + static auto get(const T& t, const E&) noexcept + -> decltype(t.get_immediate_executor()) + { + return t.get_immediate_executor(); + } +}; + +template +struct associated_immediate_executor_impl::value + >, + void_t< + typename associator::type + >> : associator +{ +}; + +} // namespace detail + +/// Traits type used to obtain the immediate 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 or a (possibly const) reference to @c + * type. + * + * @li Provide a noexcept static member function named @c get, callable as @c + * get(t,e) and with return type @c type or a (possibly const) reference to @c + * type. + */ +template +struct associated_immediate_executor +#if !defined(GENERATING_DOCUMENTATION) + : detail::associated_immediate_executor_impl +#endif // !defined(GENERATING_DOCUMENTATION) +{ +#if defined(GENERATING_DOCUMENTATION) + /// If @c T has a nested type @c immediate_executor_type, + // T::immediate_executor_type. Otherwise @c Executor. + typedef see_below type; + + /// If @c T has a nested type @c immediate_executor_type, returns + /// t.get_immediate_executor(). Otherwise returns + /// asio::require(ex, asio::execution::blocking.never). + static decltype(auto) get(const T& t, const Executor& ex) noexcept; +#endif // defined(GENERATING_DOCUMENTATION) +}; + +/// Helper function to obtain an object's associated executor. +/** + * @returns associated_immediate_executor::get(t, ex) + */ +template +ASIO_NODISCARD inline auto get_associated_immediate_executor( + const T& t, const Executor& ex, + constraint_t< + is_executor::value || execution::is_executor::value + > = 0) noexcept + -> decltype(associated_immediate_executor::get(t, ex)) +{ + return associated_immediate_executor::get(t, ex); +} + +/// Helper function to obtain an object's associated executor. +/** + * @returns associated_immediate_executor::get(t, ctx.get_executor()) + */ +template +ASIO_NODISCARD inline typename associated_immediate_executor::type +get_associated_immediate_executor(const T& t, ExecutionContext& ctx, + constraint_t< + is_convertible::value + > = 0) noexcept +{ + return associated_immediate_executor::get(t, ctx.get_executor()); +} + +template +using associated_immediate_executor_t = + typename associated_immediate_executor::type; + +namespace detail { + +template +struct associated_immediate_executor_forwarding_base +{ +}; + +template +struct associated_immediate_executor_forwarding_base::asio_associated_immediate_executor_is_unspecialised, + void + >::value + >> +{ + typedef void asio_associated_immediate_executor_is_unspecialised; +}; + +} // namespace detail + +/// Specialisation of associated_immediate_executor for +/// @c std::reference_wrapper. +template +struct associated_immediate_executor, Executor> +#if !defined(GENERATING_DOCUMENTATION) + : detail::associated_immediate_executor_forwarding_base +#endif // !defined(GENERATING_DOCUMENTATION) +{ + /// Forwards @c type to the associator specialisation for the unwrapped type + /// @c T. + typedef typename associated_immediate_executor::type type; + + /// Forwards the request to get the executor to the associator specialisation + /// for the unwrapped type @c T. + static auto get(reference_wrapper t, const Executor& ex) noexcept + -> decltype(associated_immediate_executor::get(t.get(), ex)) + { + return associated_immediate_executor::get(t.get(), ex); + } +}; + +} // namespace asio + +#include "asio/detail/pop_options.hpp" + +#endif // ASIO_ASSOCIATED_IMMEDIATE_EXECUTOR_HPP diff --git a/include/asio/associator.hpp b/include/asio/associator.hpp new file mode 100644 index 0000000..5c4f382 --- /dev/null +++ b/include/asio/associator.hpp @@ -0,0 +1,35 @@ +// +// associator.hpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the 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