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

1574 Commits

Author SHA1 Message Date
Christopher Kohlhoff
aca5723268 Change to co_spawn to dispatch first and only post if the coroutine did not context-switch. 2021-06-11 13:36:22 +10:00
Christopher Kohlhoff
3ba403d306 Invoke completion handlers as rvalue references. 2021-06-05 17:43:31 +10:00
Christopher Kohlhoff
aa311e118c Add experimental::as_tuple completion token adapter.
The as_tuple completion token adapter can be used to specify that the
completion handler arguments should be combined into a single tuple
argument.

The as_tuple adapter may be used in conjunction with use_awaitable and
structured bindings as follows:

    auto [e, n] = co_await socket.async_read_some(
        asio::buffer(data), as_tuple(use_awaitable));

Alternatively, it may be used as a default completion token like so:

    using default_token = as_tuple_t<use_awaitable_t<>>;
    using tcp_socket = default_token::as_default_on_t<tcp::socket>;
    // ...
    awaitable<void> do_read(tcp_socket socket)
    {
      // ...
      auto [e, n] = co_await socket.async_read_some(asio::buffer(data));
      // ...
    }
2021-06-05 17:43:31 +10:00
Christopher Kohlhoff
059c40e935 Add initiate-based completion token support to bind_executor. 2021-06-05 17:43:31 +10:00
Christopher Kohlhoff
99114f2b5a Use associator trait in buffered_write_stream implementation. 2021-06-05 17:43:31 +10:00
Christopher Kohlhoff
bb6dd90ac4 Use associator trait in buffered_read_stream implementation. 2021-06-05 17:43:31 +10:00
Christopher Kohlhoff
477d31f4d0 Use associator trait in spawn implementation. 2021-06-05 17:43:31 +10:00
Christopher Kohlhoff
245fc00527 Add associator trait specialisation for async_compose implementation. 2021-06-05 17:43:31 +10:00
Christopher Kohlhoff
2dd048a3c3 Use associator trait in ssl::stream implementation. 2021-06-05 17:43:31 +10:00
Christopher Kohlhoff
32cdabd9d1 Use associator trait in async_connect implementation. 2021-06-05 17:43:31 +10:00
Christopher Kohlhoff
7d48f439fa Use associator trait in async_write_at implementation. 2021-06-05 17:43:31 +10:00
Christopher Kohlhoff
3c5d092969 Use associator trait in async_write implementation. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
50f31ae82f Use associator trait in async_read_until implementation. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
d2b7968df4 Use associator trait in async_read_at implementation. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
a9497b28f3 Use associator trait in async_read implementation. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
60bd44c3f9 Use associator trait in detail::bind_handler implementation. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
41f180f052 Use associator trait in redirect_error implementation. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
793f6e25e3 Use associator trait in experimental::as_single implementation. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
3bef12eea4 Use associator trait in bind_executor implementation. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
e618857ff3 Add associator trait.
The associator trait is used to generically forward associators, such as
associated_executor<> and associated_allocator<>, through intermediate
completion handlers. For example:

    template <typename Handler>
    struct intermediate_handler
    {
      Handler handler_;

      template <typename... Args>
      void operator()(Args&... args)
      {
        // ...
      }
    };

    namespace boost {
    namespace asio {

      template <
          template <typename, typename> class Associator,
          typename Handler,
          typename DefaultCandidate>
      struct associator<
          Associator,
          intermediate_handler<Handler>,
          DefaultCandidate>
      {
        using type =
          typename Associator<Handler, DefaultCandidate>::type;

        static type get(
            const intermediate_handler<Handler>& h,
            const DefaultCandidate& c = DefaultCandidate()) noexcept
        {
          return Associator<Handler, DefaultCandidate>::get(
              h.handler_, c);
        }
      };

    } // namespace asio
    } // namespace boost
2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
9dfb1ab677 Ensure reactor headers include their dependencies. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
a3b94b6760 Use memset rather than assignment to fill UNIX domain addresses with NULs. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
8df5d67906 Initialise strings used for reverse name resolution. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
8a81ff990a Apply nodiscard attribute to awaitable<>. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
26d1132d3d Increase number of cached memory slots for default recycling allocator.
The number of per-thread slots may be configured at compile time by
defining ASIO_RECYCLING_ALLOCATOR_CACHE_SIZE to a non-negative integer.
If not defined, the default recycling allocator uses two slots.
2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
d9fffd9bce Regenerate platform macros documentation. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
bb8b2e2832 Make allocators respect alignment requirements.
This is important when completion handlers contain over-aligned members,
for example when captured in a lambda.

