7 #ifndef CPPWAMP_INTERNAL_UDSACCEPTOR_HPP
8 #define CPPWAMP_INTERNAL_UDSACCEPTOR_HPP
13 #include <boost/asio/local/stream_protocol.hpp>
14 #include <boost/asio/strand.hpp>
15 #include "../asiodefs.hpp"
27 using Socket = boost::asio::local::stream_protocol::socket;
28 using SocketPtr = std::unique_ptr<Socket>;
30 template <
typename TExecutorOrStrand>
31 UdsAcceptor(TExecutorOrStrand&& exec,
const std::string& path,
33 : strand_(std::forward<TExecutorOrStrand>(exec)),
35 deleteFile_(deleteFile)
41 void establish(F&& callback)
46 typename std::decay<F>::type callback;
52 self->acceptor_.reset();
53 self->socket_.reset();
55 callback(ec, std::move(self->socket_));
59 assert(!socket_ &&
"Accept already in progress");
64 std::remove(path_.c_str());
65 acceptor_.reset(
new uds::acceptor(strand_, path_));
67 socket_.reset(
new Socket(strand_));
70 acceptor_->async_accept(*socket_,
71 Accepted{
this, std::forward<F>(callback)});
81 using uds = boost::asio::local::stream_protocol;
86 std::unique_ptr<uds::acceptor> acceptor_;
94 #endif // CPPWAMP_INTERNAL_UDSACCEPTOR_HPP