Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3382000

Browse files
committed
Replaced std::function handler with a template in async_resolver.
1 parent00654de commit3382000

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

‎http/src/network/http/v2/client/connection/async_resolver.hpp‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ namespace network {
4242
*/
4343
typedef resolver::iterator resolver_iterator;
4444

45-
/**
46-
* \brief callback_fn
47-
*/
48-
typedef std::function<void (const boost::system::error_code&,
49-
resolver_iterator)> callback_fn;
50-
5145
/**
5246
* \brief Constructor.
5347
*/
@@ -71,13 +65,13 @@ namespace network {
7165
* \param port The port number.
7266
* \param callback A callback handler.
7367
*/
74-
75-
voidasync_resolve(const std::string &host, std::uint16_t port,callback_fn callback) {
68+
template<classHandler>
69+
voidasync_resolve(const std::string &host, std::uint16_t port,Handler&& handler) {
7670
if (cache_resolved_) {
7771
endpoint_cache::iterator it = endpoint_cache_.find(boost::to_lower_copy(host));
7872
if (it != endpoint_cache_.end()) {
7973
boost::system::error_code ec;
80-
callback(ec, it->second);
74+
handler(ec, it->second);
8175
return;
8276
}
8377
}
@@ -86,16 +80,16 @@ namespace network {
8680
resolver::queryquery(host,std::to_string(port));
8781
resolver_.async_resolve(query,
8882
resolver_strand_->wrap(
89-
[&host, &callback,this](const boost::system::error_code &ec,
83+
[&host, &handler,this](const boost::system::error_code &ec,
9084
resolver_iterator endpoint_iterator) {
9185
if (ec) {
92-
callback(ec,resolver_iterator());
86+
handler(ec,resolver_iterator());
9387
}
9488
else {
9589
if (cache_resolved_) {
9690
endpoint_cache_.insert(std::make_pair(host, endpoint_iterator));
9791
}
98-
callback(ec, endpoint_iterator);
92+
handler(ec, endpoint_iterator);
9993
}
10094
}));
10195
}

‎http/src/network/http/v2/client/connection/connection.hpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ namespace network {
5757
* \param host The host name.
5858
* \param callback A callback handler.
5959
*/
60-
*/
6160
virtualvoidasync_connect(boost::asio::ip::tcp::endpoint &endpoint,
6261
const std::string &host, connect_callback callback) = 0;
6362

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp