2
0
mirror of https://github.com/boostorg/asio.git synced 2026-01-31 19:52:09 +00:00
Commit Graph

894 Commits

Author SHA1 Message Date
Christopher Kohlhoff
cb60b08ff5 Add source location support to handler tracking.
The BOOST_ASIO_HANDLER_LOCATION((file_name, line, function_name)) macro
may be used to inform the handler tracking mechanism of a source
location. This macro declares an object that is placed on the stack.

When an asynchronous operation is launched with location information, it
outputs lines using the <action> 'n^m', prior to the 'n*m' line that
signifies the beginning of the asynchronous operation. For example:

    @asio|1589423304.861944|>7|ec=system:0,bytes_transferred=5
    @asio|1589423304.861952|7^8|in 'async_write' (./../../../include/asio/impl/write.hpp:330)
    @asio|1589423304.861952|7^8|called from 'do_write' (handler_tracking/async_tcp_echo_server.cpp:62)
    @asio|1589423304.861952|7^8|called from 'operator()' (handler_tracking/async_tcp_echo_server.cpp:51)
    @asio|1589423304.861952|7*8|socket@0x7ff61c008230.async_send
    @asio|1589423304.861975|.8|non_blocking_send,ec=system:0,bytes_transferred=5
    @asio|1589423304.861980|<7|

If std::source_location or std::experimental::source_location are
available, the use_awaitable_t token (when default-constructed or used
as a default completion token) will also cause handler tracking to
output a source location for each newly created asynchronous operation.
A use_awaitable_t object may also be explicitly constructed with location
information.
2020-06-22 20:46:29 +10:00
Christopher Kohlhoff
84ee50a2d8 Enable C++20 coroutine support for gcc 10. 2020-06-22 20:45:30 +10:00
Christopher Kohlhoff
4d3e0453e8 Fix async_compose so that it works with copyable handlers passed as an lvalue. 2020-06-22 20:45:09 +10:00
Christopher Kohlhoff
56aaf6156b Add move constructor to ssl::stream<>. 2020-06-22 20:42:56 +10:00
Christopher Kohlhoff
1cebe7c5b3 Add missing nested type '::type' when computing signature. 2020-06-22 20:40:13 +10:00
Christopher Kohlhoff
2f327be5fe Linearise gather-write buffer sequences in ssl::stream. 2020-06-22 20:37:47 +10:00
Christopher Kohlhoff
d114cff2d2 Version bump. 2020-04-22 21:55:36 +10:00
Christopher Kohlhoff
c7cf0ae0cf Fix incorrect overload selection due to injected class name. 2020-04-21 18:05:20 +10:00
Christopher Kohlhoff
371f4de392 Fix use of rebind_executor in use_awaitable.as_default_on. 2020-04-08 17:43:00 +10:00
Christopher Kohlhoff
cc5d523aee Fix comments with incorrect ASIO_HAS_TYPE_TRAITS to use ASIO_HAS_STD_TYPE_TRAITS. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
34318996a2 Add emscripten compatibility patches (Use O_NONBLOCK instead of FIONBIO + Fix usage of strerror_r). 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
d3a0dc2d8b TV titles are also windows apps. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
33412a42bb Remove unnecessary null pointer checks. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
3654215317 Add ssl::context constructor to take ownership of a native handle. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
c9382b9b42 Fix compile error in buffered streams due to lack of reference collapsing in C++98. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
094aba17f4 Recreate the socket_select_interrupter's sockets on error.
On some versions of Windows, it seems that "self pipe trick" sockets may
be disconnected after a system sleep. To work around this, we recreate
the sockets following an error on read.
2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
c1a3addbba Fix a Windows-specific thread_pool destructor hang when the pool has an associated I/O object. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
8345e0a182 Suppress non-virtual destructor warnings. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
60e491a9e4 Propagate non-EOF errors from add_certificate_authority. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
84e14b0452 Remove incorrect handler requirement checks in async_read that were accidentally left behind. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
8241ccee3f Add missing doxygen marker in executor_work_guard documentation. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
53e91db69d Fix build on current NetBSD. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
959798ee7a Ensure resolver is restarted correctly after a fork. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
7b6ac4f001 Fix strand<> converting construction and assigment. 2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
62dad58386 Add ssl::host_name_verification.
The ssl::host_name_verification class is a drop-in replacement for
ssl::rfc2818_verification, which it supersedes. The
ssl::rfc2818_verification class has been marked as deprecated.