This uses operator new() with alignment support if available,
and falls back to Boost Align (again, if available).
2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
1bad8e0dba Add associated_executor and associated_allocator specialisations for std::reference_wrapper. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
1b161b5d91 Add constraints to use_awaitable_t::executor_with_default's constructor to prevent template instantiation recursion. 2021-06-05 17:43:30 +10:00
Christopher Kohlhoff
93fa0b53dd Fix any_io_executor equality operators. 2021-06-05 17:43:30 +10:00
Peter Dimov
c0b98039e4 Add CMakeLists.txt 2021-06-02 04:29:33 +03:00
Christopher Kohlhoff
558aeb8ea8 Version bump. 2021-04-07 17:32:29 +10:00
Christopher Kohlhoff
f807ab9aec Revision history. 2021-04-07 17:32:07 +10:00
Christopher Kohlhoff
efe2bc2051 Regenerate documentation. 2021-04-06 19:24:52 +10:00
Christopher Kohlhoff
6bd1e1932a Prevent blocking.always from being used with strand<>.
Previously, calling `require(E, blocking.always)` on a strand E compiled
but produced incorrect behaviour. Now, `require(E, blocking.always)`
will no longer compile. Furthermore, when used with an always-blocking
inner executor, the strand will report its blocking property as
blocking.possibly.
2021-04-06 19:22:59 +10:00
Christopher Kohlhoff
06213e7378 Tell doxygen about the BOOST_ASIO_NOEXCEPT_IF macro. 2021-04-06 19:22:20 +10:00
Christopher Kohlhoff
cfce966532 Fix detection of defaulted template arguments on functions with MSVC. 2021-04-06 19:20:24 +10:00
Christopher Kohlhoff
c77f3b603b Compatibility with boost regex v5. 2021-03-15 11:25:28 +11:00
Christopher Kohlhoff
3e88870e34 Exclude any_io_executor traits from documentation. 2021-03-04 15:45:56 +11:00
Christopher Kohlhoff
c970aba69b Use escaped names in index entries. 2021-03-04 15:45:56 +11:00
Christopher Kohlhoff
83503a2370 Regenerate documentation. 2021-03-04 10:00:02 +11:00
Christopher Kohlhoff
3be4dad057 Use separate SFINAE constraints for read_until and async_read_until. 2021-03-04 09:49:09 +11:00
Christopher Kohlhoff
6d9a45f5ce Use separate SFINAE constraints for write and async_write. 2021-03-04 09:48:57 +11:00
Christopher Kohlhoff
03a649f720 Use separate SFINAE constraints for read and async_read. 2021-03-04 09:48:44 +11:00
Christopher Kohlhoff
787d32a417 Add index entries for classes. 2021-03-04 09:09:00 +11:00
Edward Diener
5c3df4161d Add "cxxstd" json field.
The "cxxstd" json field is being added to each Boost library's meta json
information for libraries in order to specify the minumum C++ standard
compilation level. The value of this field matches one of the values for
'cxxstd' in Boost.Build. The purpose of doing this is to provide
information for the Boost website documentation for each library which
will specify the minimum C++ standard compilation that an end-user must
employ in order to use the particular library. This will aid end-users
who want to know if they can successfully use a Boost library based on
their C++ compiler's  compilation level, without having to search the
library's documentation to find this out.
2021-03-04 09:02:43 +11:00
Christopher Kohlhoff
96a88465fc Use constraint<> rather than enable_if<> in public SFINAE-constrained functions. 2021-03-04 08:48:08 +11:00
Christopher Kohlhoff
739109cacb The executor must be copied when an I/O object is move-assigned.
The moved-from I/O object needs to be left in the same state as if
constructed with a valid executor but without a resource.
2021-03-04 08:47:58 +11:00
Christopher Kohlhoff
c002284dd8 Ensure call_stacks are accessed only from implementation files. 2021-03-04 08:47:45 +11:00
Christopher Kohlhoff
7f0b42653d Change any_io_executor to a 'strong typedef'-style class. 2021-02-25 08:37:47 +11:00