Squashed 'OpenVPN Adapter/Vendors/asio/' changes from 524288cb4..82be891ba

b3d2ab725 asio version 1.12.0 released
d9161a36e Update release script to match new boost doc build.
54c7b85de Update revision history.
9eaa2a2e5 Update tutorial text to use 'io_context'.
41eb9dc20 Ignore tsified directory.
9229964dc Don't use inline namespace 'v1' in example code snippets.
10098abd6 Include inline namespace 'v1' in tsified code.
9bdbef19f Regenerate documentation.
8fa11a15d Exclude use_future_t implementation detail from documentation.
577b69806 Workaround broken doxygen typedef linking when primary template is undefined.
ea1b39f04 Fix tsify.pl to work with latest code.
694ed5284 Document the new concurrency hints.
3834d7363 Some updates to 'Using' notes.
00873ce91 Document Networking TS changes.
8f25ea4b5 Remove spurious value_type from buffer sequence requirements.
b33eb0219 gcc 4.7 is the minimum version required for std::allocator_traits.
036faf66a Use new move-enabled form of async_accept.
f72304319 Ensure that use_future<std::allocator<void>> is always constexpr default-constructible.
4ad7a397c Add missing variadic template emulation in use_future.
5c591a466 Disable buffer debugging for older MSVC, as it triggers compiler misbehaviour.
f8bd903af Add assign() and clear() functions to error_code.
db4c0e83f Disable boost.chrono error handling.
cca13eefa Document the new handler tracking features.
ff9d69e2f Add check for _DEFAULT_SOURCE in addition to _BSD_SOURCE.
52498bbc6 Suppress recv truncation errors on Windows, to match POSIX behaviour.
e87c37ec9 Add documentation examples of using asio::post to submit work.
ad52c82d2 Create C++11 versions of the fork, local, multicast and nonblocking examples.
f16e39e78 Don't directly include <chrono>, to keep header C++03-compatible.
c016e1aec Boostify the TS headers.
559013298 Suppress MSVC dynamic initialisation warning.
efa18153d Add tests to ensure the ts/* headers compile and are self-contained.
41fccd565 asio/use_future.hpp is already in the convenience header.
2e743f737 Add waitable timer headers to convenience header.
fe5470f4f Use new post() in serialization example.
45dcb33c2 Use asio::coroutine in latency tests.
e556aed8d Update invocation examples to use executors.
5a9d0721d Fix up reference to post().
24050d5ea Show how to associate an executor using nested type and member function.
b02c6c758 Update allocation overview and examples to use new form.
3218be74e Fix typo in strands overview.
3152e77f8 Increase number of buffers per operation for consuming_buffers.
5acae1971 Increase threshold for small memory block recycling to 1KB.
986ef7361 Make sure asio/system_context.hpp is self-contained.
c80c1cbd5 Don't call memcpy with length 0, to avoid passing null pointers.
ede4e7597 Fix description of std::getline's behaviour.
60170d625 Fix copy/paste error in comment.
cff2b4998 Fix clang narrowing warning.
a40570919 Fix incorrect hyperlink target.
fcaf75700 Remove last remaining instance of auto_ptr.
fddf89126 Restore binder support for 3, 4 and 5 arguments.
096660c47 Fix double delete issue introduced by 47b9319acbc45d3c1bcb805a4a03cd47df177c11.
b44805ff0 Add backward compatibility for the old ConnectCondition form.
09c69982e Ensure make_network_vX error_code overload doesn't throw on invalid prefix length.
f4fecdfe4 Fix the rights for event objects on UWP.
2943ee65f Suppress implicit fallthrough warning on newer gcc.
b441bf70b Fix clang version detection for suppression of unused typedef warning.
565c6e8fa Fix compile errors in some asio::connect overloads.
d52b81646 Bump minimum MSVC version required for C++11 allocators.
5618fadb1 Fix compile warning under Emscripten
b2367dab2 Use proper SSL_version() function so that asio can build with BoringSSL.
cfe47e71d Regenerate documentation.
6377b0466 Patch up some template links.
2bda4b85c Add new macros to doxygen configuration.
4a4d28b0d Qualify use of error_code.
e39a95a73 Fix boostify.pl to work with latest code.
2ccb648f4 Only obtain associated allocator when handler is known to be valid.
230c0d2ae Asynchronous accept should not check user-set non-blocking flag.
862aed305 Require gcc >= 4.7 to use standard atomics.
a0d28e5a7 Don't use auto_ptr.
15e136fa8 Use deregister_internal_descriptor in signal_set_service.
59330e825 Put detail/config.hpp include first in detail/string_view.hpp.
d6144828b Only enable string_view with /std:c++17 on MSVC.
c2cb5395e Use hook allocation strategy whenever associated allocator is std::allocator.
5b4aa5ef9 Make epoll_reactor resistant to events with duplicate user data.
47b9319ac Don't free the reactor's per-descriptor state until after close.
cbf687653 Fix compile errors in dev_poll_reactor.
870124ab5 Add missing 'else' in epoll_reactor's handler tracking support.
b37b9449e Clean up socket release() implementation for reactor-based platforms.
f5c570826 Add out_of_band_inline socket option.
7f849376c Expose the system_executor's execution context as system_context.
9f62b6791 Update io_context run* documentation.
ac89cf0ba Enable newer language features for recent MSVC versions.
64ae9bcae Add alias templates for associators.
e502a6b36 Use shorter enum name resolver_errc::try_again.
b3ebdd8f6 Use ADL for calls to buffer_size.
c516cd591 Fix non-dereferencing pointer overflow in basic_streambuf::commit.
b8a34a1dc Fix work counting issue in asynchronous resolver implementation.
48e7ef864 is_continuation misplaced in reactive socket service
5adce6e26 Use poll.h rather than sys/poll.h if possible.
ddef4994f Avoid exception throwing from `make_network_v{4,6}(str, ec)`
0442bc922 Disable Boost.Chrono's dependency on Boost.System.
6c5b04eff Conditionally enable iostream move constructor and assignment.
a3bba3394 Fix version check for string_view.
246f387e7 Fix compile error on gcc 4.8.
fd024792c Add -lrt when linking on linux.
0921ab3db Simplify automatic detection of boost source distributions.
6b34f88a5 Make SSL/TLS version handling more consistent across OpenSSL versions.
1517bd1a1 Add travis and appveyor configuration.
70249b796 Use GetModuleHandleA rather than GetModuleHandle.
582ed12f7 Update copyright notices.
b6ac42dde Remove unused error code variable.
d52f28a09 Add missing rvalue cast in use_future implementation.
b33b3ae01 Unlocked reactor I/O implies a concurrency hint of 1.
cf351c44a Don't use non-portable sockaddr_storage member ss_len.
bbe092b3d Simplify and improve performance of executor operations.
e5acea17d Add shallow-constness to strands.
00a85845e Eliminate redundant copy as executors are now shallow-const.

git-subtree-dir: OpenVPN Adapter/Vendors/asio
git-subtree-split: 82be891ba69c65be4c684d709d78a225da69c3c5
This commit is contained in:
Sergey Abramchuk
2018-05-03 12:28:44 +03:00
parent d8b5f1556a
commit 6f1fcb972a
925 changed files with 12259 additions and 5600 deletions

View File

@@ -77,9 +77,19 @@ UNIT_TEST_EXES = \
tests/unit/strand.exe \
tests/unit/stream_socket_service.exe \
tests/unit/streambuf.exe \
tests/unit/system_executor.exe \
tests/unit/system_context.exe \
tests/unit/system_timer.exe \
tests/unit/thread.exe \
tests/unit/time_traits.exe \
tests/unit/ts/buffer.exe \
tests/unit/ts/executor.exe \
tests/unit/ts/internet.exe \
tests/unit/ts/io_context.exe \
tests/unit/ts/net.exe \
tests/unit/ts/netfwd.exe \
tests/unit/ts/socket.exe \
tests/unit/ts/timer.exe \
tests/unit/waitable_timer_service.exe \
tests/unit/windows/basic_handle.exe \
tests/unit/windows/basic_object_handle.exe \

View File

@@ -42,22 +42,26 @@ _WIN32_WINNT=0x0501
DEFINES = \
-DASIO_DISABLE_IOCP \
-D_WIN32_WINNT=$(_WIN32_WINNT) \
-DBOOST_ALL_NO_LIB
-DBOOST_ALL_NO_LIB \
-DBOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
!else
! ifdef STORE
DEFINES = \
-DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP \
-DBOOST_ALL_NO_LIB -D_WIN32_WINNT=$(_WIN32_WINNT) \
-DUNICODE -D_UNICODE
-DUNICODE -D_UNICODE \
-DBOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
! else
! ifdef WINRT
DEFINES = \
-ZW -FI SDKDDKVer.h -FI winapifamily.h -DWINAPI_FAMILY=WINAPI_PARTITION_APP \
-DBOOST_ALL_NO_LIB
-DBOOST_ALL_NO_LIB \
-DBOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
! else
DEFINES = \
-D_WIN32_WINNT=$(_WIN32_WINNT) \
-DBOOST_ALL_NO_LIB
-DBOOST_ALL_NO_LIB \
-DBOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
! endif
! endif
!endif
@@ -171,9 +175,19 @@ UNIT_TEST_EXES = \
tests\unit\steady_timer.exe \
tests\unit\stream_socket_service.exe \
tests\unit\streambuf.exe \
tests\unit\system_context.exe \
tests\unit\system_executor.exe \
tests\unit\system_timer.exe \
tests\unit\thread.exe \
tests\unit\time_traits.exe \
tests\unit\ts\buffer.exe \
tests\unit\ts\executor.exe \
tests\unit\ts\internet.exe \
tests\unit\ts\io_context.exe \
tests\unit\ts\net.exe \
tests\unit\ts\netfwd.exe \
tests\unit\ts\socket.exe \
tests\unit\ts\timer.exe \
tests\unit\waitable_timer_service.exe \
tests\unit\windows\basic_handle.exe \
tests\unit\windows\basic_object_handle.exe \
@@ -298,6 +312,9 @@ tests\unit\unit_test.obj: tests\unit\unit_test.cpp
{tests\unit\ssl}.cpp{tests\unit\ssl}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(SSL_CXXFLAGS) $(DEFINES) $< $(SSL_LIBS) $(LIBS) -link -opt:ref
{tests\unit\ts}.cpp{tests\unit\ts}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref
{tests\unit\windows}.cpp{tests\unit\windows}.exe:
cl -Fe$@ -Fo$(<:.cpp=.obj) $(CXXFLAGS) $(DEFINES) $< $(LIBS) -link -opt:ref

View File

@@ -2,7 +2,7 @@
// asio.cpp
// ~~~~~~~~
//
// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2017 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)

View File

@@ -2,7 +2,7 @@
// asio_ssl.cpp
// ~~~~~~~~~~~~
//
// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
# Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -7,7 +7,7 @@
[library Asio
[quickbook 1.4]
[copyright 2003 - 2016 Christopher M. Kohlhoff]
[copyright 2003 - 2017 Christopher M. Kohlhoff]
[purpose Networking library]
[license
Distributed under the Boost Software License, Version 1.0.
@@ -89,6 +89,15 @@ C++ approach.
Detailed class and function reference.
]
]
[
[
[link asio.net_ts Networking TS Compatibility]
]
[
Description of changes to provide compatibility with the "C++ Extensions
for Networking" Technical Specification.
]
]
[
[
[link asio.history Revision History]
@@ -112,5 +121,6 @@ C++ approach.
[include tutorial.qbk]
[include examples.qbk]
[include reference.qbk]
[include net_ts.qbk]
[include history.qbk]
[xinclude index.xml]

View File

@@ -2,7 +2,7 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!--
Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Copyright (c) 2003-2017 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)

View File

@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
# Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
# Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -313,6 +313,7 @@ coroutines.
Examples showing how to use UNIX domain (local) sockets.
* [@../src/examples/cpp03/local/connect_pair.cpp]
* [@../src/examples/cpp03/local/iostream_client.cpp]
* [@../src/examples/cpp03/local/stream_server.cpp]
* [@../src/examples/cpp03/local/stream_client.cpp]
@@ -370,6 +371,20 @@ and asynchronous operations.
* [@../src/examples/cpp11/echo/blocking_udp_echo_server.cpp] ([@examples/diffs/echo/blocking_udp_echo_server.cpp.html diff to C++03])
[heading Fork]
These POSIX-specific examples show how to use Asio in conjunction with the
`fork()` system call. The first example illustrates the steps required to start
a daemon process:
* [@../src/examples/cpp11/fork/daemon.cpp] ([@examples/diffs/fork/daemon.cpp.html diff to C++03])
The second example demonstrates how it is possible to fork a process from
within a completion handler.
* [@../src/examples/cpp11/fork/process_per_connection.cpp] ([@examples/diffs/fork/process_per_connection.cpp.html diff to C++03])
[heading Futures]
This example demonstrates how to use std::future in conjunction with
@@ -378,6 +393,13 @@ Asio's asynchronous operations.
* [@../src/examples/cpp11/futures/daytime_client.cpp]
[heading Handler Tracking]
This example shows how to implement custom handler tracking.
* [@../src/examples/cpp11/handler_tracking/custom_tracking.hpp]
[heading HTTP Server]
This example illustrates the use of asio in a simple single-threaded server
@@ -403,6 +425,23 @@ cancelling all outstanding asynchronous operations.
* [@../src/examples/cpp11/http/server/server.hpp] ([@examples/diffs/http/server/server.hpp.html diff to C++03])
[heading Multicast]
An example showing the use of multicast to transmit packets to a group of
subscribers.
* [@../src/examples/cpp11/multicast/receiver.cpp] ([@examples/diffs/multicast/receiver.cpp.html diff to C++03])
* [@../src/examples/cpp11/multicast/sender.cpp] ([@examples/diffs/multicast/sender.cpp.html diff to C++03])
[heading Nonblocking]
Example demonstrating reactor-style operations for integrating a third-party
library that wants to perform the I/O operations itself.
* [@../src/examples/cpp11/nonblocking/third_party_lib.cpp] ([@examples/diffs/nonblocking/third_party_lib.cpp.html diff to C++03])
[heading Spawn]
Example of using the asio::spawn() function, a wrapper around the
@@ -413,6 +452,16 @@ coroutines.
* [@../src/examples/cpp11/spawn/echo_server.cpp] ([@examples/diffs/spawn/echo_server.cpp.html diff to C++03])
[heading UNIX Domain Sockets]
Examples showing how to use UNIX domain (local) sockets.
* [@../src/examples/cpp11/local/connect_pair.cpp] ([@examples/diffs/local/connect_pair.cpp.html diff to C++03])
* [@../src/examples/cpp11/local/iostream_client.cpp] ([@examples/diffs/local/iostream_client.cpp.html diff to C++03])
* [@../src/examples/cpp11/local/stream_server.cpp] ([@examples/diffs/local/stream_server.cpp.html diff to C++03])
* [@../src/examples/cpp11/local/stream_client.cpp] ([@examples/diffs/local/stream_client.cpp.html diff to C++03])
[endsect]

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -7,6 +7,31 @@
[section:history Revision History]
[heading Asio 1.12.0]
* Completed the interface changes to reflect the Networking TS
([@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4656.pdf N4656]).
* See the [link asio.net_ts list] of new interfaces and, where
applicable, the corresponding old interfaces that have been superseded.
* The service template parameters, and the corresponding classes, are disabled
by default. For example, instead of `basic_socket<Protocol, SocketService>` we
now have simply `basic_socket<Protocol>`. The old interface can be enabled by
defining the `(BOOST_)ASIO_ENABLE_OLD_SERVICES` macro.
* Added support for customised handler tracking.
* Added reactor-related (i.e. descriptor readiness) events to handler tracking.
* Added special [link asio.overview.core.concurrency_hint concurrency
hint] values that may be used to disable locking on a per `io_context` basis.
* Enabled perfect forwarding for the first `ssl::stream<>` constructor argument.
* Added ability to release ownership of the underlying native socket. (Requires
Windows 8.1 or later when using the I/O completion port backend.)
[heading Asio 1.11.0]
* Implemented changes to substantially reflect the Networking Library Proposal

View File

@@ -2,7 +2,7 @@
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "../../../boost/tools/boostbook/dtd/boostbook.dtd">
<!--
Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Copyright (c) 2003-2017 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)

View File

@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
# Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
# Copyright (c) 2003-2017 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)

473
asio/src/doc/net_ts.qbk Normal file
View File

@@ -0,0 +1,473 @@
[/
/ Copyright (c) 2003-2017 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:net_ts Networking TS compatibility]
Asio now provides the interfaces and functionality specified by the "C++
Extensions for Networking" Technical Specification. In addition to access via
the usual Asio header files, this functionality may be accessed through special
headers that correspond to the header files defined in the TS. These are listed
in the table below:
[table
[[Networking TS header][Asio header]]
[[`#include <buffer>`][`#include <asio/ts/buffer.hpp>`]]
[[`#include <executor>`][`#include <asio/ts/executor.hpp>`]]
[[`#include <internet>`][`#include <asio/ts/internet.hpp>`]]
[[`#include <io_context>`][`#include <asio/ts/io_context.hpp>`]]
[[`#include <net>`][`#include <asio/ts/net.hpp>`]]
[[`#include <netfwd>`][`#include <asio/ts/netfwd.hpp>`]]
[[`#include <socket>`][`#include <asio/ts/socket.hpp>`]]
[[`#include <timer>`][`#include <asio/ts/timer.hpp>`]]
]
In some cases the new Networking TS compatible interfaces supersede older Asio
facilities. In these cases the older interfaces have been deprecated. The table
below shows the new Networking TS interfaces and the facilities they replace:
[table
[[New interface][Old interface][Notes]]
[
[[link asio.reference.io_context `io_context`]]
[[link asio.reference.io_service `io_service`]]
[The name `io_service` is retained as a typedef.]
]
[
[[link asio.reference.dispatch `dispatch`]]
[[link asio.reference.io_context.dispatch `io_service::dispatch`]]
[The `dispatch` free function can be used to submit functions to any [link
asio.reference.Executor1 Executor] or [link asio.reference.ExecutionContext
ExecutionContext].]
]
[
[[link asio.reference.dispatch `post`]]
[[link asio.reference.io_context.post `io_service::post`]]
[The `dispatch` free function can be used to submit functions to any [link
asio.reference.Executor1 Executor] or [link asio.reference.ExecutionContext
ExecutionContext].]
]
[
[[link asio.reference.dispatch `defer`]]
[[link asio.reference.io_context.post `io_service::post`] when the [link
asio.reference.asio_handler_is_continuation `asio_handler_is_continuation`]
hook returns true]
[The `defer` free function can be used to submit functions to any [link
asio.reference.Executor1 Executor] or [link asio.reference.ExecutionContext
ExecutionContext].]
]
[
[[link asio.reference.io_context.poll `io_context::poll`]]
[[link asio.reference.io_context.poll `io_service::poll`] overload that
takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link asio.reference.io_context.poll_one `io_context::poll_one`]]
[[link asio.reference.io_context.poll_one `io_service::poll_one`] overload
that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link asio.reference.io_context.run `io_context::run`]]
[[link asio.reference.io_context.run `io_service::run`] overload that takes
`error_code&`]
[The `error_code` overload is not required.]
]
[
[[link asio.reference.io_context.run_one `io_context::run_one`]]
[[link asio.reference.io_context.run_one `io_service::run_one`] overload
that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link asio.reference.io_context.run_for `io_context::run_for`],
[link asio.reference.io_context.run_until `io_context::run_until`],
[link asio.reference.io_context.run_one_for `io_context::run_one_for`], and
[link asio.reference.io_context.run_one_until `io_context::run_one_until`]]
[]
[These functions add the ability to run an `io_context` for a limited time.]
]
[
[[link asio.reference.io_context.restart `io_context::restart`]]
[[link asio.reference.io_context.reset `io_service::reset`]]
[]
]
[
[[link asio.reference.execution_context `execution_context`], [link
asio.reference.execution_context__service `execution_context::service`],
and [link asio.reference.execution_context__id `execution_context::id`]]
[[link asio.reference.io_context `io_service`], [link
asio.reference.io_context__service `io_service::service`], and [link
asio.reference.execution_context__id `io_service::id`]]
[The service-related functionality has been moved to the
`execution_context` base class. This may also be used as a base for
creating custom execution contexts.]
]
[
[[link asio.reference.execution_context.make_service `make_service`]]
[[link asio.reference.execution_context.add_service `add_service`]]
[]
]
[
[[link asio.reference.strand `strand`]]
[[link asio.reference.io_context__strand `io_service::strand`]]
[This template works with any valid executor, and is itself a valid
executor.]
]
[
[[link asio.reference.executor_work_guard `executor_work_guard`] and [link
asio.reference.make_work_guard `make_work_guard`]]
[[link asio.reference.io_context__work `io_service::work`]]
[Work tracking is now covered by the [link asio.reference.Executor1
Executor] requirements. These templates work with any valid executor.]
]
[
[[link asio.reference.executor_binder `executor_binder`] and [link
asio.reference.bind_executor `bind_executor`]]
[[link asio.reference.io_context.wrap `io_service::wrap`] and
[link asio.reference.io_context__strand.wrap `io_service::strand::wrap`]]
[These templates work with any valid executor.]
]
[
[[link asio.reference.async_result `async_result`] with `CompletionToken`
and `Signature` template parameters]
[[link asio.reference.handler_type `handler_type`] and single parameter
[link asio.reference.async_result_lt__Handler__gt_ `async_result`]]
[The `async_result` trait is now the single point of customisation for
asynchronous operation completion handlers and return type.]
]
[
[[link asio.reference.associated_executor `associated_executor`] and [link
asio.reference.get_associated_executor `get_associated_executor`]]
[[link asio.reference.asio_handler_invoke `asio_handler_invoke`]]
[The handler invocation hook has been replaced by the new [link
asio.reference.Executor1 Executor] requirements and the associated executor
traits.]
]
[
[[link asio.reference.associated_allocator `associated_allocator`] and
[link asio.reference.get_associated_allocator `get_associated_allocator`]]
[[link asio.reference.asio_handler_allocate `asio_handler_allocate`] and
[link asio.reference.asio_handler_deallocate `asio_handler_deallocate`]]
[The handler allocation hooks have been replaced by the standard Allocator
requirements and the associated allocator traits.]
]
[
[[link asio.reference.const_buffer.data `const_buffer::data`] and [link
asio.reference.mutable_buffer.data `mutable_buffer::data`]]
[[link asio.reference.buffer_cast `buffer_cast`]]
[]
]
[
[[link asio.reference.const_buffer.size `const_buffer::size`] and [link
asio.reference.mutable_buffer.size `mutable_buffer::size`]]
[[link asio.reference.buffer_size `buffer_size`] for single buffers]
[`buffer_size` is not deprecated for single buffers as `const_buffer` and
`mutable_buffer` now satisfy the buffer sequence requirements]
]
[
[[link asio.reference.const_buffer `const_buffer`]]
[[link asio.reference.const_buffers_1 `const_buffers_1`]]
[The [link asio.reference.ConstBufferSequence ConstBufferSequence]
requirements have been modified such that `const_buffer` now satisfies
them.]
]
[
[[link asio.reference.mutable_buffer `mutable_buffer`]]
[[link asio.reference.mutable_buffers_1 `mutable_buffers_1`]]
[The [link asio.reference.MutableBufferSequence MutableBufferSequence]
requirements have been modified such that `mutable_buffer` now satisfies
them.]
]
[
[[link asio.reference.basic_socket.get_executor
`basic_socket::get_executor`] (and corresponding member for I/O objects
such as timers, serial ports, etc.)]
[[link asio.reference.basic_io_object.get_io_service
`basic_io_object::get_io_service`]]
[Use `get_executor().context()` to obtain the associated `io_context`.]
]
[
[[link asio.reference.socket_base.max_listen_connections
`socket_base::max_listen_connections`]]
[[link asio.reference.socket_base.max_connections
`socket_base::max_connections`]]
[]
]
[
[[link asio.reference.socket_base.wait_type `socket_base::wait_type`],
[link asio.reference.basic_socket.wait `basic_socket::wait`], [link
asio.reference.basic_socket.async_wait `basic_socket::async_wait`], [link
asio.reference.basic_socket_acceptor.wait `basic_socket_acceptor::wait`],
and [link asio.reference.basic_socket_acceptor.async_wait
`basic_socket_acceptor::async_wait`]]
[[link asio.reference.null_buffers `null_buffers`]]
[Operations for reactive I/O.]
]
[
[[link asio.reference.basic_socket_acceptor.accept
`basic_socket_acceptor::accept`] returns a socket]
[[link asio.reference.basic_socket_acceptor.accept
`basic_socket_acceptor::accept`] takes a socket by reference]
[Uses move support so requires C++11 or later. To accept a connection into
a socket object on a different `io_context`, pass the destination context
to `accept`.]
]
[
[[link asio.reference.basic_socket_acceptor.async_accept
`basic_socket_acceptor::async_accept`] passes socket to handler]
[[link asio.reference.basic_socket_acceptor.async_accept
`basic_socket_acceptor::async_accept`] takes a socket by reference]
[Uses move support so requires C++11 or later. To accept a connection into
a socket object on a different `io_context`, pass the destination context
to `async_accept`.]
]
[
[[link asio.reference.connect `connect`] overloads that take a range]
[[link asio.reference.connect `connect`] overloads that take a single
iterator]
[The [link asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] function now returns a range. When the
`resolve` function's result is passed directly to `connect`, the range
overload will be selected.]
]
[
[[link asio.reference.async_connect `async_connect`] overloads that take a
range]
[[link asio.reference.async_connect `async_connect`] overloads that take a
single iterator]
[The [link asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] function now returns a range. When the
`resolve` function's result is passed directly to `async_connect`, the
range overload will be selected.]
]
[
[[link asio.reference.basic_socket_streambuf.duration
`basic_socket_streambuf::duration`]]
[[link asio.reference.basic_socket_streambuf.duration_type
`basic_socket_streambuf::duration_type`]]
[]
]
[
[[link asio.reference.basic_socket_streambuf.time_point
`basic_socket_streambuf::time_point`]]
[[link asio.reference.basic_socket_streambuf.time_type
`basic_socket_streambuf::time_type`]]
[]
]
[
[[link asio.reference.basic_socket_streambuf.expiry
`basic_socket_streambuf::expiry`]]
[[link asio.reference.basic_socket_streambuf.expires_at
`basic_socket_streambuf::expires_at`] and [link
asio.reference.basic_socket_streambuf.expires_from_now
`basic_socket_streambuf::expires_from_now`] getters]
[]
]
[
[[link asio.reference.basic_socket_streambuf.expires_after
`basic_socket_streambuf::expires_after`]]
[[link asio.reference.basic_socket_streambuf.expires_from_now
`basic_socket_streambuf::expires_from_now`] setter]
[]
]
[
[[link asio.reference.basic_socket_streambuf.error
`basic_socket_streambuf::error`]]
[[link asio.reference.basic_socket_streambuf.puberror
`basic_socket_streambuf::puberror`]]
[]
]
[
[[link asio.reference.basic_socket_iostream.duration
`basic_socket_iostream::duration`]]
[[link asio.reference.basic_socket_iostream.duration_type
`basic_socket_iostream::duration_type`]]
[]
]
[
[[link asio.reference.basic_socket_iostream.time_point
`basic_socket_iostream::time_point`]]
[[link asio.reference.basic_socket_iostream.time_type
`basic_socket_iostream::time_type`]]
[]
]
[
[[link asio.reference.basic_socket_iostream.expiry
`basic_socket_iostream::expiry`]]
[[link asio.reference.basic_socket_iostream.expires_at
`basic_socket_iostream::expires_at`] and [link
asio.reference.basic_socket_iostream.expires_from_now
`basic_socket_iostream::expires_from_now`] getters]
[]
]
[
[[link asio.reference.basic_socket_iostream.expires_after
`basic_socket_iostream::expires_after`]]
[[link asio.reference.basic_socket_iostream.expires_from_now
`basic_socket_iostream::expires_from_now`] setter]
[]
]
[
[[link asio.reference.basic_waitable_timer.cancel
`basic_waitable_timer::cancel`]]
[[link asio.reference.basic_waitable_timer.cancel
`basic_waitable_timer::cancel`] overload that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link asio.reference.basic_waitable_timer.cancel_one
`basic_waitable_timer::cancel_one`]]
[[link asio.reference.basic_waitable_timer.cancel_one
`basic_waitable_timer::cancel_one`] overload that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link asio.reference.basic_waitable_timer.expires_at
`basic_waitable_timer::expires_at`] setter]
[[link asio.reference.basic_waitable_timer.expires_at
`basic_waitable_timer::expires_at`] setter that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link asio.reference.basic_waitable_timer.expiry
`basic_waitable_timer::expiry`]]
[[link asio.reference.basic_waitable_timer.expires_at
`basic_waitable_timer::expires_at`] and [link
asio.reference.basic_waitable_timer.expires_from_now
`basic_waitable_timer::expires_from_now`] getters]
[]
]
[
[[link asio.reference.basic_waitable_timer.expires_after
`basic_waitable_timer::expires_after`]]
[[link asio.reference.basic_waitable_timer.expires_from_now
`basic_waitable_timer::expires_from_now`] setter]
[]
]
[
[[link asio.reference.ip__address.make_address `ip::make_address`]]
[[link asio.reference.ip__address.from_string `ip::address::from_string`]]
[]
]
[
[[link asio.reference.ip__address_v4.make_address_v4 `ip::make_address_v4`]]
[[link asio.reference.ip__address_v4.from_string
`ip::address_v4::from_string`] and [link
asio.reference.ip__address_v6.to_v4 `ip::address_v6::to_v4`]]
[]
]
[
[[link asio.reference.ip__address_v6.make_address_v6 `ip::make_address_v6`]]
[[link asio.reference.ip__address_v6.from_string
`ip::address_v6::from_string`] and [link
asio.reference.ip__address_v6.v4_mapped `ip::address_v6::v4_mapped`]]
[]
]
[
[[link asio.reference.ip__address.to_string `ip::address::to_string`]]
[[link asio.reference.ip__address.to_string `ip::address::to_string`] that
takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link asio.reference.ip__address_v4.to_string `ip::address_v4::to_string`]]
[[link asio.reference.ip__address_v4.to_string `ip::address_v4::to_string`]
that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[[link asio.reference.ip__address_v6.to_string `ip::address_v6::to_string`]]
[[link asio.reference.ip__address_v6.to_string `ip::address_v6::to_string`]
that takes `error_code&`]
[The `error_code` overload is not required.]
]
[
[No replacement]
[[link asio.reference.ip__address_v6.is_v4_compatible
`ip::address_v6::is_v4_compatible`] and [link
asio.reference.ip__address_v6.v4_compatible
`ip::address_v6::v4_compatible`]]
[]
]
[
[[link asio.reference.ip__network_v4 `ip::network_v4`]]
[[link asio.reference.ip__address_v4.broadcast `ip::address_v4::broadcast`],
[link asio.reference.ip__address_v4.is_class_a `ip::address_v4::is_class_a`],
[link asio.reference.ip__address_v4.is_class_b `ip::address_v4::is_class_b`],
[link asio.reference.ip__address_v4.is_class_c `ip::address_v4::is_class_c`],
and [link asio.reference.ip__address_v4.netmask `ip::address_v4::netmask`]]
[The `network_v4` class adds the ability to manipulate IPv4 network
addresses using CIDR notation.]
]
[
[[link asio.reference.ip__network_v6 `ip::network_v6`]]
[]
[The `network_v6` class adds the ability to manipulate IPv6 network
addresses using CIDR notation.]
]
[
[[link asio.reference.ip__basic_address_iterator_lt__address_v4__gt_
`ip::address_v4_iterator`] and [link
asio.reference.ip__basic_address_range_lt__address_v4__gt_
`ip::address_v4_range`]]
[]
[The `ip::address_v4_iterator` and `address_v4_range` classes add the
ability to iterate over all, or a subset of, IPv4 addresses.]
]
[
[[link asio.reference.ip__basic_address_iterator_lt__address_v6__gt_
`ip::address_v6_iterator`] and [link
asio.reference.ip__basic_address_range_lt__address_v6__gt_
`ip::address_v6_range`]]
[]
[The `ip::address_v6_iterator` and `address_v6_range` classes add the
ability to iterate over all, or a subset of, IPv6 addresses.]
]
[
[[link asio.reference.ip__basic_resolver.results_type
`ip::basic_resolver::results_type`]]
[[link asio.reference.ip__basic_resolver.iterator
`ip::basic_resolver::iterator`]]
[Resolvers now produce ranges rather than single iterators.]
]
[
[[link asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] overloads taking hostname and service as
arguments]
[[link asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] overloads taking a [link
asio.reference.ip__basic_resolver.query `ip::basic_resolver::query`]]
[]
]
[
[[link asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] returns a range]
[[link asio.reference.ip__basic_resolver.resolve
`ip::basic_resolver::resolve`] returns a single iterator]
[]
]
[
[[link asio.reference.ip__basic_resolver.async_resolve
`ip::basic_resolver::async_resolve`] overloads taking hostname and service
as arguments]
[[link asio.reference.ip__basic_resolver.async_resolve
`ip::basic_resolver::async_resolve`] overloads taking a [link
asio.reference.ip__basic_resolver.query `ip::basic_resolver::query`]]
[]
]
[
[[link asio.reference.ip__basic_resolver.async_resolve
`ip::basic_resolver::async_resolve`] calls the handler with a range]
[[link asio.reference.ip__basic_resolver.async_resolve
`ip::basic_resolver::async_resolve`] calls the handler with a single
iterator]
[]
]
]
[endsect]

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -19,6 +19,7 @@
* [link asio.overview.core.line_based Line-Based Operations]
* [link asio.overview.core.allocation Custom Memory Allocation]
* [link asio.overview.core.handler_tracking Handler Tracking]
* [link asio.overview.core.concurrency_hint Concurrency Hints]
* [link asio.overview.core.coroutine Stackless Coroutines]
* [link asio.overview.core.spawn Stackful Coroutines]
* [link asio.overview.networking Networking]
@@ -53,6 +54,7 @@
* [link asio.overview.core.line_based Line-Based Operations]
* [link asio.overview.core.allocation Custom Memory Allocation]
* [link asio.overview.core.handler_tracking Handler Tracking]
* [link asio.overview.core.concurrency_hint Concurrency Hints]
* [link asio.overview.core.coroutine Stackless Coroutines]
* [link asio.overview.core.spawn Stackful Coroutines]
@@ -66,6 +68,7 @@
[include overview/line_based.qbk]
[include overview/allocation.qbk]
[include overview/handler_tracking.qbk]
[include overview/concurrency_hint.qbk]
[include overview/coroutine.qbk]
[include overview/spawn.qbk]

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -19,22 +19,53 @@ executing in parallel. Programs should be able to leverage this knowledge to
reuse memory for all asynchronous operations in a chain.
Given a copy of a user-defined `Handler` object `h`, if the implementation
needs to allocate memory associated with that handler it will execute the code:
needs to allocate memory associated with that handler it will obtain an
allocator using the `get_associated_allocator` function. For example:
void* pointer = asio_handler_allocate(size, &h);
asio::associated_allocator_t<Handler> a = asio::get_associated_allocator(h);
Similarly, to deallocate the memory it will execute:
The associated allocator must satisfy the standard Allocator requirements.
asio_handler_deallocate(pointer, size, &h);
By default, handlers use the standard allocator (which is implemented in terms
of `::operator new()` and `::operator delete()`). The allocator may be
customised for a particular handler type by specifying a nested type
`allocator_type` and member function `get_allocator()`:
These functions are located using argument-dependent lookup. The implementation
provides default implementations of the above functions in the `asio` namespace:
class my_handler
{
public:
// Custom implementation of Allocator type requirements.
typedef my_allocator allocator_type;
void* asio_handler_allocate(size_t, ...);
void asio_handler_deallocate(void*, size_t, ...);
// Return a custom allocator implementation.
allocator_type get_allocator() const noexcept
{
return my_allocator();
}
which are implemented in terms of `::operator new()` and `::operator delete()`
respectively.
void operator()() { ... }
};
In more complex cases, the `associated_allocator` template may be partially
specialised directly:
namespace asio {
template <typename Allocator>
struct associated_allocator<my_handler, Allocator>
{
// Custom implementation of Allocator type requirements.
typedef my_allocator type;
// Return a custom allocator implementation.
static type get(const my_handler&,
const Allocator& a = Allocator()) noexcept
{
return my_allocator();
}
};
} // namespace asio
The implementation guarantees that the deallocation will occur before the
associated handler is invoked, which means the memory is ready to be reused for
@@ -50,8 +81,8 @@ threads.
[heading See Also]
[link asio.reference.asio_handler_allocate asio_handler_allocate],
[link asio.reference.asio_handler_deallocate asio_handler_deallocate],
[link asio.reference.associated_allocator associated_allocator],
[link asio.reference.get_associated_allocator get_associated_allocator],
[link asio.examples.cpp03_examples.allocation custom memory allocation example (C++03)],
[link asio.examples.cpp11_examples.allocation custom memory allocation example (C++11)].

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -70,7 +70,7 @@ operations, such as the send or receive operations of a socket:
of this function meets the `ConstBufferSequence` requirements.
* The output sequence of the streambuf is accessible via the [link
asio.reference.basic_streambuf.data prepare()] member function. The return
asio.reference.basic_streambuf.prepare prepare()] member function. The return
type of this function meets the `MutableBufferSequence` requirements.
* Data is transferred from the front of the output sequence to the back of the

View File

@@ -0,0 +1,88 @@
[/
/ Copyright (c) 2003-2017 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:concurrency_hint Concurrency Hints]
The [link asio.reference.io_context.io_context `io_context` constructor]
allows programs to specify a concurrency hint. This is a suggestion to the
`io_context` implementation as to the number of active threads that should be
used for running completion handlers.
When the Windows I/O completion port backend is in use, this value is passed
to [^CreateIoCompletionPort].
When a reactor-based backend is used, the implementation recognises the
following special concurrency hint values:
[table
[[Value][Description]]
[
[`1`]
[
The implementation assumes that the `io_context` will be run from a
single thread, and applies several optimisations based on this
assumption.
For example, when a handler is posted from within another handler, the
new handler is added to a fast thread-local queue (with the consequence
that the new handler is held back until the currently executing handler
finishes).
]
]
[
[`ASIO_CONCURRENCY_HINT_UNSAFE`]
[
This special concurrency hint disables locking in both the scheduler and
reactor I/O. This hint has the following restrictions:
[mdash] Care must be taken to ensure that all operations on the
`io_context` and any of its associated I/O objects (such as sockets and
timers) occur in only one thread at a time.
[mdash] Asynchronous resolve operations fail with `operation_not_supported`.
[mdash] If a `signal_set` is used with the `io_context`, `signal_set`
objects cannot be used with any other io_context in the program.
]
]
[
[`ASIO_CONCURRENCY_HINT_UNSAFE_IO`]
[
This special concurrency hint disables locking in the reactor I/O. This
hint has the following restrictions:
[mdash] Care must be taken to ensure that run functions on the
`io_context`, and all operations on the context's associated I/O objects
(such as sockets and timers), occur in only one thread at a time.
]
]
[
[`ASIO_CONCURRENCY_HINT_SAFE`]
[
The default. The `io_context` provides full thread safety, and distinct
I/O objects may be used from any thread.
]
]
]
[teletype]
The concurrency hint used by default-constructed `io_context` objects can be
overridden at compile time by defining the `ASIO_CONCURRENCY_HINT_DEFAULT`
macro. For example, specifying
-DASIO_CONCURRENCY_HINT_DEFAULT=1
on the compiler command line means that a concurrency hint of `1` is used for
all default-constructed `io_context` objects in the program. Similarly, the
concurrency hint used by `io_context` objects constructed with `1` can be
overridden by defining `ASIO_CONCURRENCY_HINT_1`. For example, passing
-DASIO_CONCURRENCY_HINT_1=ASIO_CONCURRENCY_HINT_UNSAFE
to the compiler will disable thread safety for all of these objects.
[endsect]

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -79,13 +79,12 @@ or:
{
private:
tcp::acceptor acceptor_;
tcp::socket socket_;
...
void handle_accept(error_code ec)
void handle_accept(error_code ec, tcp::socket socket)
{
if (!ec)
std::make_shared<connection>(std::move(socket_))->go();
acceptor_.async_accept(socket_, ...);
std::make_shared<connection>(std::move(socket))->go();
acceptor_.async_accept(...);
}
...
};

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -18,25 +18,30 @@ asynchronous operations are chained together, or what the pending asynchronous
operations are. As an illustration, here is the output when you run the HTTP
Server example, handle a single request, then shut down via Ctrl+C:
@asio|1298160085.070638|0*1|signal_set@0x7fff50528f40.async_wait
@asio|1298160085.070888|0*2|socket@0x7fff50528f60.async_accept
@asio|1298160085.070913|0|resolver@0x7fff50528e28.cancel
@asio|1298160118.075438|>2|ec=asio.system:0
@asio|1298160118.075472|2*3|socket@0xb39048.async_receive
@asio|1298160118.075507|2*4|socket@0x7fff50528f60.async_accept
@asio|1298160118.075527|<2|
@asio|1298160118.075540|>3|ec=asio.system:0,bytes_transferred=122
@asio|1298160118.075731|3*5|socket@0xb39048.async_send
@asio|1298160118.075778|<3|
@asio|1298160118.075793|>5|ec=asio.system:0,bytes_transferred=156
@asio|1298160118.075831|5|socket@0xb39048.close
@asio|1298160118.075855|<5|
@asio|1298160122.827317|>1|ec=asio.system:0,signal_number=2
@asio|1298160122.827333|1|socket@0x7fff50528f60.close
@asio|1298160122.827359|<1|
@asio|1298160122.827370|>4|ec=asio.system:125
@asio|1298160122.827378|<4|
@asio|1298160122.827394|0|signal_set@0x7fff50528f40.cancel
@asio|1512254357.979980|0*1|signal_set@0x7ffeaaaa20d8.async_wait
@asio|1512254357.980127|0*2|socket@0x7ffeaaaa20f8.async_accept
@asio|1512254357.980150|.2|non_blocking_accept,ec=asio.system:11
@asio|1512254357.980162|0|resolver@0x7ffeaaaa1fd8.cancel
@asio|1512254368.457147|.2|non_blocking_accept,ec=system:0
@asio|1512254368.457193|>2|ec=system:0
@asio|1512254368.457219|2*3|socket@0x55cf39f0a238.async_receive
@asio|1512254368.457244|.3|non_blocking_recv,ec=system:0,bytes_transferred=141
@asio|1512254368.457275|2*4|socket@0x7ffeaaaa20f8.async_accept
@asio|1512254368.457293|.4|non_blocking_accept,ec=asio.system:11
@asio|1512254368.457301|<2|
@asio|1512254368.457310|>3|ec=system:0,bytes_transferred=141
@asio|1512254368.457441|3*5|socket@0x55cf39f0a238.async_send
@asio|1512254368.457502|.5|non_blocking_send,ec=system:0,bytes_transferred=156
@asio|1512254368.457511|<3|
@asio|1512254368.457519|>5|ec=system:0,bytes_transferred=156
@asio|1512254368.457544|5|socket@0x55cf39f0a238.close
@asio|1512254368.457559|<5|
@asio|1512254371.385106|>1|ec=system:0,signal_number=2
@asio|1512254371.385130|1|socket@0x7ffeaaaa20f8.close
@asio|1512254371.385163|<1|
@asio|1512254371.385175|>4|ec=asio.system:125
@asio|1512254371.385182|<4|
@asio|1512254371.385202|0|signal_set@0x7ffeaaaa20d8.cancel
Each line is of the form:
@@ -77,11 +82,19 @@ The `<action>` takes one of the following forms:
]
[
[n]
[The handler number n performed some other operation. The `<description>`
[The handler number `n` performed some other operation. The `<description>`
shows what function was called. Currently only `close()` and `cancel()`
operations are logged, as these may affect the state of pending
asynchronous operations.]
]
[
[.n]
[The implementation performed a system call as part of the asynchronous
operation for which handler number `n` is the completion handler. The
`<description>` shows what function was called and its results. These
tracking events are only emitted when using a reactor-based
implementation.]
]
]
Where the `<description>` shows a synchronous or asynchronous operation, the
@@ -99,4 +112,109 @@ The handler tracking output may be post-processed using the included
(requires the GraphViz tool [^dot]).
[c++]
[heading Custom Tracking]
Handling tracking may be customised by defining the
`ASIO_CUSTOM_HANDLER_TRACKING` macro to the name of a header file
(enclosed in `""` or `<>`). This header file must implement the following
preprocessor macros:
[table
[[Macro] [Description]]
[
[`ASIO_INHERIT_TRACKED_HANDLER`]
[Specifies a base class for classes that implement asynchronous operations.
When used, the macro immediately follows the class name, so it must have
the form `: public my_class`.]
]
[
[`ASIO_ALSO_INHERIT_TRACKED_HANDLER`]
[Specifies a base class for classes that implement asynchronous operations.
When used, the macro follows other base classes, so it must have the form
`, public my_class`.]
]
[
[`ASIO_HANDLER_TRACKING_INIT(args)`]
[An expression that is used to initialise the tracking mechanism.]
]
[
[`ASIO_HANDLER_CREATION(args)`]
[An expression that is called on creation of an asynchronous operation.
`args` is a parenthesised function argument list containing the owning
execution context, the tracked handler, the name of the object type, a
pointer to the object, the object's native handle, and the operation name.]
]
[
[`ASIO_HANDLER_COMPLETION(args)`]
[An expression that is called on completion of an asynchronous operation.
`args` is a parenthesised function argument list containing the tracked
handler.]
]
[
[`ASIO_HANDLER_INVOCATION_BEGIN(args)`]
[An expression that is called immediately before a completion handler is
invoked. `args` is a parenthesised function argument list containing the
arguments to the completion handler.]
]
[
[`ASIO_HANDLER_INVOCATION_END`]
[An expression that is called immediately after a completion handler is
invoked.]
]
[
[`ASIO_HANDLER_OPERATION(args)`]
[An expression that is called when some synchronous object operation is
called (such as `close()` or `cancel()`). `args` is a parenthesised
function argument list containing the owning execution context, the name
of the object type, a pointer to the object, the object's native handle,
and the operation name.]
]
[
[`ASIO_HANDLER_REACTOR_REGISTRATION(args)`]
[An expression that is called when an object is registered with the
reactor. `args` is a parenthesised function argument list containing the
owning execution context, the object's native handle, and a unique
registration key.]
]
[
[`ASIO_HANDLER_REACTOR_DEREGISTRATION(args)`]
[An expression that is called when an object is deregistered from the
reactor. `args` is a parenthesised function argument list containing the
owning execution context, the object's native handle, and a unique
registration key.]
]
[
[`ASIO_HANDLER_REACTOR_READ_EVENT`]
[A bitmask constant used to identify reactor read readiness events.]
]
[
[`ASIO_HANDLER_REACTOR_WRITE_EVENT`]
[A bitmask constant used to identify reactor write readiness events.]
]
[
[`ASIO_HANDLER_REACTOR_ERROR_EVENT`]
[A bitmask constant used to identify reactor error readiness events.]
]
[
[`ASIO_HANDLER_REACTOR_EVENTS(args)`]
[An expression that is called when an object registered with the reactor
becomes ready. `args` is a parenthesised function argument list containing
the owning execution context, the unique registration key, and a bitmask of
the ready events.]
]
[
[`ASIO_HANDLER_REACTOR_OPERATION(args)`]
[An expression that is called when the implementation performs a system
call as part of a reactor-based asynchronous operation. `args` is a
parenthesised function argument list containing the tracked handler, the
operation name, the error code produced by the operation, and (optionally)
the number of bytes transferred.]
]
]
[heading See Also]
[link asio.examples.cpp11_examples.handler_tracking Custom handler tracking
example].
[endsect]

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -36,9 +36,35 @@ ensure thread safe access for any objects that are shared between the caller
and the composed operation (in the case of `async_read()` it's the socket,
which the caller can `close()` to cancel the operation).
This is done by partially specialising the `asio::ssociated_executor<>` trait
for all intermediate handlers. This trait forwards to the corresponding trait
specialisation for the final handler:
To achieve this, all asynchronous operations obtain the handler's associated
executor by using the `get_associated_executor` function. For example:
asio::associated_executor_t<Handler> a = asio::get_associated_executor(h);
The associated executor must satisfy the Executor requirements. It will be used
by the asynchronous operation to submit both intermediate and final handlers
for execution.
The executor may be customised for a particular handler type by specifying a
nested type `executor_type` and member function `get_executor()`:
class my_handler
{
public:
// Custom implementation of Executor type requirements.
typedef my_executor executor_type;
// Return a custom executor implementation.
executor_type get_executor() const noexcept
{
return my_executor();
}
void operator()() { ... }
};
In more complex cases, the `associated_executor` template may be partially
specialised directly:
struct my_handler
{
@@ -54,7 +80,8 @@ specialisation for the final handler:
typedef my_executor type;
// Return a custom executor implementation.
static type get(const my_handler&, const Executor& = Executor())
static type get(const my_handler&,
const Executor& = Executor()) noexcept
{
return my_executor();
}
@@ -64,8 +91,8 @@ specialisation for the final handler:
The `asio::bind_executor()` function is a helper to bind a specific executor
object, such as a strand, to a completion handler. This binding automatically
specialises the `associated_executor` trait as shown above. For example, to
bind a strand to a completion handler we would simply write:
associates an executor as shown above. For example, to bind a strand to a
completion handler we would simply write:
my_socket.async_read_some(my_buffer,
asio::bind_executor(my_strand,
@@ -76,6 +103,8 @@ bind a strand to a completion handler we would simply write:
[heading See Also]
[link asio.reference.associated_executor associated_executor],
[link asio.reference.get_associated_executor get_associated_executor],
[link asio.reference.bind_executor bind_executor],
[link asio.reference.strand strand],
[link asio.reference.io_context__strand io_context::strand],

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -18,8 +18,8 @@ concurrently.
Multiple threads may call `io_context::run()` to set up a pool of threads from
which completion handlers may be invoked. This approach may also be used with
`io_context::post()` to use a means to perform any computational tasks across a
thread pool.
`post()` as a means to perform arbitrary computational tasks across a thread
pool.
Note that all threads that have joined an `io_context`'s pool are considered
equivalent, and the `io_context` may distribute work across them in an
@@ -61,6 +61,7 @@ The reasons for this approach include:
[heading See Also]
[link asio.reference.io_context io_context].
[link asio.reference.io_context io_context],
[link asio.reference.post post].
[endsect]

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -2,7 +2,7 @@
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "../../../boost/tools/boostbook/dtd/boostbook.dtd">
<!--
Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Copyright (c) 2003-2017 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)

View File

@@ -213,7 +213,8 @@ PREDEFINED = GENERATING_DOCUMENTATION \
ASIO_CONST_BUFFER=const_buffer \
ASIO_MUTABLE_BUFFER=mutable_buffer \
ASIO_SYNC_OP_VOID=void \
ASIO_STRING_VIEW_PARAM=string_view
ASIO_STRING_VIEW_PARAM=string_view \
ASIO_UNUSED_VARIABLE=
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!--
Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Copyright (c) 2003-2017 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)
@@ -26,7 +26,7 @@
-->
<xsl:template match="/doxygen">
<xsl:text>[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -100,6 +100,7 @@
not(contains(compoundname, '::detail')) and
not(contains(compoundname, '::service::key')) and
not(contains(compoundname, '_handler')) and
not(contains(compoundname, 'std_allocator_void')) and
not(contains(compoundname, 'thread_function')) and
not(contains(compoundname, 'context_impl'))">
<xsl:call-template name="class"/>
@@ -111,6 +112,7 @@
not(contains(ancestor::*/compoundname, '::service::key')) and
not(contains(ancestor::*/compoundname, '_helper')) and
not(contains(name, '_helper')) and
not(contains(name, 'std_allocator_void')) and
not(contains(name, 'thread_function')) and
not(contains(name, 'io_context_impl'))">
<xsl:call-template name="namespace-memberdef"/>
@@ -765,24 +767,9 @@
<xsl:when test="contains($file, 'include/asio/ssl')">
<xsl:text>[^asio/ssl.hpp]</xsl:text>
</xsl:when>
<xsl:when test="contains($file, 'include/asio/high_resolution_timer')">
<xsl:text>None</xsl:text>
</xsl:when>
<xsl:when test="contains($file, 'include/asio/package')">
<xsl:text>None</xsl:text>
</xsl:when>
<xsl:when test="contains($file, 'include/asio/spawn')">
<xsl:text>None</xsl:text>
</xsl:when>
<xsl:when test="contains($file, 'include/asio/steady_timer')">
<xsl:text>None</xsl:text>
</xsl:when>
<xsl:when test="contains($file, 'include/asio/system_timer')">
<xsl:text>None</xsl:text>
</xsl:when>
<xsl:when test="contains($file, 'include/asio/use_future')">
<xsl:text>None</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>[^asio.hpp]</xsl:text>
</xsl:otherwise>
@@ -1363,9 +1350,25 @@
</xsl:text>
<xsl:if test="count(type/ref) &gt; 0 and not(contains(type, '*'))">
<xsl:variable name="class-refid">
<xsl:for-each select="type/ref[1]">
<xsl:value-of select="@refid"/>
</xsl:for-each>
<xsl:choose>
<xsl:when test="type='basic_address_iterator&lt; address_v4 &gt;'">
<xsl:text>classasio_1_1ip_1_1basic__address__iterator_3_01address__v4_01_4</xsl:text>
</xsl:when>
<xsl:when test="type='basic_address_iterator&lt; address_v6 &gt;'">
<xsl:text>classasio_1_1ip_1_1basic__address__iterator_3_01address__v6_01_4</xsl:text>
</xsl:when>
<xsl:when test="type='basic_address_range&lt; address_v4 &gt;'">
<xsl:text>classasio_1_1ip_1_1basic__address__range_3_01address__v4_01_4</xsl:text>
</xsl:when>
<xsl:when test="type='basic_address_range&lt; address_v6 &gt;'">
<xsl:text>classasio_1_1ip_1_1basic__address__range_3_01address__v6_01_4</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="type/ref[1]">
<xsl:value-of select="@refid"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="name" select="name"/>
<xsl:for-each select="/doxygen/compounddef[@id=$class-refid]">
@@ -1517,6 +1520,9 @@
<xsl:when test="declname = 'Function'">
<xsl:value-of select="declname"/>
</xsl:when>
<xsl:when test="declname = 'IoObjectService1'">
<xsl:value-of select="concat('``[link asio.reference.IoObjectService ', declname, ']``')"/>
</xsl:when>
<xsl:when test="declname = 'Iterator'">
<xsl:value-of select="declname"/>
</xsl:when>

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -40,11 +40,9 @@ denotes an identifier.
asio::buffer_sequence_end(x),
asio::buffer_sequence_begin(u),
asio::buffer_sequence_end(u),
[](const typename X::value_type& v1,
const typename X::value_type& v2)
[](const const_buffer& b1,
const const_buffer& b2)
{
const_buffer b1(v1);
const_buffer b2(v2);
return b1.data() == b2.data()
&& b1.size() == b2.size();
})

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -41,11 +41,9 @@ denotes an identifier.
asio::buffer_sequence_end(x),
asio::buffer_sequence_begin(u),
asio::buffer_sequence_end(u),
[](const typename X::value_type& v1,
const typename X::value_type& v2)
[](const mutable_buffer& b1,
const mutable_buffer& b2)
{
mutable_buffer b1(v1);
mutable_buffer b2(v2);
return b1.data() == b2.data()
&& b1.size() == b2.size();
})

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -88,16 +88,23 @@ Since this example uses timers, we need to include the appropriate Boost.Date\_T
All programs that use asio need to have at least one asio::io\_service object. This class provides access to I/O functionality. We declare an object of this type first thing in the main function.
All programs that use asio need to have at least one
[link asio.reference.io_context io_context] object. This class provides access to I/O functionality. We declare an object of this type first thing in the main function.
``''''''``int main()
``''''''``{
``''''''`` asio::io_context io;
Next we declare an object of type asio::deadline\_timer. The core asio classes that provide I/O functionality (or as in this case timer functionality) always take a reference to an io\_service as their first constructor argument. The second argument to the constructor sets the timer to expire 5 seconds from now.
Next we declare an object of type asio::deadline\_timer. The core asio classes that provide I/O functionality (or as in this case timer functionality) always take a reference to an io\_context as their first constructor argument. The second argument to the constructor sets the timer to expire 5 seconds from now.
``''''''`` asio::deadline_timer t(io, boost::posix_time::seconds(5));
In this simple example we perform a blocking wait on the timer. That is, the call to [link asio.reference.basic_deadline_timer.wait deadline_timer::wait()] will not return until the timer has expired, 5 seconds after it was created (i.e. not from when the wait starts).
@@ -105,6 +112,7 @@ In this simple example we perform a blocking wait on the timer. That is, the cal
A deadline timer is always in one of two states: "expired" or "not expired". If the [link asio.reference.basic_deadline_timer.wait deadline_timer::wait()] function is called on an expired timer, it will return immediately.
``''''''`` t.wait();
@@ -112,6 +120,11 @@ Finally we print the obligatory `"Hello, world!"` message to show when the timer
``''''''`` std::cout << "Hello, world!" << std::endl;
``''''''`` return 0;
``''''''``}
See the [link asio.tutorial.tuttimer1.src full source listing]
@@ -129,7 +142,7 @@ Next: [link asio.tutorial.tuttimer2 Timer.2 - Using a timer asynchronously]
``''''''``// timer.cpp
``''''''``// ~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -196,13 +209,13 @@ Next, instead of doing a blocking wait as in tutorial Timer.1, we call the [link
Finally, we must call the [link asio.reference.io_context.run io_service::run()] member function on the io\_service object.
Finally, we must call the [link asio.reference.io_context.run io_context::run()] member function on the io\_context object.
The asio library provides a guarantee that callback handlers will only be called from threads that are currently calling [link asio.reference.io_context.run io_service::run()]. Therefore unless the [link asio.reference.io_context.run io_service::run()] function is called the callback for the asynchronous wait completion will never be invoked.
The asio library provides a guarantee that callback handlers will only be called from threads that are currently calling [link asio.reference.io_context.run io_context::run()]. Therefore unless the [link asio.reference.io_context.run io_context::run()] function is called the callback for the asynchronous wait completion will never be invoked.
The [link asio.reference.io_context.run io_service::run()] function will also continue to run while there is still "work" to do. In this example, the work is the asynchronous wait on the timer, so the call will not return until the timer has expired and the callback has completed.
The [link asio.reference.io_context.run io_context::run()] function will also continue to run while there is still "work" to do. In this example, the work is the asynchronous wait on the timer, so the call will not return until the timer has expired and the callback has completed.
It is important to remember to give the io\_service some work to do before calling [link asio.reference.io_context.run io_service::run()]. For example, if we had omitted the above call to [link asio.reference.basic_deadline_timer.async_wait deadline_timer::async_wait()], the io\_service would not have had any work to do, and consequently [link asio.reference.io_context.run io_service::run()] would have returned immediately.
It is important to remember to give the io\_context some work to do before calling [link asio.reference.io_context.run io_context::run()]. For example, if we had omitted the above call to [link asio.reference.basic_deadline_timer.async_wait deadline_timer::async_wait()], the io\_context would not have had any work to do, and consequently [link asio.reference.io_context.run io_context::run()] would have returned immediately.
``''''''`` io.run();
@@ -229,7 +242,7 @@ Next: [link asio.tutorial.tuttimer3 Timer.3 - Binding arguments to a handler]
``''''''``// timer.cpp
``''''''``// ~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -294,7 +307,7 @@ To implement a repeating timer using asio you need to change the timer's expiry
As mentioned above, this tutorial program uses a counter to stop running when the timer fires for the sixth time. However you will observe that there is no explicit call to ask the io\_service to stop. Recall that in tutorial Timer.2 we learnt that the [link asio.reference.io_context.run io_service::run()] function completes when there is no more "work" to do. By not starting a new asynchronous wait on the timer when `count` reaches 5, the io\_service will run out of work and stop running.
As mentioned above, this tutorial program uses a counter to stop running when the timer fires for the sixth time. However you will observe that there is no explicit call to ask the io\_context to stop. Recall that in tutorial Timer.2 we learnt that the [link asio.reference.io_context.run io_context::run()] function completes when there is no more "work" to do. By not starting a new asynchronous wait on the timer when `count` reaches 5, the io\_context will run out of work and stop running.
``''''''`` if (*count < 5)
@@ -319,6 +332,14 @@ See the [@http://www.boost.org/libs/bind/bind.html Boost.Bind documentation] for
In this example, the asio::placeholders::error argument to [link asio.tutorial.boost_bind boost::bind] is a named placeholder for the error object passed to the handler. When initiating the asynchronous operation, and if using [link asio.tutorial.boost_bind boost::bind] , you must specify only the arguments that match the handler's parameter list. In tutorial Timer.4 you will see that this placeholder may be elided if the parameter is not needed by the callback handler.
``''''''`` t->async_wait(boost::bind(print,
``''''''`` asio::placeholders::error, t, count));
``''''''`` }
``''''''``}
``''''''``int main()
``''''''``{
``''''''`` asio::io_context io;
@@ -326,11 +347,18 @@ A new `count` variable is added so that we can stop the program when the timer f
``''''''`` int count = 0;
``''''''`` asio::deadline_timer t(io, boost::posix_time::seconds(1));
As in Step 4, when making the call to [link asio.reference.basic_deadline_timer.async_wait deadline_timer::async_wait()] from `main` we bind the additional parameters needed for the `print` function.
``''''''`` t.async_wait(boost::bind(print,
``''''''`` asio::placeholders::error, &t, &count));
``''''''`` io.run();
@@ -338,6 +366,11 @@ Finally, just to prove that the `count` variable was being used in the `print` h
``''''''`` std::cout << "Final count is " << count << std::endl;
``''''''`` return 0;
``''''''``}
See the [link asio.tutorial.tuttimer3.src full source listing]
@@ -357,7 +390,7 @@ Next: [link asio.tutorial.tuttimer4 Timer.4 - Using a member function as a handl
``''''''``// timer.cpp
``''''''``// ~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -430,7 +463,7 @@ Instead of defining a free function `print` as the callback handler, as we did i
The constructor of this class will take a reference to the io\_service object and use it when initialising the `timer_` member. The counter used to shut down the program is now also a member of the class.
The constructor of this class will take a reference to the io\_context object and use it when initialising the `timer_` member. The counter used to shut down the program is now also a member of the class.
``''''''`` printer(asio::io_context& io)
@@ -484,7 +517,7 @@ The `print` member function is very similar to the `print` function from tutoria
The `main` function is much simpler than before, as it now declares a local `printer` object before running the io\_service as normal.
The `main` function is much simpler than before, as it now declares a local `printer` object before running the io\_context as normal.
@@ -518,7 +551,7 @@ Next: [link asio.tutorial.tuttimer5 Timer.5 - Synchronising handlers in multithr
``''''''``// timer.cpp
``''''''``// ~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -578,9 +611,10 @@ Return to [link asio.tutorial.tuttimer4 Timer.4 - Using a member function as a h
[section:tuttimer5 Timer.5 - Synchronising handlers in multithreaded programs]
This tutorial demonstrates the use of the asio::io\_service::strand class to synchronise callback handlers in a multithreaded program.
This tutorial demonstrates the use of the
[link asio.reference.io_context__strand io_context::strand] class to synchronise callback handlers in a multithreaded program.
The previous four tutorials avoided the issue of handler synchronisation by calling the [link asio.reference.io_context.run io_service::run()] function from one thread only. As you already know, the asio library provides a guarantee that callback handlers will only be called from threads that are currently calling [link asio.reference.io_context.run io_service::run()]. Consequently, calling [link asio.reference.io_context.run io_service::run()] from only one thread ensures that callback handlers cannot run concurrently.
The previous four tutorials avoided the issue of handler synchronisation by calling the [link asio.reference.io_context.run io_context::run()] function from one thread only. As you already know, the asio library provides a guarantee that callback handlers will only be called from threads that are currently calling [link asio.reference.io_context.run io_context::run()]. Consequently, calling [link asio.reference.io_context.run io_context::run()] from only one thread ensures that callback handlers cannot run concurrently.
The single threaded approach is usually the best place to start when developing applications using asio. The downside is the limitations it places on programs, particularly servers, including:
@@ -592,7 +626,7 @@ The single threaded approach is usually the best place to start when developing
If you find yourself running into these limitations, an alternative approach is to have a pool of threads calling [link asio.reference.io_context.run io_service::run()]. However, as this allows handlers to execute concurrently, we need a method of synchronisation when handlers might be accessing a shared, thread-unsafe resource.
If you find yourself running into these limitations, an alternative approach is to have a pool of threads calling [link asio.reference.io_context.run io_context::run()]. However, as this allows handlers to execute concurrently, we need a method of synchronisation when handlers might be accessing a shared, thread-unsafe resource.
@@ -616,9 +650,13 @@ We start by defining a class called `printer`, similar to the class in the previ
In addition to initialising a pair of asio::deadline\_timer members, the constructor initialises the `strand_` member, an object of type asio::io\_service::strand.
In addition to initialising a pair of asio::deadline\_timer members, the constructor initialises the `strand_` member, an object of type
[link asio.reference.io_context__strand io_context::strand].
An asio::io\_service::strand is an executor that guarantees that, for those handlers that are dispatched through it, an executing handler will be allowed to complete before the next one is started. This is guaranteed irrespective of the number of threads that are calling [link asio.reference.io_context.run io_service::run()]. Of course, the handlers may still execute concurrently with other handlers that were not dispatched through an asio::io\_service::strand, or were dispatched through a different asio::io\_service::strand object.
An
[link asio.reference.io_context__strand io_context::strand] is an executor that guarantees that, for those handlers that are dispatched through it, an executing handler will be allowed to complete before the next one is started. This is guaranteed irrespective of the number of threads that are calling [link asio.reference.io_context.run io_context::run()]. Of course, the handlers may still execute concurrently with other handlers that were not dispatched through an
[link asio.reference.io_context__strand io_context::strand], or were dispatched through a different
[link asio.reference.io_context__strand io_context::strand] object.
``''''''`` printer(asio::io_context& io)
@@ -630,7 +668,10 @@ An asio::io\_service::strand is an executor that guarantees that, for those hand
When initiating the asynchronous operations, each callback handler is "bound" to an asio::io\_service::strand object. The asio::io\_service::strand::bind\_executor() function returns a new handler that automatically dispatches its contained handler through the asio::io\_service::strand object. By binding the handlers to the same asio::io\_service::strand, we are ensuring that they cannot execute concurrently.
When initiating the asynchronous operations, each callback handler is "bound" to an
[link asio.reference.io_context__strand io_context::strand] object. The asio::io\_context::strand::bind\_executor() function returns a new handler that automatically dispatches its contained handler through the
[link asio.reference.io_context__strand io_context::strand] object. By binding the handlers to the same
[link asio.reference.io_context__strand io_context::strand], we are ensuring that they cannot execute concurrently.
``''''''`` timer1_.async_wait(asio::bind_executor(strand_,
@@ -688,10 +729,10 @@ In a multithreaded program, the handlers for asynchronous operations should be s
The `main` function now causes [link asio.reference.io_context.run io_service::run()] to be called from two threads: the main thread and one additional thread. This is accomplished using an
The `main` function now causes [link asio.reference.io_context.run io_context::run()] to be called from two threads: the main thread and one additional thread. This is accomplished using an
[link asio.reference.thread thread] object.
Just as it would with a call from a single thread, concurrent calls to [link asio.reference.io_context.run io_service::run()] will continue to execute while there is "work" left to do. The background thread will not exit until all asynchronous operations have completed.
Just as it would with a call from a single thread, concurrent calls to [link asio.reference.io_context.run io_context::run()] will continue to execute while there is "work" left to do. The background thread will not exit until all asynchronous operations have completed.
@@ -725,7 +766,7 @@ Previous: [link asio.tutorial.tuttimer4 Timer.4 - Using a member function as a h
``''''''``// timer.cpp
``''''''``// ~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -844,16 +885,21 @@ The purpose of this application is to access a daytime service, so we need the u
All programs that use asio need to have at least one asio::io\_service object.
All programs that use asio need to have at least one
[link asio.reference.io_context io_context] object.
``''''''`` asio::io_context io_context;
We need to turn the server name that was specified as a parameter to the application, into a TCP endpoint. To do this we use an [link asio.reference.ip__tcp.resolver ip::tcp::resolver] object.
``''''''`` tcp::resolver resolver(io_context);
A resolver takes a query object and turns it into a list of endpoints. We construct a query using the name of the server, specified in `argv[1]`, and the name of the service, in this case `"daytime"`.
@@ -909,7 +955,7 @@ Next: [link asio.tutorial.tutdaytime2 Daytime.2 - A synchronous TCP daytime serv
``''''''``// client.cpp
``''''''``// ~~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -991,29 +1037,63 @@ We define the function `make_daytime_string()` to create the string to be sent b
``''''''``std::string make_daytime_string()
``''''''``{
``''''''`` using namespace std; // For time_t, time and ctime;
``''''''`` time_t now = time(0);
``''''''`` return ctime(&now);
``''''''``}
``''''''``int main()
``''''''``{
``''''''`` try
``''''''`` {
``''''''`` asio::io_context io_context;
A [link asio.reference.ip__tcp.acceptor ip::tcp::acceptor] object needs to be created to listen for new connections. It is initialised to listen on TCP port 13, for IP version 4.
``''''''`` tcp::acceptor acceptor(io_context, tcp::endpoint(tcp::v4(), 13));
This is an iterative server, which means that it will handle one connection at a time. Create a socket that will represent the connection to the client, and then wait for a connection.
``''''''`` for (;;)
``''''''`` {
``''''''`` tcp::socket socket(io_context);
``''''''`` acceptor.accept(socket);
A client is accessing our service. Determine the current time and transfer this information to the client.
``''''''`` std::string message = make_daytime_string();
``''''''`` asio::error_code ignored_error;
``''''''`` asio::write(socket, asio::buffer(message), ignored_error);
``''''''`` }
``''''''`` }
Finally, handle any exceptions.
``''''''`` catch (std::exception& e)
``''''''`` {
``''''''`` std::cerr << e.what() << std::endl;
``''''''`` }
``''''''`` return 0;
``''''''``}
@@ -1034,7 +1114,7 @@ Next: [link asio.tutorial.tutdaytime3 Daytime.3 - An asynchronous TCP daytime se
``''''''``// server.cpp
``''''''``// ~~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -1099,7 +1179,8 @@ Return to [link asio.tutorial.tutdaytime2 Daytime.2 - A synchronous TCP daytime
We need to create a server object to accept incoming client connections. The asio::io\_service object provides I/O services, such as sockets, that the server object will use.
We need to create a server object to accept incoming client connections. The
[link asio.reference.io_context io_context] object provides I/O services, such as sockets, that the server object will use.
``''''''`` asio::io_context io_context;
@@ -1107,7 +1188,8 @@ We need to create a server object to accept incoming client connections. The asi
Run the asio::io\_service object so that it will perform asynchronous operations on your behalf.
Run the
[link asio.reference.io_context io_context] object so that it will perform asynchronous operations on your behalf.
``''''''`` io_context.run();
@@ -1284,7 +1366,7 @@ Next: [link asio.tutorial.tutdaytime4 Daytime.4 - A synchronous UDP daytime clie
``''''''``// server.cpp
``''''''``// ~~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -1421,18 +1503,43 @@ The start of the application is essentially the same as for the TCP daytime clie
``''''''``int main(int argc, char* argv[])
``''''''``{
``''''''`` try
``''''''`` {
``''''''`` if (argc != 2)
``''''''`` {
``''''''`` std::cerr << "Usage: client <host>" << std::endl;
``''''''`` return 1;
``''''''`` }
``''''''`` asio::io_context io_context;
We use an [link asio.reference.ip__udp.resolver ip::udp::resolver] object to find the correct remote endpoint to use based on the host and service names. The query is restricted to return only IPv4 endpoints by the [link asio.reference.ip__udp.v4 ip::udp::v4()] argument.
``''''''`` udp::resolver resolver(io_context);
``''''''`` udp::endpoint receiver_endpoint =
``''''''`` *resolver.resolve(udp::v4(), argv[1], "daytime").begin();
The [link asio.reference.ip__basic_resolver.resolve ip::udp::resolver::resolve()] function is guaranteed to return at least one endpoint in the list if it does not fail. This means it is safe to dereference the return value directly.
``''''''`` udp::socket socket(io_context);
``''''''`` socket.open(udp::v4());
``''''''`` boost::array<char, 1> send_buf = {{ 0 }};
``''''''`` socket.send_to(asio::buffer(send_buf), receiver_endpoint);
``''''''`` boost::array<char, 128> recv_buf;
``''''''`` udp::endpoint sender_endpoint;
Since UDP is datagram-oriented, we will not be using a stream socket. Create an [link asio.reference.ip__udp.socket ip::udp::socket] and initiate contact with the remote endpoint.
@@ -1468,7 +1575,7 @@ Next: [link asio.tutorial.tutdaytime5 Daytime.5 - A synchronous UDP daytime serv
``''''''``// client.cpp
``''''''``// ~~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -1528,6 +1635,11 @@ Return to [link asio.tutorial.tutdaytime4 Daytime.4 - A synchronous UDP daytime
This tutorial program shows how to use asio to implement a server application with UDP.
``''''''``int main()
``''''''``{
``''''''`` try
``''''''`` {
``''''''`` asio::io_context io_context;
@@ -1535,6 +1647,8 @@ Create an [link asio.reference.ip__udp.socket ip::udp::socket] object to receive
``''''''`` udp::socket socket(io_context, udp::endpoint(udp::v4(), 13));
Wait for a client to initiate contact with us. The remote\_endpoint object will be populated by [link asio.reference.basic_datagram_socket.receive_from ip::udp::socket::receive_from()].
@@ -1578,7 +1692,7 @@ Next: [link asio.tutorial.tutdaytime6 Daytime.6 - An asynchronous UDP daytime se
``''''''``// server.cpp
``''''''``// ~~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -1612,11 +1726,7 @@ Next: [link asio.tutorial.tutdaytime6 Daytime.6 - An asynchronous UDP daytime se
``''''''`` boost::array<char, 1> recv_buf;
``''''''`` udp::endpoint remote_endpoint;
``''''''`` asio::error_code error;
``''''''`` socket.receive_from(asio::buffer(recv_buf),
``''''''`` remote_endpoint, 0, error);
``''''''`` if (error && error != asio::error::message_size)
``''''''`` throw asio::system_error(error);
``''''''`` socket.receive_from(asio::buffer(recv_buf), remote_endpoint);
``''''''`` std::string message = make_daytime_string();
@@ -1651,7 +1761,8 @@ Return to [link asio.tutorial.tutdaytime5 Daytime.5 - A synchronous UDP daytime
Create a server object to accept incoming client requests, and run the asio::io\_service object.
Create a server object to accept incoming client requests, and run the
[link asio.reference.io_context io_context] object.
``''''''`` asio::io_context io_context;
@@ -1692,7 +1803,8 @@ The constructor initialises a socket to listen on UDP port 13.
The function [link asio.reference.basic_datagram_socket.async_receive_from ip::udp::socket::async_receive_from()] will cause the application to listen in the background for a new request. When such a request is received, the asio::io\_service object will invoke the `handle_receive()` function with two arguments: a value of type
The function [link asio.reference.basic_datagram_socket.async_receive_from ip::udp::socket::async_receive_from()] will cause the application to listen in the background for a new request. When such a request is received, the
[link asio.reference.io_context io_context] object will invoke the `handle_receive()` function with two arguments: a value of type
[link asio.reference.error_code error_code] indicating whether the operation succeeded or failed, and a `size_t` value `bytes_transferred` specifying the number of bytes received.
@@ -1715,10 +1827,11 @@ The function `handle_receive()` will service the client request.
The `error` parameter contains the result of the asynchronous operation. Since we only provide the 1-byte `recv_buffer_` to contain the client's request, the asio::io\_service object would return an error if the client sent anything larger. We can ignore such an error if it comes up.
The `error` parameter contains the result of the asynchronous operation. Since we only provide the 1-byte `recv_buffer_` to contain the client's request, the
[link asio.reference.io_context io_context] object would return an error if the client sent anything larger. We can ignore such an error if it comes up.
``''''''`` if (!error || error == asio::error::message_size)
``''''''`` if (!error)
``''''''`` {
@@ -1794,7 +1907,7 @@ Next: [link asio.tutorial.tutdaytime7 Daytime.7 - A combined TCP/UDP asynchronou
``''''''``// server.cpp
``''''''``// ~~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -1839,7 +1952,7 @@ Next: [link asio.tutorial.tutdaytime7 Daytime.7 - A combined TCP/UDP asynchronou
``''''''`` void handle_receive(const asio::error_code& error,
``''''''`` std::size_t /*bytes_transferred*/)
``''''''`` {
``''''''`` if (!error || error == asio::error::message_size)
``''''''`` if (!error)
``''''''`` {
``''''''`` boost::shared_ptr<std::string> message(
``''''''`` new std::string(make_daytime_string()));
@@ -1893,24 +2006,41 @@ This tutorial program shows how to combine the two asynchronous servers that we
[heading The main() function]
``''''''``int main()
``''''''``{
``''''''`` try
``''''''`` {
``''''''`` asio::io_context io_context;
We will begin by creating a server object to accept a TCP client connection.
``''''''`` tcp_server server1(io_context);
We also need a server object to accept a UDP client request.
``''''''`` udp_server server2(io_context);
We have created two lots of work for the asio::io\_service object to do.
We have created two lots of work for the
[link asio.reference.io_context io_context] object to do.
``''''''`` io_context.run();
``''''''`` }
``''''''`` catch (std::exception& e)
``''''''`` {
``''''''`` std::cerr << e.what() << std::endl;
``''''''`` }
``''''''`` return 0;
``''''''``}
@@ -2018,7 +2148,7 @@ Similarly, this next class is taken from the [link asio.tutorial.tutdaytime6 pre
``''''''`` void handle_receive(const asio::error_code& error)
``''''''`` {
``''''''`` if (!error || error == asio::error::message_size)
``''''''`` if (!error)
``''''''`` {
``''''''`` boost::shared_ptr<std::string> message(
``''''''`` new std::string(make_daytime_string()));
@@ -2056,7 +2186,7 @@ Previous: [link asio.tutorial.tutdaytime6 Daytime.6 - An asynchronous UDP daytim
``''''''``// server.cpp
``''''''``// ~~~~~~~~~~
``''''''``//
``''''''``// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
``''''''``// Copyright (c) 2003-2017 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)
@@ -2173,7 +2303,7 @@ Previous: [link asio.tutorial.tutdaytime6 Daytime.6 - An asynchronous UDP daytim
``''''''`` void handle_receive(const asio::error_code& error)
``''''''`` {
``''''''`` if (!error || error == asio::error::message_size)
``''''''`` if (!error)
``''''''`` {
``''''''`` boost::shared_ptr<std::string> message(
``''''''`` new std::string(make_daytime_string()));

View File

@@ -2,7 +2,7 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!--
Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Copyright (c) 2003-2017 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)
@@ -20,7 +20,7 @@
<xsl:template match="/doxygen">
<xsl:text>[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)

View File

@@ -1,5 +1,5 @@
[/
/ Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
/ Copyright (c) 2003-2017 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)
@@ -9,28 +9,37 @@
[heading Supported Platforms]
The following platforms and compilers have been tested:
The following platform and compiler combinations are regularly tested:
* Win32 and Win64 using Visual C++ 7.1 and Visual C++ 8.0.
* Win32 using MinGW.
* Win32 using Cygwin. (`__USE_W32_SOCKETS` must be defined.)
* Linux (2.4 or 2.6 kernels) using g++ 3.3 or later.
* Solaris using g++ 3.3 or later.
* Mac OS X 10.4 using g++ 3.3 or later.
* Linux using g++ 4.1 or later
* Linux using clang 3.2 or later
* FreeBSD using g++ 4.1 or later
* macOS using Xcode 8 or later
* Win32 using Visual C++ 9.0 or later
* Win32 using g++ 4.1 or later (MinGW)
* Win64 using Visual C++ 9.0 or later
The following platforms may also work:
* AIX 5.3 using XL C/C++ v9.
* HP-UX 11i v3 using patched aC++ A.06.14.
* QNX Neutrino 6.3 using g++ 3.3 or later.
* Solaris using Sun Studio 11 or later.
* Tru64 v5.1 using Compaq C++ v7.1.
* AIX
* Android
* HP-UX
* iOS
* NetBSD
* OpenBSD
* QNX Neutrino
* Solaris
* Tru64
* Win32 using Cygwin. (`__USE_W32_SOCKETS` must be defined.)
[heading Dependencies]
The following libraries must be available in order to link programs that use
Asio:
* Boost.Coroutine (optional) if you use [link asio.reference.spawn
`spawn()`] to launch coroutines.
* Boost.Regex (optional) if you use any of the [link
asio.reference.read_until `read_until()`] or [link
asio.reference.async_read_until `async_read_until()`] overloads that take
@@ -85,7 +94,7 @@ working correctly, run `make check`.
[heading Building the tests and examples with MSVC]
To build using the MSVC 7.1 or MSVC 8.0 command line compiler, perform the
To build using the MSVC 9.0 (or later) command line compiler, perform the
following steps in a Command Prompt window:
* If you are using a version of boost other than 1.34.1, or if the boost
@@ -139,9 +148,9 @@ Asio.
std::string object being written is destroyed before the write operation
completes).
When using Microsoft Visual C++, this macro is defined automatically if
the compiler's iterator debugging support is enabled, unless
`ASIO_DISABLE_BUFFER_DEBUGGING` has been defined.
When using Microsoft Visual C++ 11.0 or later, this macro is defined
automatically if the compiler's iterator debugging support is enabled,
unless `ASIO_DISABLE_BUFFER_DEBUGGING` has been defined.
When using g++, this macro is defined automatically if standard library
debugging is enabled (`_GLIBCXX_DEBUG` is defined), unless
@@ -178,7 +187,7 @@ Asio.
[
[`ASIO_DISABLE_KQUEUE`]
[
Explicitly disables `kqueue` support on Mac OS X and BSD variants,
Explicitly disables `kqueue` support on macOS and BSD variants,
forcing the use of a `select`-based implementation.
]
]
@@ -225,22 +234,6 @@ Asio.
prevents these libraries from being linked.
]
]
[
[`ASIO_SOCKET_STREAMBUF_MAX_ARITY`]
[
Determines the maximum number of arguments that may be passed to the
`basic_socket_streambuf` class template's `connect` member function.
Defaults to 5.
]
]
[
[`ASIO_SOCKET_IOSTREAM_MAX_ARITY`]
[
Determines the maximum number of arguments that may be passed to the
`basic_socket_iostream` class template's constructor and `connect` member
function. Defaults to 5.
]
]
[
[`ASIO_ENABLE_CANCELIO`]
[
@@ -299,6 +292,16 @@ Asio.
the map.
]
]
[
[`ASIO_ENABLE_OLD_SERVICES`]
[
The service template parameters, and the corresponding classes, are
disabled by default. For example, instead of `basic_socket<Protocol,
SocketService>` we now have simply `basic_socket<Protocol>`. The old
interface can be enabled by defining the `ASIO_ENABLE_OLD_SERVICES`
macro.
]
]
]
[heading Mailing List]

View File

@@ -2,7 +2,7 @@
// server.cpp
// ~~~~~~~~~~
//
// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2017 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)
@@ -24,11 +24,11 @@ using asio::ip::tcp;
// It contains a single block of memory which may be returned for allocation
// requests. If the memory is in use when an allocation request is made, the
// allocator delegates allocation to the global heap.
class handler_allocator
class handler_memory
: private boost::noncopyable
{
public:
handler_allocator()
handler_memory()
: in_use_(false)
{
}
@@ -66,19 +66,78 @@ private:
bool in_use_;
};
// The allocator to be associated with the handler objects. This allocator only
// needs to satisfy the C++11 minimal allocator requirements, plus rebind when
// targeting C++03.
template <typename T>
class handler_allocator
{
public:
typedef T value_type;
explicit handler_allocator(handler_memory& mem)
: memory_(mem)
{
}
template <typename U>
handler_allocator(const handler_allocator<U>& other)
: memory_(other.memory_)
{
}
template <typename U>
struct rebind
{
typedef handler_allocator<U> other;
};
bool operator==(const handler_allocator& other) const
{
return &memory_ == &other.memory_;
}
bool operator!=(const handler_allocator& other) const
{
return &memory_ != &other.memory_;
}
T* allocate(std::size_t n) const
{
return static_cast<T*>(memory_.allocate(sizeof(T) * n));
}
void deallocate(T* p, std::size_t /*n*/) const
{
return memory_.deallocate(p);
}
//private:
// The underlying memory.
handler_memory& memory_;
};
// Wrapper class template for handler objects to allow handler memory
// allocation to be customised. Calls to operator() are forwarded to the
// encapsulated handler.
// allocation to be customised. The allocator_type typedef and get_allocator()
// member function are used by the asynchronous operations to obtain the
// allocator. Calls to operator() are forwarded to the encapsulated handler.
template <typename Handler>
class custom_alloc_handler
{
public:
custom_alloc_handler(handler_allocator& a, Handler h)
: allocator_(a),
typedef handler_allocator<Handler> allocator_type;
custom_alloc_handler(handler_memory& m, Handler h)
: memory_(m),
handler_(h)
{
}
allocator_type get_allocator() const
{
return allocator_type(memory_);
}
template <typename Arg1>
void operator()(Arg1 arg1)
{
@@ -91,29 +150,17 @@ public:
handler_(arg1, arg2);
}
friend void* asio_handler_allocate(std::size_t size,
custom_alloc_handler<Handler>* this_handler)
{
return this_handler->allocator_.allocate(size);
}
friend void asio_handler_deallocate(void* pointer, std::size_t /*size*/,
custom_alloc_handler<Handler>* this_handler)
{
this_handler->allocator_.deallocate(pointer);
}
private:
handler_allocator& allocator_;
handler_memory& memory_;
Handler handler_;
};
// Helper function to wrap a handler object to add custom allocation.
template <typename Handler>
inline custom_alloc_handler<Handler> make_custom_alloc_handler(
handler_allocator& a, Handler h)
handler_memory& m, Handler h)
{
return custom_alloc_handler<Handler>(a, h);
return custom_alloc_handler<Handler>(m, h);
}
class session
@@ -133,7 +180,7 @@ public:
void start()
{
socket_.async_read_some(asio::buffer(data_),
make_custom_alloc_handler(allocator_,
make_custom_alloc_handler(handler_memory_,
boost::bind(&session::handle_read,
shared_from_this(),
asio::placeholders::error,
@@ -147,7 +194,7 @@ public:
{
asio::async_write(socket_,
asio::buffer(data_, bytes_transferred),
make_custom_alloc_handler(allocator_,
make_custom_alloc_handler(handler_memory_,
boost::bind(&session::handle_write,
shared_from_this(),
asio::placeholders::error)));
@@ -159,7 +206,7 @@ public:
if (!error)
{
socket_.async_read_some(asio::buffer(data_),
make_custom_alloc_handler(allocator_,
make_custom_alloc_handler(handler_memory_,
boost::bind(&session::handle_read,
shared_from_this(),
asio::placeholders::error,
@@ -174,8 +221,8 @@ private:
// Buffer used to store data received from the client.
boost::array<char, 1024> data_;
// The allocator to use for handler-based custom memory allocation.
handler_allocator allocator_;
// The memory to use for handler-based custom memory allocation.
handler_memory handler_memory_;
};
typedef boost::shared_ptr<session> session_ptr;

View File

@@ -2,7 +2,7 @@
// reference_counted.cpp
// ~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2017 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)

View File

@@ -2,7 +2,7 @@
// chat_client.cpp
// ~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2017 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)

View File

@@ -2,7 +2,7 @@
// chat_message.hpp
// ~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2017 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)

Some files were not shown because too many files have changed in this diff Show More