Thanks to Arvid Norberg for providing the implementation.
2020-04-07 11:44:28 +10:00
Christopher Kohlhoff
df4d3c18fd Fix work counting issue in asynchronous resolver endpoint implementation. 2020-04-07 11:20:20 +10:00
Christopher Kohlhoff
18305828ab Mark posix descriptor classes' move constructors as noexcept. 2020-04-07 11:19:15 +10:00
Christopher Kohlhoff
a707db8193 Support C++20 concept syntax. 2020-04-07 11:18:31 +10:00
Christopher Kohlhoff
bd6d59e65e When using gcc, use __cplusplus macro to determine language conformance. 2020-04-07 11:17:33 +10:00
Christopher Kohlhoff
4b552cfd5b Update copyright notices. 2020-04-07 11:15:42 +10:00
Christopher Kohlhoff
95f7e93635 Version bump. 2019-12-05 00:34:58 +11:00
Christopher Kohlhoff
f74937cdd6 Don't specify default token on some async_write overloads.
Eliminates an ambiguity.
2019-12-03 20:13:24 +11:00
Christopher Kohlhoff
dfc8da28c1 Start handler work again in case of restarting accept operation. 2019-12-03 20:12:53 +11:00
Christopher Kohlhoff
a69af4d982 Specify default baud rate when opening serial port on Windows. 2019-12-03 20:10:04 +11:00
Christopher Kohlhoff
2c29ad2e98 Fix constant used to initialise the serial port RTS control flag on Windows. 2019-12-03 20:06:48 +11:00
Christopher Kohlhoff
5225384b4d Use feature-test macro for detecting return type deduction. 2019-12-03 20:06:15 +11:00
Christopher Kohlhoff
37c6a4cea5 More typenames required in ssl::stream. 2019-12-03 19:57:37 +11:00
Christopher Kohlhoff
b6c27b9c31 Add noexcept qualifier to socket move constructors. 2019-11-06 21:13:26 +11:00
Christopher Kohlhoff
6e49032917 Require that Endpoint default constructor and move operations never throw. 2019-11-06 21:13:26 +11:00
Christopher Kohlhoff
ab97085e81 Add noexcept qualifier to protocol accessors. 2019-11-06 20:58:27 +11:00
Christopher Kohlhoff
529ce8dec4 Add typename to ssl::stream's initiation objects' executor_type typedefs. 2019-11-06 20:57:47 +11:00
Christopher Kohlhoff
7b0b56b702 Ensure the executor type is propagated to newly accepted sockets.
When synchronously or asynchronously accepting a new connection, but
without specifying an executor or execution context, the accept
operation will now correctly propagate the executor type from the
acceptor to the socket. For example, if your acceptor type is:

  basic_socket_acceptor<ip::tcp, my_executor_type>

then your accepted socket type will be:

  basic_stream_socket<ip::tcp, my_executor_type>
2019-10-30 20:53:18 +11:00
Christopher Kohlhoff
8e0762de49 Add default completion tokens.
Every I/O executor type now has an associated default completion token
type. This is specified via the `default_completion_token_type` trait.
This trait may be used in asynchronous operation declarations as
follows:

  template <
      typename IoObject,
      typename CompletionToken =
        typename default_completion_token_type<
          typename IoObject::executor_type
        >::type
    >
  auto async_foo(
      IoObject& io_object,
      CompletionToken&& token =
        typename default_completion_token_type<
          typename IoObject::executor_type
        >::type{}
    );

If not specialised, this trait type is `void`, meaning no default
completion token type is available for the given I/O executor.

The `default_completion_token_type` trait is specialised for the
`use_awaitable` completion token so that it may be used as shown in the
following example:

  auto socket = use_awaitable.as_default_on(tcp::socket(my_context));
  // ...
  co_await socket.async_connect(my_endpoint); // Defaults to use_awaitable.

In this example, type of the `socket` object is transformed from
`tcp::socket` to have an I/O executor with the default completion token
set to `use_awaitable`.

Alternatively, the socket type may be computed directly:

  using tcp_socket = use_awaitable_t<>::as_default_on_t<tcp::socket>;
  tcp_socket socket(my_context);
  // ...
  co_await socket.async_connect(my_endpoint); // Defaults to use_awaitable.
2019-10-30 20:51:58 +11:00
Christopher Kohlhoff
ab27d55ef2 Use async_initiate in Windows-specific I/O objects. 2019-10-30 20:49:47 +11:00
Christopher Kohlhoff
935dad16cb Add executor_type/get_executor to all initiation objects.
The asynchronous operations' initiation function objects now report
their associated I/O executor via the nested type `executor_type` and
member function `get_executor()`.

The presence of `executor_type` and `get_executor()` should be treated
as optional, and consequently it may be preferable to access them via
the `associated_executor` trait and the `get_associated_executor()`
helper function.
2019-10-30 20:48:15 +11:00
Christopher Kohlhoff
b9dce65df6 Add rebind_executor to all I/O object types.
The I/O objects provided by Asio now support the nested template type
`rebind_executor` as a way to generically rebind them to an alternative
I/O executor type. For example:

  using my_socket_type =
    tcp::socket::rebind_executor<my_executor_type>::other;
2019-10-30 20:46:29 +11:00
Christopher Kohlhoff
72ca8370ed Use completion_token_for concept to constrain token parameters. 2019-10-30 20:45:38 +11:00
Christopher Kohlhoff
ac6f944f72 Add concepts to support async_initiate.
This change introduces three new concepts:

* completion_signature<T>: Checks if T is a signature of the form R(Args...).

* completion_handler_for<T, Signature>: Checks if T is usable as a completion
  handler with the specified signature.

* completion_token_for<T, Signature>: Checks if T is a completion token that
  can be used with async_initiate and the specified signature.

For backward compatibility, use the macros BOOST_ASIO_COMPLETION_SIGNATURE,
BOOST_ASIO_COMPLETION_HANDLER_FOR, and BOOST_ASIO_COMPLETION_TOKEN_FOR
respectively. These macros expand to `typename` when concepts are unsupported.
2019-10-30 20:44:27 +11:00
Christopher Kohlhoff
77b14fff7f Use automatically deduced return types for all async operations.
C++14 or later is required to support completion tokens that use
per-operation return type deduction. For C++11 or earlier, a completion
token's async_result specialisation must still provide the nested
typedef `return_type`.
2019-10-30 20:39:22 +11:00
Christopher Kohlhoff
3f680fe1f7 Add automatic return type deduction to async_initiate.
Enabled for C++11 or later.
2019-10-30 20:38:31 +11:00