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

11 Commits

Author SHA1 Message Date
Christopher Kohlhoff
b6bd05ae45 Fixes compiler error "error: 'asio::posix' has not been declared" on Windows 10 with MSYS Mingw64 10.3.0 2021-10-17 11:02:22 +11:00
Christopher Kohlhoff
3a585b615e Add missing C++14 examples. 2021-08-04 21:16:59 +10:00
Christopher Kohlhoff
1c3c80d778 Make experimental::parallel_group compatible with C++14. 2021-07-01 10:52:01 +10: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
Christopher Kohlhoff
723982b867 Update copyright notices. 2021-02-25 08:29:05 +11:00
Christopher Kohlhoff
d98c116eb7 Update executor examples to use standard executor form. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
307690de7f Disable asio::executor if BOOST_ASIO_NO_TS_EXECUTORS is defined. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
fefe9a992e Use properties to track outstanding work against an io_context.
When using standard executors, work is tracked by requiring (or
preferring) an executor with the execution::outstanding_work.tracked
property. This replaces executor_work_guard and make_work_guard() with
code of the form

    asio::io_context io_context;
    auto work = asio::require(io_context.get_executor(),
        asio::execution::outstanding_work.tracked);

To explicitly reset work, store the returned work-tracking executor in
an any_io_executor object:

    asio::any_io_executor work
      = asio::require(io_context.get_executor(),
          asio::execution::outstanding_work.tracked);

and then assign an empty executor into the object when done:

    work = asio::any_io_executor();
2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
17ad33715a Add c++14 versions of executor examples. 2020-04-08 17:48:10 +10:00
Christopher Kohlhoff
4b552cfd5b Update copyright notices. 2020-04-07 11:15:42 +10:00
Christopher Kohlhoff
2f7af2e33c Update composed operations examples to use async_initiate and a new helper function async_compose. 2019-03-06 20:22:23 +11:00