Commit Graph

2760 Commits

Author SHA1 Message Date
Christopher Kohlhoff
68879b4fa3 Add new executor type requirements. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
caa8764b02 Documentation generation tweaks for new execution facilities. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
93a753bb27 Update executor examples to use standard executor form. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
ddffd55106 Disable executor_work_guard if ASIO_NO_TS_EXECUTORS is defined. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
36e43c7e40 Disable io_context::strand if ASIO_NO_TS_EXECUTORS is defined. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
e0a3173e51 Disable asio::executor if ASIO_NO_TS_EXECUTORS is defined. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
390673c322 Use properties to obtain an executor's execution context.
Rather than using a context() member function, query the executor's
execution::context_t property to obtain its associated execution
context:

    asio::execution_context& context
      = asio::query(my_io_executor, asio::execution::context);
2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
165ea38ac8 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:07:35 +10:00
Christopher Kohlhoff
408168d7d4 Use an any_executor<> as the polymorphic executor for I/O objects.
The asio::any_io_executor type alias has been added as the default
runtime-polymorphic executor for all I/O objects. This type alias points
to the execution::any_executor<> template with a set of supportable
properties specified for use with I/O.

If required for backward compatibility, ASIO_USE_TS_EXECUTOR_AS_DEFAULT
can be defined. This changes the asio::any_io_executor type alias to
point to the Networking TS-based runtime-polymorphic asio::executor
class instead.
2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
172c610da0 Increase emulated variadic template support to 8 parameters. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
3ae6c68443 Add standard executor support to spawn. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
b45ad1469f Add standard executor support to executor_work_guard. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
386666d9cb Add standard executor support to use_future. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
4658609599 Add standard executor support to co_spawn. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
01c20f6365 Add standard executor support to async_compose. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
31a18097a1 Add standard executor support to bind_executor. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
76430ded78 Add standard executor support to get_associated_executor. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
3757330a83 Add standard executor support to strand<>. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
a3f4e1c303 Add standard executor support to async I/O operations. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
c7f68caef3 Add standard executor support to post(), dispatch(), and defer(). 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
d25a180430 Update system_executor to standard executor form. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
4cd27fffd4 Update io_context::executor_type to standard executor form. 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
e61acbcb42 Add static_thread_pool (as thread_pool in standard executor form). 2020-06-23 11:07:35 +10:00
Christopher Kohlhoff
b47fdccb6a Add "asio/execution.hpp" convenience header. 2020-06-23 10:25:15 +10:00
Christopher Kohlhoff
ed4530ef79 Add execution::context_as property adapter. 2020-06-23 10:25:15 +10:00
Christopher Kohlhoff
b975aa75c8 Add execution::prefer_only property adapter. 2020-06-23 10:25:15 +10:00
Christopher Kohlhoff
6505157d2e Add execution::any_executor. 2020-06-23 10:25:15 +10:00
Christopher Kohlhoff
a13604cf8d Add execution::context property. 2020-06-22 22:48:33 +10:00
Christopher Kohlhoff
b88245283a Add execution::occupancy property. 2020-06-22 22:48:33 +10:00
Christopher Kohlhoff
8adc6d9096 Add execution::allocator property. 2020-06-22 22:48:33 +10:00
Christopher Kohlhoff
47b5692553 Add execution::bulk_guarantee property. 2020-06-22 22:48:33 +10:00
Christopher Kohlhoff
4a899105c6 Add execution::blocking_adaptation property. 2020-06-22 22:48:33 +10:00
Christopher Kohlhoff
d0ffa51c86 Add execution::relationship property. 2020-06-22 22:48:33 +10:00
Christopher Kohlhoff
ead0aa154f Add execution::mapping property. 2020-06-22 22:48:33 +10:00
Christopher Kohlhoff
1b6018accd Add execution::outstanding_work property. 2020-06-22 22:48:33 +10:00
Christopher Kohlhoff
535b6210e8 Add execution::blocking property. 2020-06-22 22:48:33 +10:00
Christopher Kohlhoff
a0ca290c6d Add execution::executor concept and execution::is_executor trait. 2020-06-22 22:48:33 +10:00
Christopher Kohlhoff
ec3ec3ec16 Add execution::execute() customisation point object. 2020-06-22 22:48:33 +10:00
Christopher Kohlhoff
f14dbd716c Add execution::invocable_archetype. 2020-06-22 22:42:41 +10:00
Christopher Kohlhoff
7bdae05db9 Add properties implementation. 2020-06-22 20:04:50 +10:00
Christopher Kohlhoff
62102ebb59 Don't treat gcc 6 builds as supporting c++14. 2020-06-22 19:10:48 +10:00
Christopher Kohlhoff
d2c55c2152 Add ability to run function templates as tests. 2020-06-22 19:10:48 +10:00
Christopher Kohlhoff
ebd426cd36 Fix copy/paste errors in "Networking TS compatibility" docs. 2020-06-22 19:10:48 +10:00
Christopher Kohlhoff
5a30d4c939 Fix compile error on MSVC 2017. 2020-06-22 19:02:24 +10:00
Christopher Kohlhoff
260afe3a7b Don't default the IoExecutor in detail::handler_work<>. 2020-06-19 20:43:22 +10:00
Christopher Kohlhoff
ccdf9fa3d4 Change detail::completion_handler<> to use an I/O executor. 2020-06-19 20:43:22 +10:00
Christopher Kohlhoff
6080760b80 Test for native I/O executors in detail::handler_work<>.
The detail::io_object_executor wrapper has been removed, and the job of
detecting, and optimising for, native I/O executors is now performed
directly in the detail::handler_work implementation.
2020-06-19 20:43:22 +10:00
Christopher Kohlhoff
a5401f7eee Change detail::handler_work<> to use an RAII-based approach. 2020-06-19 11:32:49 +10:00
Christopher Kohlhoff
f64f916489 Avoid touching errors when we get a 0-length receive on a non-stream. 2020-06-15 17:54:01 +10:00
Christopher Kohlhoff
480a336189 Add single-buffer optimisation for descriptor read and write.
When we can determine at compile time that the user has supplied a
single buffer, use read/write rather than readv/writev, as the former
system calls can be faster.
2020-06-15 17:53:54 +10:00