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

6 Commits

Author SHA1 Message Date
Christopher Kohlhoff
1afbc5c12b Update copyright notices. 2025-03-04 22:57:26 +11:00
Christopher Kohlhoff
c36d3ef338 Update copyright notices. 2024-03-05 07:51:17 +11:00
Christopher Kohlhoff
35e93e4e90 Update copyright notices. 2023-03-01 23:03:03 +11:00
Christopher Kohlhoff
4c216747dc Move deferred to the asio namespace.
This is no longer an experimental facility. The names deferred and
deferred_t have been temporarily retained as deprecated entities under
the asio::experimental namespace, for backwards compatibility.
2022-06-30 01:08:13 +10:00
Christopher Kohlhoff
ff58013a23 Update copyright notices. 2022-03-02 21:23:52 +11:00
Christopher Kohlhoff
0c340c786a Add experimental::deferred completion token.
The experimental::deferred completion token takes a call to an
asynchronous operation's initiating function and turns it into a
function object that accepts a completion token. For example:

  auto deferred_op =
    timer.async_wait(
      boost::asio::experimental::deferred);
  ...
  std::move(deferred_op)(
      [](std::error_code ec){ ... });

or

  auto deferred_op =
    timer.async_wait(
      boost::asio::experimental::deferred);
  ...
  std::future<void> =
    std::move(deferred_op)(
      boost::asio::use_future);

The deferred token also supports chaining, to create simple
compositions:

  auto deferred_op =
    timer.async_wait(
      boost::asio::experimental::deferred(
        [&](std::error_code ec)
        {
          timer.expires_after(
              std::chrono::seconds(1));

          return timer.async_wait(
              boost::asio::experimental::deferred);
        });
  ...
  std::future<void> = std::move(deferred_op)(boost::asio::use_future);
2021-07-01 10:52:01 +10:00