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

382 Commits

Author SHA1 Message Date
Christopher Kohlhoff
edbde3cdce Disable deprecated messages when building tests. 2025-11-04 23:48:36 +11:00
Christopher Kohlhoff
85a9eb155e Add default completion token to 1-arg overloads of dispatch, post and defer. 2025-11-04 23:44:14 +11:00
Christopher Kohlhoff
f49a0add53 Add redirect_disposition completion token adapter. 2025-11-04 23:42:51 +11:00
Christopher Kohlhoff
893e569bbd Change inline_or_executor to use blocking.always by default. 2025-10-30 20:41:07 +11:00
Christopher Kohlhoff
5fa261e86d Add inline_or_executor<> and inline_or(). 2025-10-30 08:28:04 +11:00
Christopher Kohlhoff
84c45dbe48 Add inline_executor. 2025-10-29 22:58:47 +11:00
Christopher Kohlhoff
82c9b858c8 Add execution::inline_exception_handling property. 2025-10-29 22:57:58 +11:00
Christopher Kohlhoff
77d09d001d Add dispatch, post and defer overloads that run a function before completion. 2025-10-29 22:56:44 +11:00
Christopher Kohlhoff
cd2b1b37ff Fix compilation errors in channel<void(error_code)>. 2025-08-05 08:09:27 +10:00
Christopher Kohlhoff
7e51960177 Make co_spawn adhere to async op requirement for non-reentrant completion.
Previously, co_spawn-ing the following coroutine:

  awaitable<void> foo()
  {
    co_await dispatch(use_awaitable);
  }

would result in a call to the completion handler from within co_spawn.
2025-08-05 08:09:27 +10:00
Christopher Kohlhoff
751cec5701 Make BOOST_ASIO_CONCURRENCY_HINT_SAFE consistent with io_context default constructor.
Also fixed docs for BOOST_ASIO_CONCURRENCY_HINT_UNSAFE_IO to reflect
that registration locking is still enabled.
2025-07-09 09:12:53 +10:00
Christopher Kohlhoff
6b4bcb9dd3 Add allocator support to execution contexts. 2025-07-02 20:43:27 +10:00
Christopher Kohlhoff
882f4631f9 Fix ambiguous overloads when using std::span with asio::buffer. 2025-04-01 22:02:47 +11:00
Christopher Kohlhoff
1afbc5c12b Update copyright notices. 2025-03-04 22:57:26 +11:00
Christopher Kohlhoff
0ca957b83a Remove unused variables in unit test. 2024-12-03 08:40:43 +11:00
Christopher Kohlhoff
edbc200c76 Add disposition support to spawn(). 2024-11-06 07:55:59 +11:00
Christopher Kohlhoff
b38b6d5aee Update async op archetypes to use async_initiate. 2024-11-06 07:55:46 +11:00
Christopher Kohlhoff
7955d57329 Add unit test for spawn(). 2024-11-06 07:55:31 +11:00
Rene Rivera
a31cca5ec1 Add support for modular build structure. 2024-10-31 21:42:07 +11:00
Christopher Kohlhoff
bbda620590 Add asio::config.
The asio::config class provides access to configuration variables that
are associated with an execution context. The class is intended for use
by asio internals, or by libraries or user-provided abstractions that
build on top of asio. These configuration variables will typically be
used to fine tune behaviour, such as enabling or disabling certain
optimisations.

When constructing an execution context, such as an io_context, the
caller may optionally pass a service_maker to install a concrete
configuration service into the context. For example:

  asio::io_context ctx{asio::config_from_env{}};

The configuration variables' values are accessed by using the
asio::config class, passing a section, key and default value:

  asio::config cfg{ctx};
  bool enable_locking = cfg.get("scheduler", "locking", true);

The initial set of configuration variables recognised by the asio
internals correspond to the concurrency hint and its special values:

  "scheduler" / "concurrency_hint" (int)
  "scheduler" / "locking" (bool)
  "reactor" / "registration_locking" (bool)
  "reactor" / "io_locking" (bool)
2024-10-30 23:01:37 +11:00
Christopher Kohlhoff
dc8dc3e192 Add execution_context::service_maker abstract base class.
A service_maker is an object that is passed to an execution context's
constructor, and allows services to be added at context construction
time. Additional constructor overloads have been added to io_context and
thread_pool that accept a service_maker. For example:

  class my_service_maker : public execution_context::service_maker
  {
  public:
    void make(execution_context& ctx) override
    {
      make_service<my_service>(ctx);
    }
  };

  io_context ctx{my_service_maker{}};
2024-10-30 23:00:28 +11:00
Christopher Kohlhoff
4b4487cbfe Add disposition_traits and no_error_t.
The disposition concept describes types that can be used to test whether
an asynchronous operation completed without error. This includes
error_code and exception_ptr, but can be extended to user types via
specialisation of the disposition_traits class template.

Generic code that is intended to work in terms of dispositions should
not use asio::disposition_traits directly, but instead:

* Test whether a disposition holds no error by comparing against
  asio::no_error (of type asio::no_error_t).

* Use asio::to_exception_ptr to convert a disposition to a
  std::exception_ptr.

* Use asio::throw_exception to throw an exception that corresponds to
  the disposition, after first testing the disposition against
  asio::no_error.

