Commit Graph

2666 Commits

Author SHA1 Message Date
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
Christopher Kohlhoff
75fd0ca1b7 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-15 17:53:54 +10:00
Christopher Kohlhoff
cebecc56ae Remove unnecessary allocator_ member. 2020-06-15 17:15:48 +10:00
Christopher Kohlhoff
3b7d655cc9 On success, zero only the error_code value. 2020-06-15 17:15:48 +10:00
Christopher Kohlhoff
8077f65047 Use a cached success error code to avoid touching the category singleton. 2020-06-15 17:15:48 +10:00
Christopher Kohlhoff
8638b3539f Return earlier on success in send/receive and read/write operations. 2020-06-15 17:15:48 +10:00
Christopher Kohlhoff
288e378038 Access errno only when on the error path. 2020-06-15 17:15:48 +10:00
Christopher Kohlhoff
3582b06196 Add single-buffer optimisation for send and receive.
When we can determine at compile time that the user has supplied a
single buffer, use send/recv rather than sendmsg/recvmsg, as the former
system calls can be faster.
2020-06-12 11:17:44 +10:00
Christopher Kohlhoff
0687857ec1 Specify memory ordering when reference counting with standard atomics. 2020-06-12 10:50:04 +10:00
Christopher Kohlhoff
716ab8d22c Add some gcc 9 targets on travis. 2020-06-08 11:55:05 +10:00
Christopher Kohlhoff
d6c41e33e3 Explicitly disable copy construction in io_context and thread_pool. 2020-06-08 11:54:35 +10:00
Christopher Kohlhoff
0d5dc52c81 Use alternate boost download location. 2020-06-08 10:49:04 +10:00
Christopher Kohlhoff
16695f2777 Add --with-boost=system option.
This configure option causes the build to define the necessary
preprocessor macros to use boost, but does not alter the include or
library paths.
2020-06-08 10:25:09 +10:00
Christopher Kohlhoff
67fc1fed38 Mark the asio_handler_allocate/deallocate hooks as deprecated.
Compiling an application with ASIO_NO_DEPRECATED will now trigger a
compile error if any handler implements the asio_handler_allocate or
asio_handler_deallocate hooks.
2020-06-07 12:13:20 +10:00
Christopher Kohlhoff
81964e87f4 Mark the asio_handler_invoke hook as deprecated.
Compiling an application with ASIO_NO_DEPRECATED will now trigger a
compile error if any handler implements the asio_handler_invoke hook.
2020-06-07 12:13:20 +10:00
Christopher Kohlhoff
8c4d117a41 Update socks4 example to use non-deprecated resolver interface. 2020-06-06 16:52:58 +10:00
Christopher Kohlhoff
73625e8e32 Another tutorial fix to reflect current resolver API. 2020-06-03 21:31:50 +10:00
Christopher Kohlhoff
cfa430c8de Fix examples in read_until() documentation. 2020-06-03 19:22:10 +10:00
Christopher Kohlhoff
91df1a56d3 Changes for clang-based Embarcadero C++ compilers. 2020-06-03 19:21:34 +10:00
Christopher Kohlhoff
62d0cf33a7 Add unit test for thread_pool. 2020-05-30 12:10:47 +10:00
Christopher Kohlhoff
8f48589ff1 Add missing .gitignore entry for io_context_strand. 2020-05-30 12:03:32 +10:00
Christopher Kohlhoff
c409c80105 Fix parameter names in co_spawn documentation. 2020-05-30 11:46:29 +10:00
Christopher Kohlhoff
c511ca8501 Remove spurious 'Executor' base class from executor_binder implementation.
This appears to have been left behind by an incomplete change made in
commit a1f71f95c4.
2020-05-30 11:40:59 +10:00
Christopher Kohlhoff
50e2c8c88e Correctly stop "own thread" in service destructor.
This change fixes the scheduler and win_iocp_io_context destructors so
that they correctly stop the internal thread that was created in the
constructor. This fixes a deadlock that can occur when two threads
concurrently attempt to create the first I/O object associated with a
non-native I/O execution context.
2020-05-30 11:40:59 +10:00
Christopher Kohlhoff
71324d7cbb Add as_default_on() and as_default_on_t<> to asio::detached_t. 2020-05-30 11:40:58 +10:00
Christopher Kohlhoff
2898a5e0fa Add converting move construction and assignment to basic_waitable_timer.
This change enables move construction and assignment between different timer
types, provided the executor types are convertible. For example:

  basic_waitable_timer<
      clock_type,
      traits_type,
      io_context::executor_type
    > timer1(my_io_context);

  basic_waitable_timer<
      clock_type,
      traits_type,
      executor // polymorphic wrapper
    > timer2(std::move(timer1));
2020-05-26 08:15:57 +10:00
Christopher Kohlhoff
3c63a53921 Add converting constructor to use_awaitable_t::executor_with_default. 2020-05-26 07:53:33 +10:00
Christopher Kohlhoff
bb39e3458f Add overloads of co_spawn that launch an awaitable.
This change allows us to write:

 co_spawn(executor,
     echo(std::move(socket)),
     detached);

