Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
youyuanwu committed Oct 15, 2023
1 parent 92af950 commit e4cc1dd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
30 changes: 16 additions & 14 deletions include/boost/winasio/named_pipe/named_pipe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,25 @@ class named_pipe : public boost::asio::windows::basic_stream_handle<Executor> {
parent_type::assign(hPipe);
}

template<typename Token>
auto async_server_connect(Token && token){
return boost::asio::async_initiate<decltype(token),
void(boost::system::error_code)>(
template <typename Token> auto async_server_connect(Token &&token) {
return boost::asio::async_initiate<decltype(token),
void(boost::system::error_code)>(
[this](auto handler) {
// init optr to pass through the user handler.
boost::asio::windows::overlapped_ptr optr(this->get_executor(),
[h=std::move(handler)](boost::system::error_code ec, std::size_t) mutable {
std::move(h)(ec);
});
boost::asio::windows::overlapped_ptr optr(
this->get_executor(),
[h = std::move(handler)](boost::system::error_code ec,
std::size_t) mutable {
std::move(h)(ec);
});
boost::system::error_code ec;
bool fConnected = false;
fConnected = ConnectNamedPipe(this->native_handle(), optr.get());
// Overlapped ConnectNamedPipe should return zero.
if (fConnected) {
// printf("ConnectNamedPipe failed with %d.\n", GetLastError());
ec = boost::system::error_code(::GetLastError(),
boost::system::system_category());
boost::system::system_category());
optr.complete(ec, 0);
return;
}
Expand All @@ -104,17 +105,18 @@ class named_pipe : public boost::asio::windows::basic_stream_handle<Executor> {
break;
// Client is already connected, so signal an event.
case ERROR_PIPE_CONNECTED: {
// In the win32 example here we need to reset the overlapp event when pipe
// already is connected. But this case overlapped_ptr cannot trigger this
// because iocp does not register this pipe instance.
// In the win32 example here we need to reset the overlapp event
// when pipe already is connected. But this case overlapped_ptr
// cannot trigger this because iocp does not register this pipe
// instance.
optr.complete(ec, 0);
break;
}
// If an error occurs during the connect operation...
default: {
// printf("Some named pipe op failed with %d.\n", GetLastError());
ec = boost::system::error_code(::GetLastError(),
boost::asio::error::get_system_category());
ec = boost::system::error_code(
::GetLastError(), boost::asio::error::get_system_category());
optr.complete(ec, 0);
}
}
Expand Down
15 changes: 8 additions & 7 deletions include/boost/winasio/named_pipe/named_pipe_acceptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ template <typename Executor> class named_pipe_acceptor {
BOOST_ASIO_MOVE_ARG(AcceptToken)
token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) {
return boost::asio::async_initiate<decltype(token),
void(boost::system::error_code)>(
void(boost::system::error_code)>(
[this, &pipe](auto handler) {
boost::system::error_code ec;
pipe.server_create(ec, endpoint_);
if (ec) {
std::move(handler)(ec);
return;
}
pipe.async_server_connect([h=std::move(handler), this](boost::system::error_code ec) mutable {
std::move(h)(ec);
});
pipe.async_server_connect(
[h = std::move(handler), this](
boost::system::error_code ec) mutable { std::move(h)(ec); });
},
token);
}
Expand All @@ -83,16 +83,17 @@ template <typename Executor> class named_pipe_acceptor {
async_accept(BOOST_ASIO_MOVE_ARG(MoveAcceptToken)
token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)) {
return boost::asio::async_initiate<decltype(token),
void(boost::system::error_code,
named_pipe<executor_type>)>(
void(boost::system::error_code,
named_pipe<executor_type>)>(
[this](auto handler) {
boost::system::error_code ec;
pipe_.server_create(ec, endpoint_);
if (ec) {
std::move(handler)(ec, std::move(pipe_));
return;
}
pipe_.async_server_connect([h=std::move(handler), this](boost::system::error_code ec) mutable {
pipe_.async_server_connect([h = std::move(handler), this](
boost::system::error_code ec) mutable {
std::move(h)(ec, std::move(pipe_));
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

namespace boost {
namespace winasio {
namespace details {


} // namespace details
namespace details {} // namespace details
} // namespace winasio
} // namespace boost

Expand Down

0 comments on commit e4cc1dd

Please sign in to comment.