Skip to content

Commit

Permalink
Rework reference documentation in terms of completion tokens.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskohlhoff committed Mar 2, 2022
1 parent e935ce3 commit 7162c96
Show file tree
Hide file tree
Showing 67 changed files with 3,420 additions and 2,414 deletions.
20 changes: 8 additions & 12 deletions doc/history.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -740,15 +740,14 @@
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:
``
[pre
@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|[email protected]_send
@asio|1589423304.861975|.8|non_blocking_send,ec=system:0,bytes_transferred=5
@asio|1589423304.861980|<7|
``[br]
@asio|1589423304.861980|<7|][br]
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
Expand Down Expand Up @@ -777,21 +776,18 @@
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
``
[pre
cat output.txt | perl handlertree.pl 123 456]
or:
``
perl handlertree.pl 123 456 < output.txt
``[br]
[pre
perl handlertree.pl 123 456 < output.txt][br]
This script may be combined with handerlive.pl and handlerviz.pl to produce a
graph of the "live" asynchronous operation chains. For example:
``
[pre
cat output.txt | \
perl handlertree.pl `perl handlerlive.pl output.txt` | \
perl handlerviz.pl | \
dot -Tsvg > output.svg
``[br]
dot -Tsvg > output.svg][br]
* Added changes for clang-based Embarcadero C++ compilers.
* Fixed a deadlock that can occur when multiple threads concurrently initialise
the Windows I/O completion port backend.
Expand Down
14 changes: 14 additions & 0 deletions doc/model_dox.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//

/**
\page asynchronous_operation asynchronous operation
*/

