2
0
mirror of https://github.com/boostorg/asio.git synced 2026-01-28 06:42:08 +00:00
Commit Graph

1164 Commits

Author SHA1 Message Date
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
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
Christopher Kohlhoff
558aeb8ea8 Version bump. 2021-04-07 17:32:29 +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
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
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
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
Christopher Kohlhoff
dc6e5669aa Remove deprecated file 'asio/impl/src.cpp'. 2021-02-25 08:37:47 +11:00
Christopher Kohlhoff
0b0b904883 Add std::hash specialisations for ip::basic_endpoint<>. 2021-02-25 08:37:47 +11:00
Christopher Kohlhoff
eed38fbe97 Add std::hash specialisations for IP addresses. 2021-02-25 08:35:32 +11:00
Christopher Kohlhoff
0182813698 Add ip::port_type type alias. 2021-02-25 08:33:48 +11:00
Christopher Kohlhoff
6106cd16d0 Add ip::scope_id_type type alias. 2021-02-25 08:33:38 +11:00
Christopher Kohlhoff
2c50cd1e42 Fix outstanding_work.tracked executor move assignment.
Move assignments for io_context and thread pool executors are missing
the logic present in copy assignments that finishes work on old contexts.
This causes the following example to hang:

int main()
{
    asio::static_thread_pool tp1{1},tp2{1};
    {
        auto work = asio::prefer(tp1.get_executor(),
            asio::execution::outstanding_work.tracked);
        work = asio::prefer(tp2.get_executor(),
            asio::execution::outstanding_work.tracked);
    }
    tp1.join();
    tp2.join();
}
2021-02-25 08:33:25 +11:00
Christopher Kohlhoff
be68fe37ed Make the thread_pool executor's execute, require, and query members private. 2021-02-25 08:33:12 +11:00
Christopher Kohlhoff
9f8835ee02 Make system_executor's execute, require, and query members private. 2021-02-25 08:33:00 +11:00
Christopher Kohlhoff
a820249201 Make the io_context executor's execute, require, and query functions private. 2021-02-25 08:32:51 +11:00
Christopher Kohlhoff
f2b56c196d Add friendship support to execution::occupancy property. 2021-02-25 08:32:40 +11:00