Commit Graph

2828 Commits

Author SHA1 Message Date
Christopher Kohlhoff
9b29e75a43 Add execution::receiver_invocation_error exception. 2020-06-30 22:04:39 +10:00
Christopher Kohlhoff
08af3e76bf Add execution::sender concepts and traits.
This change adds the concept:

  * execution::sender

the traits:

  * execution::sender_traits

and the tag type:

  * execution::sender_base

It also adds the following traits that correspond to the concepts:

  * execution::is_sender
2020-06-30 22:04:39 +10:00
Christopher Kohlhoff
4a5a7c5c0e Add execution::operation_state concept and execution::is_operation_state trait. 2020-06-30 22:04:39 +10:00
Christopher Kohlhoff
1a5fa59815 Add execution::start() customisation point object. 2020-06-30 22:04:39 +10:00
Christopher Kohlhoff
a2e718da65 Add execution::executor_of concept and execution::is_executor trait. 2020-06-30 22:04:39 +10:00
Christopher Kohlhoff
afff66d73e Add execution::receiver concepts and traits.
This change adds the concepts:

  * execution::receiver
  * execution::receiver_of

and the trait:

  * execution::is_nothrow_receiver_of

It also adds the following traits that correspond to the concepts:

  * execution::is_receiver
  * execution::is_receiver_of
2020-06-30 21:59:10 +10:00
Christopher Kohlhoff
dffb5d3e0b Add execution::set_value() customisation point object. 2020-06-30 17:00:56 +10:00
Christopher Kohlhoff
6830d6d530 Add execution::set_done() customisation point object. 2020-06-30 17:00:56 +10:00
Christopher Kohlhoff
ee7030548a Add execution::set_error() customisation point object. 2020-06-30 17:00:56 +10:00
Christopher Kohlhoff
726a33038e Require gcc 4.8 or later to enable certain C++11 features.
When building with gcc, require version 4.8 or later to enable Asio's
support for the following C++11 features:

  * rvalue references and move support
  * variadic templates
  * constexpr
  * decltype
  * standard type traits
2020-06-30 17:00:56 +10:00
Christopher Kohlhoff
d3c527f6eb Fix forward declaration guard used for any_executor. 2020-06-28 20:41:40 +10:00
Christopher Kohlhoff
eb7ffb9d22 Add standard executor support to basic_socket_acceptor accept() and async_accept(). 2020-06-26 15:42:40 +10:00
Christopher Kohlhoff
8b0eb52f8a More spawn() changes to support standard executors. 2020-06-26 11:28:51 +10:00
Christopher Kohlhoff
af58116845 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 10:58:24 +10:00
Christopher Kohlhoff
eff1ccd815 Add any_io_executor to forward declaration header 'netfwd.hpp'. 2020-06-24 19:02:31 +10:00
Christopher Kohlhoff
96987daee4 Documentation fix for the execution::allocator property. 2020-06-24 11:37:24 +10:00
Christopher Kohlhoff
574227a859 Regenerate documentation. 2020-06-23 11:39:36 +10:00
Christopher Kohlhoff
fa2a1c80c4 Add new execution facilities to quick reference. 2020-06-23 11:07:35 +10:00
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