instead of:

 co_spawn(executor,
     [socket = std::move(socket)]() mutable
     {
       return echo(std::move(socket));
     },
     detached);
2020-05-25 15:42:30 +10:00
Christopher Kohlhoff
d40e5ba690 Add handlertree.pl tool.
The handlertree.pl script filters handler tracking output to include
only those events in the tree that produced the nominated handlers. For
example, to filter the output to include only the events associated with
handlers 123, 456, and their predecessors:

  cat output.txt | perl handlertree.pl 123 456

or:

  perl handlertree.pl 123 456 < output.txt

This script may be combined with handerlive.pl and handlerviz.pl to
produce a graph of the "live" asynchronous operation chains. For
example:

  cat output.txt | perl handlertree.pl `perl handlerlive.pl output.txt` | perl handlerviz.pl | dot -Tsvg > output.svg
2020-05-16 20:28:33 +10:00
Christopher Kohlhoff
7859c3acb9 Add handlerlive.pl tool.
The handlerlive.pl script processes handler tracking output to produce a
list of "live" handlers, namely those that are associated with pending
asynchronous operations, as well as handlers that are currently executing.

To use:

  cat output.txt | perl handlerlive.pl

or:

  perl handerlive.pl < output.txt

or:

  perl handlerlive.pl output.txt
2020-05-16 20:20:00 +10:00
Christopher Kohlhoff
0f7b5b8307 Various improvements to the handlerviz.pl tool.
* Add nodes for pending handlers at bottom of graph, outlined in red.
* Display source location in a tooltip on the edge label (for SVG).
* Use invisible nodes to enforce order to keep related control flow vertical.
2020-05-16 20:19:52 +10:00
Christopher Kohlhoff
c747142662 Add missing handler tracking include. 2020-05-15 08:57:44 +10:00
Christopher Kohlhoff
685aa84c2b Fix awaitable_handler specialisation for empty completion signatures. 2020-05-14 13:13:38 +10:00
Christopher Kohlhoff
74c19cdab6 Fix search/replace damage in comments. 2020-05-14 13:13:38 +10:00
Christopher Kohlhoff
11eed2fb3a Add source location support to handler tracking.
The ASIO_HANDLER_LOCATION((file_name, line, function_name)) macro may
be used to inform the handler tracking mechanism of a source location.
This macro declares an object that is placed on the stack.

When an asynchronous operation is launched with location information, it
outputs lines using the <action> 'n^m', prior to the 'n*m' line that
signifies the beginning of the asynchronous operation. For example:

    @asio|1589423304.861944|>7|ec=system:0,bytes_transferred=5
    @asio|1589423304.861952|7^8|in 'async_write' (./../../../include/asio/impl/write.hpp:330)
    @asio|1589423304.861952|7^8|called from 'do_write' (handler_tracking/async_tcp_echo_server.cpp:62)
    @asio|1589423304.861952|7^8|called from 'operator()' (handler_tracking/async_tcp_echo_server.cpp:51)
    @asio|1589423304.861952|7*8|socket@0x7ff61c008230.async_send
    @asio|1589423304.861975|.8|non_blocking_send,ec=system:0,bytes_transferred=5
    @asio|1589423304.861980|<7|

If std::source_location or std::experimental::source_location are
available, the use_awaitable_t token (when default-constructed or used
as a default completion token) will also cause handler tracking to
output a source location for each newly created asynchronous operation.
A use_awaitable_t object may also be explicitly constructed with location
information.
2020-05-14 13:13:38 +10:00
Christopher Kohlhoff
c140c85091 Fix travis configuration warnings. 2020-05-08 19:34:57 +10:00
Christopher Kohlhoff
8cb3ec8609 Use more recent xcode on travis, add coroutines-enabled target. 2020-05-08 18:52:59 +10:00
Christopher Kohlhoff
a2397d7cc9 Add makefile support for coroutines. 2020-05-08 18:37:18 +10:00
Christopher Kohlhoff
2de6ec4c33 Enable C++20 coroutine support for gcc 10. 2020-05-08 12:39:36 +10:00
Christopher Kohlhoff
ebfaa50e3b Fix async_compose so that it works with copyable handlers passed as an lvalue. 2020-05-03 20:34:20 +10:00
Christopher Kohlhoff
658614dca6 Add move constructor to ssl::stream<>. 2020-05-03 20:22:32 +10:00
Christopher Kohlhoff
91d1264410 Add missing nested type '::type' when computing signature. 2020-05-03 18:55:45 +10:00
Christopher Kohlhoff
17637a48cc Linearise gather-write buffer sequences in ssl::stream. 2020-05-02 19:16:08 +10:00
Christopher Kohlhoff
a5c5077e44 asio version 1.16.1 released 2020-04-29 14:04:07 +10:00
Christopher Kohlhoff
3dafb7da40 Revision history. 2020-04-29 13:40:23 +10:00