The asio::use_future completion token and asio::awaitable<>-based
coroutines have been updated to work generically in terms of
dispositions.
2024-10-30 22:59:32 +11:00
Christopher Kohlhoff
b32b66c32d Add buffer_sequence_begin/end overloads for types that are convertible to buffers. 2024-10-23 21:21:52 +11:00
Christopher Kohlhoff
f14d0b2c60 Allow buffers to be implicitly constructed from spans. 2024-10-23 21:21:39 +11:00
Christopher Kohlhoff
6e4171839e Deprecate deadline_timer and associated types. 2024-10-23 21:21:20 +11:00
Christopher Kohlhoff
bc417934ec Deprecate basic_io_object. 2024-10-23 21:21:02 +11:00
Christopher Kohlhoff
d519865824 Remove deprecated io_context::service member functions. 2024-10-23 21:19:38 +11:00
Christopher Kohlhoff
7d1aac2ffd Remove deprecated function buffer_cast. 2024-10-23 21:12:02 +11:00
Christopher Kohlhoff
534a48c0d5 Remove deprecated classes const_buffers_1 and mutable_buffers_1. 2024-10-23 21:10:47 +11:00
Christopher Kohlhoff
a69e0e1997 Remove deprecated ip::basic_resolver functions and types. 2024-10-23 21:09:42 +11:00
Christopher Kohlhoff
c0d1cfce77 Remove deprecated ip::address member functions. 2024-10-23 21:09:25 +11:00
Christopher Kohlhoff
7d86e12750 Remove deprecated ip::address_v6 member functions. 2024-10-23 21:09:15 +11:00
Christopher Kohlhoff
60b86035b3 Remove deprecated ip::address_v4 member functions. 2024-10-23 21:08:58 +11:00
Christopher Kohlhoff
4a2d50655d Move async_immediate to a public header. 2024-07-08 23:24:05 +10:00
Christopher Kohlhoff
5c01494f70 Promote co_composed to the asio namespace. 2024-07-02 07:54:20 +10:00
Christopher Kohlhoff
c4ef84506e Add composed.
The composed function creates an initiation function object from a stateful
implementation. It is similar to co_composed, but for regular function objects
rather than C++20 coroutines.

For example:

  struct async_echo_implementation
  {
    tcp::socket& socket_;
    boost::asio::mutable_buffer buffer_;
    enum { starting, reading, writing } state_;

    template <typename Self>
    void operator()(Self& self,
        boost::system::error_code error,
        std::size_t n)
    {
      switch (state_)
      {
      case starting:
        state_ = reading;
        socket_.async_read_some(
            buffer_, std::move(self));
        break;
      case reading:
        if (error)
        {
          self.complete(error, 0);
        }
        else
        {
          state_ = writing;
          boost::asio::async_write(socket_, buffer_,
              boost::asio::transfer_exactly(n),
              std::move(self));
        }
        break;
      case writing:
        self.complete(error, n);
        break;
      }
    }
  };

  template <typename CompletionToken>
  auto async_echo(tcp::socket& socket,
      boost::asio::mutable_buffer buffer,
      CompletionToken&& token)
  {
    return boost::asio::async_initiate<CompletionToken,
      void(boost::system::error_code, std::size_t)>(
        boost::asio::composed(
          async_echo_implementation{socket, buffer,
            async_echo_implementation::starting}, socket),
        token, boost::system::error_code{}, 0);
  }

The async_compose function has been changed to be a thin wrapper around
composed. However, unlike async_compose, composed allows arguments to be passed
to the stateful implementation when the operation is initiated.
2024-07-02 07:34:51 +10:00
Christopher Kohlhoff
e5a93b5e15 Permit an empty variadic list of completion signatures.
An asynchronous operation having no completion signatures signifies that the
operation never completes.
2024-07-02 07:31:07 +10:00
Christopher Kohlhoff
c83ee18458 Clean up spurious white space. 2024-06-27 23:01:17 +10:00
Christopher Kohlhoff
fc1bdcb2d6 Fix experimental::coro compatibility with Apple clang 15. 2024-06-26 22:49:38 +10:00
Christopher Kohlhoff
6a817c4374 Add cancel_at and cancel_after completion token adapters. 2024-06-26 22:46:51 +10:00
Christopher Kohlhoff
d5791b2afb Allow bind_allocator to be used as a partial completion token. 2024-06-26 22:43:49 +10:00
Christopher Kohlhoff
e3e624448f Allow bind_cancellation_slot to be used as a partial completion token. 2024-06-26 22:43:31 +10:00
Christopher Kohlhoff
78e00cd217 Allow bind_immediate_executor to be used as a partial completion token. 2024-06-26 22:43:20 +10:00
Christopher Kohlhoff
85535cec19 Allow bind_executor to be used as a partial completion token. 2024-06-26 22:43:11 +10:00
Christopher Kohlhoff
907b608ad2 Allow redirect_error to be used as a partial completion token. 2024-06-26 22:42:34 +10:00
Christopher Kohlhoff
5eb0dfcf59 Allow as_tuple to be used as a partial completion token. 2024-06-26 22:42:19 +10:00
Christopher Kohlhoff
6ce241c2bb Make asio::deferred the default completion token. 2024-06-26 22:41:56 +10:00
Christopher Kohlhoff
ca545cb4b4 Add is_connect_condition and use to disambiguate connect and async_connect overloads. 2024-06-26 22:41:12 +10:00
Christopher Kohlhoff
2a6674ea18 Ensure a cancelled co_spawn passes the exception to the completion handler. 2024-04-02 22:30:54 +11:00
Christopher Kohlhoff
ac35960f03 Add missing #include to parallel_group header. 2024-03-06 00:52:05 +11:00