mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 04:47:29 +02:00
std::bind is superfluous in some examples
This commit is contained in:
committed by
Mohammad Nejati
parent
cf72589ae9
commit
6dd3cf7ab1
@ -213,7 +213,7 @@ fail(beast::error_code ec, char const* what)
|
|||||||
// Handles an HTTP server connection
|
// Handles an HTTP server connection
|
||||||
void
|
void
|
||||||
do_session(
|
do_session(
|
||||||
tcp::socket& socket,
|
tcp::socket socket,
|
||||||
ssl::context& ctx,
|
ssl::context& ctx,
|
||||||
std::shared_ptr<std::string const> const& doc_root)
|
std::shared_ptr<std::string const> const& doc_root)
|
||||||
{
|
{
|
||||||
@ -308,11 +308,11 @@ int main(int argc, char* argv[])
|
|||||||
acceptor.accept(socket);
|
acceptor.accept(socket);
|
||||||
|
|
||||||
// Launch the session, transferring ownership of the socket
|
// Launch the session, transferring ownership of the socket
|
||||||
std::thread{std::bind(
|
std::thread{
|
||||||
&do_session,
|
do_session,
|
||||||
std::move(socket),
|
std::move(socket),
|
||||||
std::ref(ctx),
|
std::ref(ctx),
|
||||||
doc_root)}.detach();
|
doc_root}.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
|
@ -210,7 +210,7 @@ fail(beast::error_code ec, char const* what)
|
|||||||
// Handles an HTTP server connection
|
// Handles an HTTP server connection
|
||||||
void
|
void
|
||||||
do_session(
|
do_session(
|
||||||
tcp::socket& socket,
|
tcp::socket socket,
|
||||||
std::shared_ptr<std::string const> const& doc_root)
|
std::shared_ptr<std::string const> const& doc_root)
|
||||||
{
|
{
|
||||||
beast::error_code ec;
|
beast::error_code ec;
|
||||||
@ -287,10 +287,10 @@ int main(int argc, char* argv[])
|
|||||||
acceptor.accept(socket);
|
acceptor.accept(socket);
|
||||||
|
|
||||||
// Launch the session, transferring ownership of the socket
|
// Launch the session, transferring ownership of the socket
|
||||||
std::thread{std::bind(
|
std::thread{
|
||||||
&do_session,
|
do_session,
|
||||||
std::move(socket),
|
std::move(socket),
|
||||||
doc_root)}.detach();
|
doc_root}.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
|
@ -80,7 +80,7 @@ setup_stream(websocket::stream<NextLayer>& ws)
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void
|
void
|
||||||
do_sync_session(websocket::stream<beast::tcp_stream>& ws)
|
do_sync_session(websocket::stream<beast::tcp_stream> ws)
|
||||||
{
|
{
|
||||||
beast::error_code ec;
|
beast::error_code ec;
|
||||||
|
|
||||||
@ -129,10 +129,10 @@ do_sync_listen(
|
|||||||
if(ec)
|
if(ec)
|
||||||
return fail(ec, "accept");
|
return fail(ec, "accept");
|
||||||
|
|
||||||
std::thread(std::bind(
|
std::thread{
|
||||||
&do_sync_session,
|
do_sync_session,
|
||||||
websocket::stream<beast::tcp_stream>(
|
websocket::stream<beast::tcp_stream>(std::move(socket))
|
||||||
std::move(socket)))).detach();
|
}.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,13 +441,11 @@ int main(int argc, char* argv[])
|
|||||||
net::io_context ioc{threads};
|
net::io_context ioc{threads};
|
||||||
|
|
||||||
// Create sync port
|
// Create sync port
|
||||||
std::thread(beast::bind_front_handler(
|
std::thread{
|
||||||
&do_sync_listen,
|
do_sync_listen,
|
||||||
std::ref(ioc),
|
std::ref(ioc),
|
||||||
tcp::endpoint{
|
tcp::endpoint{address, static_cast<unsigned short>(port + 0u)}
|
||||||
address,
|
}.detach();
|
||||||
static_cast<unsigned short>(port + 0u)}
|
|
||||||
)).detach();
|
|
||||||
|
|
||||||
// Create async port
|
// Create async port
|
||||||
std::make_shared<async_listener>(
|
std::make_shared<async_listener>(
|
||||||
|
@ -123,10 +123,10 @@ int main(int argc, char* argv[])
|
|||||||
acceptor.accept(socket);
|
acceptor.accept(socket);
|
||||||
|
|
||||||
// Launch the session, transferring ownership of the socket
|
// Launch the session, transferring ownership of the socket
|
||||||
std::thread(
|
std::thread{
|
||||||
&do_session,
|
do_session,
|
||||||
std::move(socket),
|
std::move(socket),
|
||||||
std::ref(ctx)).detach();
|
std::ref(ctx)}.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
|
@ -108,9 +108,9 @@ int main(int argc, char* argv[])
|
|||||||
acceptor.accept(socket);
|
acceptor.accept(socket);
|
||||||
|
|
||||||
// Launch the session, transferring ownership of the socket
|
// Launch the session, transferring ownership of the socket
|
||||||
std::thread(
|
std::thread{
|
||||||
&do_session,
|
do_session,
|
||||||
std::move(socket)).detach();
|
std::move(socket)}.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
|
Reference in New Issue
Block a user