Skip to content

Commit

Permalink
Initial merge of Networking TS compatibility.
Browse files Browse the repository at this point in the history
Merged from chriskohlhoff/asio master branch as of commit
4a4d28b.
  • Loading branch information
chriskohlhoff committed Oct 23, 2017
1 parent b002097 commit b60e92b
Show file tree
Hide file tree
Showing 617 changed files with 43,295 additions and 21,609 deletions.
8 changes: 6 additions & 2 deletions doc/asio.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
]

[template mdash[] '''— ''']
[template indexterm1[term1] '''<indexterm><primary>'''[term1]'''</primary></indexterm>''']
[template indexterm2[term1 term2] '''<indexterm><primary>'''[term1]'''</primary><secondary>'''[term2]'''</secondary></indexterm>''']
[template half_open_range[text] '''&#91;'''[text])]
[template indexterm1[id term1] '''<indexterm id="'''[id]'''"><primary>'''[term1]'''</primary></indexterm>''']
[template indexterm2[id term1 term2] '''<indexterm id="'''[id]'''"><primary>'''[term1]'''</primary><secondary>'''[term2]'''</secondary></indexterm>''']
[template inline_note[text] \[['Note:] [text] '''&mdash;'''['end note]\] ]
[template ticket[number]'''<ulink url="https://svn.boost.org/trac/boost/ticket/'''[number]'''">'''#[number]'''</ulink>''']
[def __POSIX__ /POSIX/]
[def __Windows__ /Windows/]
Expand All @@ -31,9 +33,11 @@
[def __getsockname__ [@http://www.opengroup.org/onlinepubs/000095399/functions/getsockname.html `getsockname()`]]
[def __getsockopt__ [@http://www.opengroup.org/onlinepubs/000095399/functions/getsockopt.html `getsockopt()`]]
[def __ioctl__ [@http://www.opengroup.org/onlinepubs/000095399/functions/ioctl.html `ioctl()`]]
[def __poll__ [@http://www.opengroup.org/onlinepubs/000095399/functions/poll.html `poll()`]]
[def __recvfrom__ [@http://www.opengroup.org/onlinepubs/000095399/functions/recvfrom.html `recvfrom()`]]
[def __sendto__ [@http://www.opengroup.org/onlinepubs/000095399/functions/sendto.html `sendto()`]]
[def __setsockopt__ [@http://www.opengroup.org/onlinepubs/000095399/functions/setsockopt.html `setsockopt()`]]
[def __shutdown__ [@http://www.opengroup.org/onlinepubs/000095399/functions/shutdown.html `shutdown()`]]
[def __socket__ [@http://www.opengroup.org/onlinepubs/000095399/functions/socket.html `socket()`]]

[/=============================================================================]
Expand Down
10 changes: 5 additions & 5 deletions doc/examples.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ cancelling all outstanding asynchronous operations.

[heading HTTP Server 2]

An HTTP server using an io_service-per-CPU design.
An HTTP server using an io_context-per-CPU design.

* [@boost_asio/example/cpp03/http/server2/connection.cpp]
* [@boost_asio/example/cpp03/http/server2/connection.hpp]
* [@boost_asio/example/cpp03/http/server2/header.hpp]
* [@boost_asio/example/cpp03/http/server2/io_service_pool.cpp]
* [@boost_asio/example/cpp03/http/server2/io_service_pool.hpp]
* [@boost_asio/example/cpp03/http/server2/io_context_pool.cpp]
* [@boost_asio/example/cpp03/http/server2/io_context_pool.hpp]
* [@boost_asio/example/cpp03/http/server2/main.cpp]
* [@boost_asio/example/cpp03/http/server2/mime_types.cpp]
* [@boost_asio/example/cpp03/http/server2/mime_types.hpp]
Expand All @@ -139,7 +139,7 @@ An HTTP server using an io_service-per-CPU design.

[heading HTTP Server 3]

An HTTP server using a single io_service and a thread pool calling `io_service::run()`.
An HTTP server using a single io_context and a thread pool calling `io_context::run()`.

* [@boost_asio/example/cpp03/http/server3/connection.cpp]
* [@boost_asio/example/cpp03/http/server3/connection.hpp]
Expand Down Expand Up @@ -227,7 +227,7 @@ decode structures for transmission over a socket.
[heading Services]

This example demonstrates how to integrate custom functionality (in this case,
for logging) into asio's [link boost_asio.reference.io_service io_service], and
for logging) into asio's [link boost_asio.reference.io_context io_context], and
how to use a custom service with [link
boost_asio.reference.basic_stream_socket basic_stream_socket<>].

Expand Down
10 changes: 5 additions & 5 deletions doc/overview/async.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ read or write on a socket.]
[mdash] Asynchronous Operation Processor

[:Executes asynchronous operations and queues events on a completion event
queue when operations complete. From a high-level point of view, services like
`stream_socket_service` are asynchronous operation processors.]
queue when operations complete. From a high-level point of view, internal
services like `reactive_socket_service` are asynchronous operation processors.]

[mdash] Completion Event Queue

Expand All @@ -52,14 +52,14 @@ a completed event to its caller.]

[:Calls the asynchronous event demultiplexer to dequeue events, and dispatches
the completion handler (i.e. invokes the function object) associated with the
event. This abstraction is represented by the `io_service` class.]
event. This abstraction is represented by the `io_context` class.]

[mdash] Initiator

[:Application-specific code that starts asynchronous operations. The initiator
interacts with an asynchronous operation processor via a high-level interface
such as `basic_stream_socket`, which in turn delegates to a service like
`stream_socket_service`.]
`reactive_socket_service`.]

[heading Implementation Using Reactor]

Expand Down Expand Up @@ -97,7 +97,7 @@ calling an overlapped function such as `AcceptEx`.]
[mdash] Completion Event Queue

[:This is implemented by the operating system, and is associated with an I/O
completion port. There is one I/O completion port for each `io_service`
completion port. There is one I/O completion port for each `io_context`
instance.]

[mdash] Asynchronous Event Demultiplexer
Expand Down
28 changes: 14 additions & 14 deletions doc/overview/basics.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ operations.

[$boost_asio/sync_op.png]

[*Your program] will have at least one [*io_service] object. The [*io_service]
[*Your program] will have at least one [*io_context] object. The [*io_context]
represents [*your program]'s link to the [*operating system]'s I/O services.

boost::asio::io_service io_service;
boost::asio::io_context io_context;

To perform I/O operations [*your program] will need an [*I/O object] such as a
TCP socket:

boost::asio::ip::tcp::socket socket(io_service);
boost::asio::ip::tcp::socket socket(io_context);

When a synchronous connect operation is performed, the following sequence of
events occurs:
Expand All @@ -35,15 +35,15 @@ object]:

socket.connect(server_endpoint);

2. The [*I/O object] forwards the request to the [*io_service].
2. The [*I/O object] forwards the request to the [*io_context].

3. The [*io_service] calls on the [*operating system] to perform the connect
3. The [*io_context] calls on the [*operating system] to perform the connect
operation.

4. The [*operating system] returns the result of the operation to the
[*io_service].
[*io_context].

5. The [*io_service] translates any error resulting from the operation into an
5. The [*io_context] translates any error resulting from the operation into an
object of type `boost::system::error_code`. An `error_code` may be compared with
specific values, or tested as a boolean (where a `false` result means that no
error occurred). The result is then forwarded back up to the [*I/O object].
Expand Down Expand Up @@ -76,9 +76,9 @@ The exact signature required depends on the asynchronous operation being
performed. The reference documentation indicates the appropriate form for each
operation.

2. The [*I/O object] forwards the request to the [*io_service].
2. The [*I/O object] forwards the request to the [*io_context].

3. The [*io_service] signals to the [*operating system] that it should start an
3. The [*io_context] signals to the [*operating system] that it should start an
asynchronous connect.

Time passes. (In the synchronous case this wait would have been contained
Expand All @@ -87,15 +87,15 @@ entirely within the duration of the connect operation.)
[$boost_asio/async_op2.png]

4. The [*operating system] indicates that the connect operation has completed
by placing the result on a queue, ready to be picked up by the [*io_service].
by placing the result on a queue, ready to be picked up by the [*io_context].

5. [*Your program] must make a call to `io_service::run()` (or to one of the
similar [*io_service] member functions) in order for the result to be
retrieved. A call to `io_service::run()` blocks while there are unfinished
5. [*Your program] must make a call to `io_context::run()` (or to one of the
similar [*io_context] member functions) in order for the result to be
retrieved. A call to `io_context::run()` blocks while there are unfinished
asynchronous operations, so you would typically call it as soon as you have
started your first asynchronous operation.

6. While inside the call to `io_service::run()`, the [*io_service] dequeues the
6. While inside the call to `io_context::run()`, the [*io_context] dequeues the
result of the operation, translates it into an `error_code`, and then passes it
to [*your completion handler].

Expand Down
8 changes: 4 additions & 4 deletions doc/overview/bsd_sockets.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ The following table shows the mapping between the BSD socket API and Boost.Asio:
[`poll()`,
`select()`,
`pselect()`]
[ [link boost_asio.reference.io_service.run io_service::run()],
[link boost_asio.reference.io_service.run_one io_service::run_one()],
[link boost_asio.reference.io_service.poll io_service::poll()],
[link boost_asio.reference.io_service.poll_one io_service::poll_one()]
[ [link boost_asio.reference.io_context.run io_context::run()],
[link boost_asio.reference.io_context.run_one io_context::run_one()],
[link boost_asio.reference.io_context.poll io_context::poll()],
[link boost_asio.reference.io_context.poll_one io_context::poll_one()]

Note: in conjunction with asynchronous operations. ]
]
Expand Down
2 changes: 1 addition & 1 deletion doc/overview/buffers.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ an opaque representation of contiguous memory, where:
mechanisms for automatically determining the size of a buffer from an array,
`boost::array` or `std::vector` of POD elements, or from a `std::string`.

* Type safety violations must be explicitly requested using the `buffer_cast`
* The underlying memory is explicitly accessed using the `data()` member
function. In general an application should never need to do this, but it is
required by the library implementation to pass the raw memory to the
underlying operating system functions.
Expand Down
2 changes: 1 addition & 1 deletion doc/overview/cpp2011.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Windows handles.

Move support allows you to write code like:

tcp::socket make_socket(io_service& i)
tcp::socket make_socket(io_context& i)
{
tcp::socket s(i);
...
Expand Down
2 changes: 1 addition & 1 deletion doc/overview/handler_tracking.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The `<action>` takes one of the following forms:
[~n]
[The handler number `n` was destroyed without having been invoked. This is
usually the case for any unfinished asynchronous operations when the
`io_service` is destroyed.]
`io_context` is destroyed.]
]
[
[n*m]
Expand Down
80 changes: 40 additions & 40 deletions doc/overview/implementation.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ descriptors in the process cannot be permitted to exceed `FD_SETSIZE`.
Threads:

* Demultiplexing using `select` is performed in one of the threads that calls
`io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
`io_service::poll_one()`.
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.

* An additional thread per `io_service` is used to emulate asynchronous host
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.

Expand All @@ -42,10 +42,10 @@ Demultiplexing mechanism:
Threads:

* Demultiplexing using `epoll` is performed in one of the threads that calls
`io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
`io_service::poll_one()`.
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.

* An additional thread per `io_service` is used to emulate asynchronous host
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.

Expand All @@ -63,10 +63,10 @@ Demultiplexing mechanism:
Threads:

* Demultiplexing using [^/dev/poll] is performed in one of the threads that
calls `io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
`io_service::poll_one()`.
calls `io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.

* An additional thread per `io_service` is used to emulate asynchronous host
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.

Expand All @@ -85,10 +85,10 @@ descriptors in the process cannot be permitted to exceed `FD_SETSIZE`.
Threads:

* Demultiplexing using `select` is performed in one of the threads that calls
`io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
`io_service::poll_one()`.
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.

* An additional thread per `io_service` is used to emulate asynchronous host
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.

Expand All @@ -106,10 +106,10 @@ Demultiplexing mechanism:
Threads:

* Demultiplexing using `kqueue` is performed in one of the threads that calls
`io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
`io_service::poll_one()`.
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.

* An additional thread per `io_service` is used to emulate asynchronous host
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.

Expand All @@ -127,10 +127,10 @@ Demultiplexing mechanism:
Threads:

* Demultiplexing using `kqueue` is performed in one of the threads that calls
`io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
`io_service::poll_one()`.
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.

* An additional thread per `io_service` is used to emulate asynchronous host
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.

Expand All @@ -149,10 +149,10 @@ descriptors in the process cannot be permitted to exceed `FD_SETSIZE`.
Threads:

* Demultiplexing using `select` is performed in one of the threads that calls
`io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
`io_service::poll_one()`.
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.

* An additional thread per `io_service` is used to emulate asynchronous host
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.

Expand All @@ -171,10 +171,10 @@ descriptors in the process cannot be permitted to exceed `FD_SETSIZE`.
Threads:

* Demultiplexing using `select` is performed in one of the threads that calls
`io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
`io_service::poll_one()`.
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.

* An additional thread per `io_service` is used to emulate asynchronous host
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.

Expand All @@ -193,10 +193,10 @@ descriptors in the process cannot be permitted to exceed `FD_SETSIZE`.
Threads:

* Demultiplexing using `select` is performed in one of the threads that calls
`io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
`io_service::poll_one()`.
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.

* An additional thread per `io_service` is used to emulate asynchronous host
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.

Expand All @@ -214,10 +214,10 @@ Demultiplexing mechanism:
Threads:

* Demultiplexing using `select` is performed in one of the threads that calls
`io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
`io_service::poll_one()`.
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.

* An additional thread per `io_service` is used to emulate asynchronous host
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.

Expand All @@ -238,17 +238,17 @@ operations except for asynchronous connect.
Threads:

* Demultiplexing using I/O completion ports is performed in all threads that call
`io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
`io_service::poll_one()`.
`io_context::run()`, `io_context::run_one()`, `io_context::poll()` or
`io_context::poll_one()`.

* An additional thread per `io_service` is used to trigger timers. This thread
is created on construction of the first `deadline_timer` or
`deadline_timer_service` objects.
* An additional thread per `io_context` is used to trigger timers. This thread
is created on construction of the first `basic_deadline_timer` or
`basic_waitable_timer` objects.

* An additional thread per `io_service` is used for the `select`
* An additional thread per `io_context` is used for the `select`
demultiplexing. This thread is created on the first call to `async_connect()`.

* An additional thread per `io_service` is used to emulate asynchronous host
* An additional thread per `io_context` is used to emulate asynchronous host
resolution. This thread is created on the first call to either
`ip::tcp::resolver::async_resolve()` or `ip::udp::resolver::async_resolve()`.

Expand All @@ -265,7 +265,7 @@ Boost.Asio provides limited support for the Windows Runtime. It requires that th
language extensions be enabled. Due to the restricted facilities exposed by the
Windows Runtime API, the support comes with the following caveats:

* The core facilities such as the `io_service`, `strand`, buffers, composed
* The core facilities such as the `io_context`, `strand`, buffers, composed
operations, timers, etc., should all work as normal.

* For sockets, only client-side TCP is supported.
Expand All @@ -292,9 +292,9 @@ Demultiplexing mechanism:
Threads:

* Event completions are delivered to the Windows thread pool and posted to the
`io_service` for the handler to be executed.
`io_context` for the handler to be executed.

* An additional thread per `io_service` is used to trigger timers. This thread
* An additional thread per `io_context` is used to trigger timers. This thread
is created on construction of the first timer objects.

Scatter-Gather:
Expand Down
Loading

0 comments on commit b60e92b

Please sign in to comment.