/**
\page completion_token completion token
*/
13 changes: 13 additions & 0 deletions doc/quickref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,13 @@
<member><link linkend="boost_asio.reference.DynamicBuffer_v2">DynamicBuffer_v2</link></member>
<member><link linkend="boost_asio.reference.MutableBufferSequence">MutableBufferSequence</link></member>
<member><link linkend="boost_asio.reference.ReadHandler">ReadHandler</link></member>
<member><link linkend="boost_asio.reference.ReadToken">ReadToken</link></member>
<member><link linkend="boost_asio.reference.SyncRandomAccessReadDevice">SyncRandomAccessReadDevice</link></member>
<member><link linkend="boost_asio.reference.SyncRandomAccessWriteDevice">SyncRandomAccessWriteDevice</link></member>
<member><link linkend="boost_asio.reference.SyncReadStream">SyncReadStream</link></member>
<member><link linkend="boost_asio.reference.SyncWriteStream">SyncWriteStream</link></member>
<member><link linkend="boost_asio.reference.WriteHandler">WriteHandler</link></member>
<member><link linkend="boost_asio.reference.WriteToken">WriteToken</link></member>
</simplelist>
</entry>
</row>
Expand Down Expand Up @@ -575,18 +577,24 @@
<member><link linkend="boost_asio.reference.asynchronous_socket_operations">Asynchronous socket operations</link></member>
<member><link linkend="boost_asio.reference.AcceptableProtocol">AcceptableProtocol</link></member>
<member><link linkend="boost_asio.reference.AcceptHandler">AcceptHandler</link></member>
<member><link linkend="boost_asio.reference.AcceptToken">AcceptToken</link></member>
<member><link linkend="boost_asio.reference.ConnectCondition">ConnectCondition</link></member>
<member><link linkend="boost_asio.reference.ConnectHandler">ConnectHandler</link></member>
<member><link linkend="boost_asio.reference.ConnectToken">ConnectToken</link></member>
<member><link linkend="boost_asio.reference.Endpoint">Endpoint</link></member>
<member><link linkend="boost_asio.reference.EndpointSequence">EndpointSequence</link></member>
<member><link linkend="boost_asio.reference.GettableSocketOption">GettableSocketOption</link></member>
<member><link linkend="boost_asio.reference.InternetProtocol">InternetProtocol</link></member>
<member><link linkend="boost_asio.reference.IoControlCommand">IoControlCommand</link></member>
<member><link linkend="boost_asio.reference.IteratorConnectHandler">IteratorConnectHandler</link></member>
<member><link linkend="boost_asio.reference.IteratorConnectToken">IteratorConnectToken</link></member>
<member><link linkend="boost_asio.reference.MoveAcceptHandler">MoveAcceptHandler</link></member>
<member><link linkend="boost_asio.reference.MoveAcceptToken">MoveAcceptToken</link></member>
<member><link linkend="boost_asio.reference.Protocol">Protocol</link></member>
<member><link linkend="boost_asio.reference.RangeConnectHandler">RangeConnectHandler</link></member>
<member><link linkend="boost_asio.reference.RangeConnectToken">RangeConnectToken</link></member>
<member><link linkend="boost_asio.reference.ResolveHandler">ResolveHandler</link></member>
<member><link linkend="boost_asio.reference.ResolveToken">ResolveToken</link></member>
<member><link linkend="boost_asio.reference.SettableSocketOption">SettableSocketOption</link></member>
</simplelist>
</entry>
Expand Down Expand Up @@ -635,6 +643,7 @@
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.TimeTraits">TimeTraits</link></member>
<member><link linkend="boost_asio.reference.WaitHandler">WaitHandler</link></member>
<member><link linkend="boost_asio.reference.WaitToken">WaitToken</link></member>
<member><link linkend="boost_asio.reference.WaitTraits">WaitTraits</link></member>
</simplelist>
</entry>
Expand All @@ -659,8 +668,11 @@
<bridgehead renderas="sect3">Type Requirements</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.BufferedHandshakeHandler">BufferedHandshakeHandler</link></member>
<member><link linkend="boost_asio.reference.BufferedHandshakeToken">BufferedHandshakeToken</link></member>
<member><link linkend="boost_asio.reference.HandshakeHandler">HandshakeHandler</link></member>
<member><link linkend="boost_asio.reference.HandshakeToken">HandshakeToken</link></member>
<member><link linkend="boost_asio.reference.ShutdownHandler">ShutdownHandler</link></member>
<member><link linkend="boost_asio.reference.ShutdownToken">ShutdownToken</link></member>
</simplelist>
</entry>
<entry valign="top">
Expand Down Expand Up @@ -699,6 +711,7 @@
<bridgehead renderas="sect3">Type Requirements</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="boost_asio.reference.SignalHandler">SignalHandler</link></member>
<member><link linkend="boost_asio.reference.SignalToken">SignalToken</link></member>
</simplelist>
</entry>
</row>
Expand Down
1 change: 1 addition & 0 deletions doc/reference.dox
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ INPUT = ./../../../boost/asio.hpp \
./../../../boost/asio/windows \
./../../../boost/asio/execution \
./../../../boost/asio/experimental \
./model_dox.txt \
./noncopyable_dox.txt \
./std_exception_dox.txt
FILE_PATTERNS =
Expand Down
33 changes: 33 additions & 0 deletions doc/reference.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,20 @@
[include requirements/asynchronous_socket_operations.qbk]
[include requirements/AcceptableProtocol.qbk]
[include requirements/AcceptHandler.qbk]
[include requirements/AcceptToken.qbk]
[include requirements/AsyncRandomAccessReadDevice.qbk]
[include requirements/AsyncRandomAccessWriteDevice.qbk]
[include requirements/AsyncReadStream.qbk]
[include requirements/AsyncWriteStream.qbk]
[include requirements/BufferedHandshakeHandler.qbk]
[include requirements/BufferedHandshakeToken.qbk]
[include requirements/CancellationHandler.qbk]
[include requirements/CancellationSlot.qbk]
[include requirements/CompletionCondition.qbk]
[include requirements/CompletionHandler.qbk]
[include requirements/ConnectCondition.qbk]
[include requirements/ConnectHandler.qbk]
[include requirements/ConnectToken.qbk]
[include requirements/ConstBufferSequence.qbk]
[include requirements/DynamicBuffer.qbk]
[include requirements/DynamicBuffer_v1.qbk]
Expand All @@ -69,35 +72,45 @@
[include requirements/GettableSocketOption.qbk]
[include requirements/Handler.qbk]
[include requirements/HandshakeHandler.qbk]
[include requirements/HandshakeToken.qbk]
[include requirements/InternetProtocol.qbk]
[include requirements/IoControlCommand.qbk]
[include requirements/IoObjectService.qbk]
[include requirements/IteratorConnectHandler.qbk]
[include requirements/IteratorConnectToken.qbk]
[include requirements/LegacyCompletionHandler.qbk]
[include requirements/MoveAcceptHandler.qbk]
[include requirements/MoveAcceptToken.qbk]
[include requirements/MutableBufferSequence.qbk]
[include requirements/OperationState.qbk]
[include requirements/ProtoAllocator.qbk]
[include requirements/Protocol.qbk]
[include requirements/RangeConnectHandler.qbk]
[include requirements/RangeConnectToken.qbk]
[include requirements/ReadHandler.qbk]
[include requirements/ReadToken.qbk]
[include requirements/Receiver.qbk]
[include requirements/ResolveHandler.qbk]
[include requirements/ResolveToken.qbk]
[include requirements/Scheduler.qbk]
[include requirements/Sender.qbk]
[include requirements/Service.qbk]
[include requirements/SettableSerialPortOption.qbk]
[include requirements/SettableSocketOption.qbk]
[include requirements/ShutdownHandler.qbk]
[include requirements/ShutdownToken.qbk]
[include requirements/SignalHandler.qbk]
[include requirements/SignalToken.qbk]
[include requirements/SyncRandomAccessReadDevice.qbk]
[include requirements/SyncRandomAccessWriteDevice.qbk]
[include requirements/SyncReadStream.qbk]
[include requirements/SyncWriteStream.qbk]
[include requirements/TimeTraits.qbk]
[include requirements/WaitHandler.qbk]
[include requirements/WaitToken.qbk]
[include requirements/WaitTraits.qbk]
[include requirements/WriteHandler.qbk]
[include requirements/WriteToken.qbk]

