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

966 Commits

Author SHA1 Message Date
Christopher Kohlhoff
4ff016c025 More spawn() changes to support standard executors. 2020-06-26 15:45:55 +10:00
Christopher Kohlhoff
e6451028c3 Use a different target function table depending on the blocking property.
The any_executor class stores the state of the target's blocking
property to enable an optimisation in any_executor::execute(), i.e. if
the target executor has the property blocking.always, we can avoid a
memory allocation when type-erasing the submitted function object. With
this change the any_executor now "stores" the blocking property as a
different target function table, rather than as a separate member of
type blocking_t. This reduces the size of an any_executor by 8 bytes on
x86-64.
2020-06-26 15:44:47 +10:00
Christopher Kohlhoff
e2cde117c0 Add any_io_executor to forward declaration header 'netfwd.hpp'. 2020-06-24 20:07:00 +10:00
Christopher Kohlhoff
c06347a602 Documentation fix for the execution::allocator property. 2020-06-24 11:42:43 +10:00
Christopher Kohlhoff
242b3ee482 Disable executor_work_guard if BOOST_ASIO_NO_TS_EXECUTORS is defined. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
bb547e1a44 Disable io_context::strand if BOOST_ASIO_NO_TS_EXECUTORS is defined. 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
5488c28a3b 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, BOOST_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:08:25 +10:00
Christopher Kohlhoff
9557f87ae4 Increase emulated variadic template support to 8 parameters. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
50ab1cb652 Add standard executor support to spawn. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
166e773815 Add standard executor support to executor_work_guard. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
34c898b27b Add standard executor support to use_future. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
0d9bbf613c Add standard executor support to co_spawn. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
e3d6bcfac9 Add standard executor support to async_compose. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
20d2c5e806 Add standard executor support to bind_executor. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
75c405d249 Add standard executor support to get_associated_executor. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
3fc1f87a2b Add standard executor support to strand<>. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
bbe07663c0 Add standard executor support to async I/O operations. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
0e0a38df5f Add standard executor support to post(), dispatch(), and defer(). 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
95eb4eb16c Update system_executor to standard executor form. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
d56b243026 io_context.hpp 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
121e8aa610 Update io_context::executor_type to standard executor form. 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
65dfb99273 threadpool 2020-06-23 11:08:25 +10:00
Christopher Kohlhoff
0a662cb309 Add static_thread_pool (as thread_pool in standard executor form). 2020-06-23 10:36:49 +10:00
Christopher Kohlhoff
9a743f078e Add "asio/execution.hpp" convenience header. 2020-06-23 10:36:49 +10:00
Christopher Kohlhoff
ac7e13f51b Add execution::context_as property adapter. 2020-06-23 10:36:49 +10:00
Christopher Kohlhoff
d2cb3bbdc6 Add execution::prefer_only property adapter. 2020-06-23 10:36:49 +10:00
Christopher Kohlhoff
3783cc1093 Add execution::any_executor. 2020-06-23 10:36:49 +10:00
Christopher Kohlhoff
ec2f491be0 Add execution::context property. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
f1b382b32b Add execution::occupancy property. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
f080c01965 Add execution::allocator property. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
74a13e9920 Add execution::bulk_guarantee property. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
3f90ca5cb2 Add execution::blocking_adaptation property. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
bfeec7cd2b Add execution::relationship property. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
3d5209fa19 Add execution::mapping property. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
50e3e1798d Add execution::outstanding_work property. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
36686f07a1 Add execution::blocking property. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
834c5bdc8a Add execution::executor concept and execution::is_executor trait. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
f6cfbc3982 Add execution::execute() customisation point object. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
e3be5fe444 Add execution::invocable_archetype. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
fac4056517 Add properties implementation. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
0d0e36be72 Fix compile error on MSVC 2017. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
7dad754997 Don't default the IoExecutor in detail::handler_work<>. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
24bb388fb9 Change detail::completion_handler<> to use an I/O executor. 2020-06-22 23:16:39 +10:00
Christopher Kohlhoff
59d6542f2a 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-22 23:16:39 +10:00
Christopher Kohlhoff
deb0b72619 Change detail::handler_work<> to use an RAII-based approach. 2020-06-22 21:31:21 +10:00
Christopher Kohlhoff
3122e49c63 Avoid touching errors when we get a 0-length receive on a non-stream. 2020-06-22 21:30:58 +10:00
Christopher Kohlhoff
7f41b8ed6b 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-22 21:29:40 +10:00
Christopher Kohlhoff
bbe2dbe3e8 Add single-buffer optimisation for recvfrom and sendto.
When we can determine at compile time that the user has supplied a
single buffer, use recvfrom/sendto rather than recvmsg/sendmsg, as the
former system calls can be faster.
2020-06-22 21:29:07 +10:00