Skip to content

Commit dbdde20

Browse files
committed
improved variable names and fixed comments
1 parent 6867ad0 commit dbdde20

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
lines changed

examples/echo_server_both/echo_server_both.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ context_ptr on_tls_init(websocketpp::connection_hdl hdl) {
6767
int main() {
6868
// set up an external io_context to run both endpoints on. This is not
6969
// strictly necessary, but simplifies thread management a bit.
70-
websocketpp::lib::asio::io_context ios;
70+
websocketpp::lib::asio::io_context ctx;
7171

7272
// set up plain endpoint
7373
server_plain endpoint_plain;
7474
// initialize asio with our external io_context rather than an internal one
75-
endpoint_plain.init_asio(&ios);
75+
endpoint_plain.init_asio(&ctx);
7676
endpoint_plain.set_message_handler(
7777
bind(&on_message<server_plain>,&endpoint_plain,::_1,::_2));
7878
endpoint_plain.listen(80);
7979
endpoint_plain.start_accept(&on_end_accept);
8080

8181
// set up tls endpoint
8282
server_tls endpoint_tls;
83-
endpoint_tls.init_asio(&ios);
83+
endpoint_tls.init_asio(&ctx);
8484
endpoint_tls.set_message_handler(
8585
bind(&on_message<server_tls>,&endpoint_tls,::_1,::_2));
8686
// TLS endpoint has an extra handler for the tls init
@@ -90,5 +90,5 @@ int main() {
9090
endpoint_tls.start_accept(&on_end_accept);
9191

9292
// Start the ASIO io_context run loop running both endpoints
93-
ios.run();
93+
ctx.run();
9494
}

test/endpoint/endpoint.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ BOOST_AUTO_TEST_CASE( initialize_server_asio ) {
5353

5454
BOOST_AUTO_TEST_CASE( initialize_server_asio_external ) {
5555
websocketpp::server<websocketpp::config::asio> s;
56-
websocketpp::lib::asio::io_context ios;
57-
s.init_asio(&ios);
56+
websocketpp::lib::asio::io_context ctx;
57+
s.init_asio(&ctx);
5858
}
5959

6060
#ifdef _WEBSOCKETPP_MOVE_SEMANTICS_

test/transport/asio/timers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ void run_dummy_server(int port) {
7979

8080
// Wait for the specified time period then fail the test
8181
void run_test_timer(long value) {
82-
boost::asio::io_context ios;
83-
boost::asio::deadline_timer t(ios,boost::posix_time::milliseconds(value));
82+
boost::asio::io_context ctx;
83+
boost::asio::deadline_timer t(ctx,boost::posix_time::milliseconds(value));
8484
boost::system::error_code ec;
8585
t.wait(ec);
8686
BOOST_FAIL( "Test timed out" );

test/transport/integration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ void run_dummy_client(std::string port) {
252252
try {
253253
websocketpp::lib::asio::io_context io_context;
254254
tcp::resolver resolver(io_context);
255-
tcp::resolver::results_type endpoints = resolver.resolve("localhost", port);
255+
tcp::resolver::results_type results = resolver.resolve("localhost", port);
256256
tcp::socket socket(io_context);
257257

258-
websocketpp::lib::asio::connect(socket, endpoints);
258+
websocketpp::lib::asio::connect(socket, results);
259259
for (;;) {
260260
char data[512];
261261
websocketpp::lib::asio::error_code ec;

websocketpp/transport/asio/connection.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ class connection : public config::socket_type::socket_con_type {
380380
* fail handler is called.
381381
*
382382
* Primarily used if you are using mismatched asio / system_error
383-
* implementations such as `lib::asio` with `std::system_error`. In these
383+
* implementations such as `boost::asio` with `std::system_error`. In these
384384
* cases the transport error type is different than the library error type
385385
* and some WebSocket++ functions that return transport errors via the
386386
* library error code type will be coerced into a catch all `pass_through`

websocketpp/transport/asio/endpoint.hpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class endpoint : public config::socket_type {
8686
/// Type of timer handle
8787
typedef lib::shared_ptr<lib::asio::steady_timer> timer_ptr;
8888
/// Type of a shared pointer to an io_context work object
89-
typedef lib::shared_ptr<lib::asio::executor_work_guard<lib::asio::io_context::executor_type>> work_ptr;
89+
typedef lib::shared_ptr<lib::asio::executor_work_guard<lib::asio::io_context::executor_type>> work_guard_ptr;
9090

9191
/// Type of socket pre-bind handler
9292
typedef lib::function<lib::error_code(acceptor_ptr)> tcp_pre_bind_handler;
@@ -108,7 +108,7 @@ class endpoint : public config::socket_type {
108108
// Explicitly destroy local objects
109109
m_acceptor.reset();
110110
m_resolver.reset();
111-
m_work.reset();
111+
m_work_guard.reset();
112112
if (m_state != UNINITIALIZED && !m_external_io_context) {
113113
delete m_io_context;
114114
}
@@ -495,8 +495,7 @@ class endpoint : public config::socket_type {
495495
/**
496496
* Bind the internal acceptor using the given host and service. More details
497497
* about what host and service can be are available in the Asio
498-
* documentation for ip::basic_resolver_query::basic_resolver_query's
499-
* constructors.
498+
* documentation for the ip::basic_resolver::resolve function.
500499
*
501500
* The endpoint must have been initialized by calling init_asio before
502501
* listening.
@@ -519,14 +518,14 @@ class endpoint : public config::socket_type {
519518
{
520519
using lib::asio::ip::tcp;
521520
tcp::resolver r(*m_io_context);
522-
tcp::resolver::results_type endpoints = r.resolve(host, service);
523-
if (endpoints.empty()) {
521+
tcp::resolver::results_type results = r.resolve(host, service);
522+
if (results.empty()) {
524523
m_elog->write(log::elevel::library,
525524
"asio::listen could not resolve the supplied host or service");
526525
ec = make_error_code(error::invalid_host_service);
527526
return;
528527
}
529-
listen(*endpoints.begin(),ec);
528+
listen(*(results.begin()),ec);
530529
}
531530

532531
/// Stop listening (exception free)
@@ -613,8 +612,7 @@ class endpoint : public config::socket_type {
613612
/**
614613
* Bind the internal acceptor using the given host and service. More
615614
* details about what host and service can be are available in the Asio
616-
* documentation for ip::basic_resolver_query::basic_resolver_query's
617-
* constructors.
615+
* documentation for the ip::basic_resolver::resolve function.
618616
*
619617
* The endpoint must have been initialized by calling init_asio before
620618
* listening.
@@ -712,7 +710,7 @@ class endpoint : public config::socket_type {
712710
* @since 0.3.0
713711
*/
714712
void start_perpetual() {
715-
m_work.reset(new lib::asio::executor_work_guard<lib::asio::io_context::executor_type>(m_io_context->get_executor()));
713+
m_work_guard.reset(new lib::asio::executor_work_guard<lib::asio::io_context::executor_type>(m_io_context->get_executor()));
716714
}
717715

718716
/// Clears the endpoint's perpetual flag, allowing it to exit when empty
@@ -724,7 +722,7 @@ class endpoint : public config::socket_type {
724722
* @since 0.3.0
725723
*/
726724
void stop_perpetual() {
727-
m_work.reset();
725+
m_work_guard.reset();
728726
}
729727

730728
/// Call back a function after a period of time.
@@ -993,7 +991,7 @@ class endpoint : public config::socket_type {
993991

994992
void handle_resolve(transport_con_ptr tcon, timer_ptr dns_timer,
995993
connect_handler callback, lib::asio::error_code const & ec,
996-
lib::asio::ip::tcp::resolver::results_type endpoints)
994+
lib::asio::ip::tcp::resolver::results_type results)
997995
{
998996
if (ec == lib::asio::error::operation_aborted ||
999997
lib::asio::is_neg(dns_timer->expiry() - timer_ptr::element_type::clock_type::now()))
@@ -1015,7 +1013,7 @@ class endpoint : public config::socket_type {
10151013
s << "Async DNS resolve successful. Results: ";
10161014

10171015
lib::asio::ip::tcp::resolver::results_type::iterator it;
1018-
for (it = endpoints.begin(); it != endpoints.end(); ++it) {
1016+
for (it = results.begin(); it != results.end(); ++it) {
10191017
s << (*it).endpoint() << " ";
10201018
}
10211019

@@ -1041,7 +1039,7 @@ class endpoint : public config::socket_type {
10411039
if (config::enable_multithreading) {
10421040
lib::asio::async_connect(
10431041
tcon->get_raw_socket(),
1044-
endpoints,
1042+
results,
10451043
tcon->get_strand()->wrap(lib::bind(
10461044
&type::handle_connect,
10471045
this,
@@ -1054,7 +1052,7 @@ class endpoint : public config::socket_type {
10541052
} else {
10551053
lib::asio::async_connect(
10561054
tcon->get_raw_socket(),
1057-
endpoints,
1055+
results,
10581056
lib::bind(
10591057
&type::handle_connect,
10601058
this,
@@ -1189,7 +1187,7 @@ class endpoint : public config::socket_type {
11891187
bool m_external_io_context;
11901188
acceptor_ptr m_acceptor;
11911189
resolver_ptr m_resolver;
1192-
work_ptr m_work;
1190+
work_guard_ptr m_work_guard;
11931191

11941192
// Network constants
11951193
int m_listen_backlog;

0 commit comments

Comments
 (0)