</xsl:text>

Expand Down Expand Up @@ -694,6 +707,16 @@
<xsl:value-of name="text" select="$ref-name"/>
<xsl:text>`]</xsl:text>
</xsl:when>
<xsl:when test="@refid = 'asynchronous_operation'">
<xsl:text>[link boost_asio.overview.model.async_ops </xsl:text>
<xsl:value-of select="."/>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:when test="@refid = 'completion_token'">
<xsl:text>[link boost_asio.overview.model.completion_tokens </xsl:text>
<xsl:value-of select="."/>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>`</xsl:text>
<xsl:value-of select="."/>
Expand Down Expand Up @@ -727,6 +750,16 @@
<xsl:value-of name="text" select="$ref-name"/>
<xsl:text>`]</xsl:text>
</xsl:when>
<xsl:when test="@refid = 'asynchronous_operation'">
<xsl:text>[link boost_asio.overview.model.async_ops </xsl:text>
<xsl:value-of select="."/>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:when test="@refid = 'completion_token'">
<xsl:text>[link boost_asio.overview.model.completion_tokens </xsl:text>
<xsl:value-of select="."/>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>`</xsl:text>
<xsl:value-of select="."/>
Expand Down
57 changes: 0 additions & 57 deletions doc/requirements/AcceptHandler.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,4 @@ boost_asio.reference.Handler handler]. A value `h` of an accept handler
class should work correctly in the expression `h(ec)`, where `ec` is an lvalue
of type `const error_code`.

[heading Examples]

A free function as an accept handler:

void accept_handler(
const boost::system::error_code& ec)
{
...
}

An accept handler function object:

struct accept_handler
{
...
void operator()(
const boost::system::error_code& ec)
{
...
}
...
};

A lambda as an accept handler:

acceptor.async_accept(...,
[](const boost::system::error_code& ec)
{
...
});

A non-static class member function adapted to an accept handler using
`std::bind()`:

void my_class::accept_handler(
const boost::system::error_code& ec)
{
...
}
...
acceptor.async_accept(...,
std::bind(&my_class::accept_handler,
this, std::placeholders::_1));

A non-static class member function adapted to an accept handler using
`boost::bind()`:

void my_class::accept_handler(
const boost::system::error_code& ec)
{
...
}
...
acceptor.async_accept(...,
boost::bind(&my_class::accept_handler,
this, boost::asio::placeholders::error));

[endsect]
99 changes: 99 additions & 0 deletions doc/requirements/AcceptToken.qbk
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[/
/ Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
/]

[section:AcceptToken Accept token requirements]

A accept token is a [link boost_asio.overview.model.completion_tokens completion
token] for completion signature `void(error_code)`.

[heading Examples]

A free function as a accept token:

void accept_handler(
const boost::system::error_code& ec)
{
...
}

A accept token function object:

struct accept_handler
{
...
void operator()(
const boost::system::error_code& ec)
{
...
}
...
};

A lambda as a accept token:

acceptor.async_accept(...,
[](const boost::system::error_code& ec)
{
...
});

A non-static class member function adapted to a accept token using
`std::bind()`:

void my_class::accept_handler(
const boost::system::error_code& ec)
{
...
}
...
acceptor.async_accept(...,
std::bind(&my_class::accept_handler,
this, std::placeholders::_1));

A non-static class member function adapted to a accept token using
`boost::bind()`:

void my_class::accept_handler(
const boost::system::error_code& ec)
{
...
}
...
acceptor.async_accept(...,
boost::bind(&my_class::accept_handler,
this, boost::asio::placeholders::error));

Using [link boost_asio.reference.use_future use_future] as a accept token:

std::future<void> f = acceptor.async_accept(..., boost::asio::use_future);
...
try
{
f.get();
}
catch (const system_error& e)
{
...
}

Using [link boost_asio.reference.use_awaitable use_awaitable] as a accept token:

boost::asio::awaitable<void> my_coroutine()
{
try
{
...
co_await acceptor.async_accept(..., boost::asio::use_awaitable);
...
}
catch (const system_error& e)
{
...
}
}

[endsect]
Loading

0 comments on commit 7162c96

Please sign in to comment.