|
7 | 7 |
|
8 | 8 | [section:history Revision History] |
9 | 9 |
|
| 10 | +[heading Asio 1.31.0 / Boost 1.86 beta] |
| 11 | + |
| 12 | +* Changed the `default_completion_token` trait's primary template to select |
| 13 | + `deferred` as the default completion token. As a result, most asynchronous |
| 14 | + operations' initiating functions will return a deferred asynchronous operation |
| 15 | + by default. For example, the completion token can be omitted when calling |
| 16 | + asynchronous operations from an `awaitable` coroutine:[br] |
| 17 | + `` |
| 18 | + awaitable<void> echo(ip::tcp::socket& my_socket) |
| 19 | + { |
| 20 | + char data[1024]; |
| 21 | + for (;;) |
| 22 | + { |
| 23 | + std::size_t n = co_await my_socket.async_read_some(buffer(data)); |
| 24 | + co_await async_write(my_socket, buffer(data, n)); |
| 25 | + } |
| 26 | + } |
| 27 | + `` |
| 28 | + or when using an operation that accepts asynchronous operations as function |
| 29 | + objects, such as `experimental::make_parallel_group`:[br] |
| 30 | + `` |
| 31 | + experimental::make_parallel_group( |
| 32 | + my_socket.async_read_some(buffer(data)), |
| 33 | + my_timer.async_wait() |
| 34 | + ).async_wait(/* ... */); |
| 35 | + `` |
| 36 | +* Added the `is_completion_condition` trait and used it to add the missing |
| 37 | + default completion tokens to overloads of `async_read`, `async_read_at`, |
| 38 | + `async_write`, and `async_write_at`. |
| 39 | +* Added the `is_connect_condition` trait and used it disambiguate overloads of |
| 40 | + `async_connect` when the completion token is defaulted. |
| 41 | +* Extended the completion token adapters `as_tuple`, `bind_allocator`, |
| 42 | + `bind_cancellation_slot`, `bind_executor`, `bind_immediate_executor`, and |
| 43 | + `redirect_error` to allow them to be used as ['partial completion token |
| 44 | + adapters]. This means that they can be created without explicitly supplying a |
| 45 | + completion token. Instead, when the adapter is passed to an asynchronous |
| 46 | + operation, it will automatically determine the operation's default completion |
| 47 | + token and adapt it. For example, the expression:[br] |
| 48 | + `` |
| 49 | + my_socket.async_read_some(my_buffer, as_tuple) |
| 50 | + `` |
| 51 | + will return a deferred asynchronous operation with the completion arguments |
| 52 | + packaged in a tuple. They may also be applied using the `deferred` operations' |
| 53 | + pipe operator:[br] |
| 54 | + `` |
| 55 | + error_code e; |
| 56 | + co_await (async_write(my_socket, my_buffer) | redirect_error(e)); |
| 57 | + `` |
| 58 | +* Added the `cancel_after` and `cancel_at` completion token adapters. These |
| 59 | + may be used to adapt any asynchronous operation to emit a cancellation signal |
| 60 | + after a specified duration or at an absolute time point. For example:[br] |
| 61 | + `` |
| 62 | + my_socket.async_read_some(my_buffer, |
| 63 | + cancel_after(std::chrono::seconds(10), |
| 64 | + [](error_code e, std::size_t n) |
| 65 | + { |
| 66 | + // ... |
| 67 | + })); |
| 68 | + `` |
| 69 | + This cancellation is implemented internally using a `basic_waitable_timer`. |
| 70 | + By default, this timer is created using the asynchronous operation's I/O |
| 71 | + executor. If the operation does specify its I/O executor, a timer may be |
| 72 | + explicitly supplied:[br] |
| 73 | + `` |
| 74 | + my_socket.async_read_some(my_buffer, |
| 75 | + cancel_after(my_timer, std::chrono::seconds(10), |
| 76 | + [](error_code e, std::size_t n) |
| 77 | + { |
| 78 | + // ... |
| 79 | + })); |
| 80 | + `` |
| 81 | + These adapters may also be used as partial completion token adapters, as |
| 82 | + in:[br] |
| 83 | + `` |
| 84 | + co_await my_socket.async_read_some(my_buffer, cancel_after(5s)); |
| 85 | + `` |
| 86 | + or:[br] |
| 87 | + `` |
| 88 | + co_await ( |
| 89 | + async_write(my_socket, my_buffer) | as_tuple |
| 90 | + | cancel_after(std::chronos::seconds(10) |
| 91 | + ); |
| 92 | + `` |
| 93 | + or to adapt other partial completion token adapters:[br] |
| 94 | + `` |
| 95 | + co_await my_socket.async_read_some(my_buffer, cancel_after(5s, as_tuple)); |
| 96 | + `` |
| 97 | + Note that, since the implementation in terms of a timer introduces a parallel |
| 98 | + `async_wait` operation, it is the responsibility of the caller to ensure that |
| 99 | + the asynchronous operation is performed in an implicit or explicit strand. |
| 100 | +* Changed all completion token adapters to ensure they correctly propagate the |
| 101 | + asynchronous operation's I/O executor during adaptation. |
| 102 | +* Fixed `async_compose` and `co_composed` to correctly indicate if they have |
| 103 | + an I/O executor. |
| 104 | +* Moved `co_composed` out of the `experimental` namespace. |
| 105 | +* Added `composed`, which creates an initiation function object from a stateful |
| 106 | + implementation. It is similar to `co_composed`, but for regular function |
| 107 | + objects rather than C++20 coroutines. For example: |
| 108 | + `` |
| 109 | + struct async_echo_implementation |
| 110 | + { |
| 111 | + tcp::socket& socket_; |
| 112 | + mutable_buffer buffer_; |
| 113 | + enum { starting, reading, writing } state_; |
| 114 | + |
| 115 | + template <typename Self> |
| 116 | + void operator()(Self& self, |
| 117 | + error_code error, |
| 118 | + std::size_t n) |
| 119 | + { |
| 120 | + switch (state_) |
| 121 | + { |
| 122 | + // ... |
| 123 | + } |
| 124 | + } |
| 125 | + }; |
| 126 | + |
| 127 | + template <typename CompletionToken> |
| 128 | + auto async_echo(tcp::socket& socket, |
| 129 | + mutable_buffer buffer, |
| 130 | + CompletionToken&& token) |
| 131 | + { |
| 132 | + return async_initiate<CompletionToken, |
| 133 | + void(error_code, std::size_t)>( |
| 134 | + composed( |
| 135 | + async_echo_implementation{socket, buffer, |
| 136 | + async_echo_implementation::starting}, socket), |
| 137 | + token, error_code{}, 0); |
| 138 | + } |
| 139 | + `` |
| 140 | + The `async_compose` function has been changed to be a thin wrapper around |
| 141 | + `composed`. However, unlike `async_compose`, `composed` allows arguments to be |
| 142 | + passed to the stateful implementation when the operation is initiated. |
| 143 | +* Changed the `detached` completion token to work with asynchronous operations |
| 144 | + that have multiple completion signatures. |
| 145 | +* Changed `async_initiate` to allow an empty variadic list of completion |
| 146 | + signatures, which would indicate that an asynchronous operation never |
| 147 | + completes. |
| 148 | +* Added overloads of `async_initiate` that automatically deduce the type of |
| 149 | + the completion token. For example:[br] |
| 150 | + `` |
| 151 | + async_initiate(co_composed(/* ... */), detached, arg_1, arg_2); |
| 152 | + `` |
| 153 | + will deduce the token type from the argument `detached`. |
| 154 | +* Added `async_immediate` which implements a trivial asynchronous operation that |
| 155 | + completes immediately, using an associated immediate executor if available. |
| 156 | + It is intended for use within asynchronous compositions to make it easier to |
| 157 | + provide optimised immediate completion. |
| 158 | +* Updated the documentation for various asynchronous operations to specify |
| 159 | + immediate completion in terms of `async_immediate`. |
| 160 | +* Enabled SFINAE-based partial specialisation of the `associator` trait. |
| 161 | +* Changed to use the recycling allocator as the fallback for all operations, |
| 162 | + rather than calling the underlying recycling allocation helper functions |
| 163 | + directly. |
| 164 | +* Fixed the `deferred` implementation to ensure that the wrapped initiation |
| 165 | + function object's copyability is correctly propagated. |
| 166 | +* Fixed `experimental::coro` compatibility with clang 15. |
| 167 | +* Fixed deduction of a completion handler's default immediate executor type. |
| 168 | +* Don't use `ioctl` to modify the non-blocking mode on socket or descriptors |
| 169 | + that have been assigned, as they may originate from an external source. |
| 170 | +* Don't call `fcntl` with `F_SETFL` if the flags aren't changing. |
| 171 | +* Don't enable non-blocking mode when performing an `async_wait` operation on |
| 172 | + sockets or descriptors. |
| 173 | +* Update some composed operation examples to destroy the timer object before |
| 174 | + calling the completion handler. |
| 175 | +* Fix `read_until` regex support when `BOOST_ASIO_NO_DYNAMIC_BUFFER_V1` is |
| 176 | + defined. |
| 177 | + |
10 | 178 | [heading Asio 1.30.2 / Boost 1.85] |
11 | 179 |
|
12 | 180 | * Fixed `co_spawn` to correctly propagate exceptions resulting from cancellation |
|
0 commit comments