fix: use lambda as callback parameter
This commit is contained in:
parent
24a59a4875
commit
9653ae29bf
|
@ -42,13 +42,6 @@
|
||||||
using namespace nghttp2::asio_http2;
|
using namespace nghttp2::asio_http2;
|
||||||
using namespace nghttp2::asio_http2::server;
|
using namespace nghttp2::asio_http2::server;
|
||||||
|
|
||||||
void all_threads_created_cb(
|
|
||||||
std::vector<std::shared_ptr<thread_info>> all_threads_info) {
|
|
||||||
for (auto thread_info : all_threads_info) {
|
|
||||||
std::cout << "thread pid: " << thread_info->pid << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
try {
|
try {
|
||||||
// Check command line arguments.
|
// Check command line arguments.
|
||||||
|
@ -69,7 +62,12 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
server.num_threads(num_threads);
|
server.num_threads(num_threads);
|
||||||
|
|
||||||
server.set_on_all_threads_created_callback(all_threads_created_cb);
|
server.set_on_all_threads_created_callback(
|
||||||
|
[](const auto &all_threads_info) {
|
||||||
|
for (auto &thread_info : all_threads_info) {
|
||||||
|
std::cout << "thread pid: " << thread_info->pid << std::endl;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
server.handle("/", [](const request &req, const response &res) {
|
server.handle("/", [](const request &req, const response &res) {
|
||||||
res.write_head(200, {{"foo", {"bar"}}});
|
res.write_head(200, {{"foo", {"bar"}}});
|
||||||
|
|
|
@ -71,7 +71,7 @@ server::listen_and_serve(boost::system::error_code &ec,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
io_service_pool_.run(asynchronous, all_threads_created_cb);
|
io_service_pool_.run(asynchronous, std::move(all_threads_created_cb));
|
||||||
|
|
||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ void http2_impl::backlog(int backlog) { backlog_ = backlog; }
|
||||||
|
|
||||||
void http2_impl::set_on_all_threads_created_callback(
|
void http2_impl::set_on_all_threads_created_callback(
|
||||||
on_all_threads_created_cb cb) {
|
on_all_threads_created_cb cb) {
|
||||||
all_threads_created_cb_ = cb;
|
all_threads_created_cb_ = std::move(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void http2_impl::tls_handshake_timeout(
|
void http2_impl::tls_handshake_timeout(
|
||||||
|
|
Loading…
Reference in New Issue