diff --git a/src/lib/util/client_ws.hpp b/src/lib/util/client_ws.hpp index 04af502601463..60c1a816bc7dc 100644 --- a/src/lib/util/client_ws.hpp +++ b/src/lib/util/client_ws.hpp @@ -99,7 +99,7 @@ namespace webpp { std::list send_queue; void send_from_queue() { - strand.post([this]() { + asio::post(strand, [this]() { asio::async_write(*socket, send_queue.begin()->send_stream->streambuf, strand.wrap([this](const std::error_code& ec, size_t /*bytes_transferred*/) { auto send_queued=send_queue.begin(); @@ -175,7 +175,7 @@ namespace webpp { } if(io_context->stopped()) - io_context->reset(); + io_context->restart(); if(!resolver) resolver= std::make_unique(*io_context); @@ -237,7 +237,7 @@ namespace webpp { send_stream->put(message_stream->get()^mask[c%4]); } - connection->strand.post([this, send_stream, callback]() { + asio::post(connection->strand, [this, send_stream, callback]() { connection->send_queue.emplace_back(send_stream, callback); if(connection->send_queue.size()==1) connection->send_from_queue(); @@ -516,18 +516,18 @@ namespace webpp { protected: void connect() override { - asio::ip::tcp::resolver::query query(host, std::to_string(port)); - - resolver->async_resolve(query, [this] - (const std::error_code &ec, asio::ip::tcp::resolver::iterator it){ + resolver->async_resolve(host, std::to_string(port), [this] + (const std::error_code &ec, asio::ip::tcp::resolver::results_type results){ if(!ec) { - connection=std::shared_ptr(new Connection(*io_context, new WS(*io_context))); + if (!this->connection) { + this->connection = std::shared_ptr(new Connection(*io_context, new WS(*io_context))); + } - asio::async_connect(*connection->socket, it, [this] - (const std::error_code &ec, asio::ip::tcp::resolver::iterator /*it*/){ + asio::async_connect(*this->connection->socket, results, [this] + (const std::error_code &ec, const asio::ip::tcp::endpoint &) { if(!ec) { asio::ip::tcp::no_delay option(true); - connection->socket->set_option(option); + this->connection->socket->set_option(option); handshake(); } diff --git a/src/lib/util/server_ws_impl.hpp b/src/lib/util/server_ws_impl.hpp index c1ba9f1a392d6..4f7468232c380 100644 --- a/src/lib/util/server_ws_impl.hpp +++ b/src/lib/util/server_ws_impl.hpp @@ -96,7 +96,7 @@ namespace webpp { std::list send_queue; void send_from_queue(const std::shared_ptr &connection) { - strand.post([this, connection]() { + asio::post(strand, [this, connection]() { asio::async_write(*socket, send_queue.begin()->header_stream->streambuf, strand.wrap([this, connection](const std::error_code& ec, size_t /*bytes_transferred*/) { if(!ec) { @@ -219,11 +219,11 @@ namespace webpp { io_context=std::make_shared(); if(io_context->stopped()) - io_context->reset(); + io_context->restart(); asio::ip::tcp::endpoint endpoint; if(config.address.size()>0) - endpoint=asio::ip::tcp::endpoint(asio::ip::address::from_string(config.address), config.port); + endpoint=asio::ip::tcp::endpoint(asio::ip::make_address(config.address), config.port); else endpoint=asio::ip::tcp::endpoint(asio::ip::tcp::v4(), config.port); @@ -283,7 +283,7 @@ namespace webpp { else header_stream->put(static_cast(length)); - connection->strand.post([connection, header_stream, message_stream, callback]() { + asio::post(connection->strand, [connection, header_stream, message_stream, callback]() { connection->send_queue.emplace_back(header_stream, message_stream, callback); if(connection->send_queue.size()==1) connection->send_from_queue(connection); @@ -653,12 +653,12 @@ namespace webpp { void timer_idle_init(const std::shared_ptr &connection) { if(config.timeout_idle>0) { connection->timer_idle= std::make_unique(connection->socket->get_executor()); - connection->timer_idle->expires_from_now(std::chrono::seconds(static_cast(config.timeout_idle))); + connection->timer_idle->expires_after(std::chrono::seconds(static_cast(config.timeout_idle))); timer_idle_expired_function(connection); } } void timer_idle_reset(const std::shared_ptr &connection) const { - if(config.timeout_idle>0 && connection->timer_idle->expires_from_now(std::chrono::seconds(static_cast(config.timeout_idle)))>0) + if(config.timeout_idle>0 && connection->timer_idle->expires_after(std::chrono::seconds(static_cast(config.timeout_idle)))>0) timer_idle_expired_function(connection); } void timer_idle_cancel(const std::shared_ptr &connection) const { diff --git a/src/mame/capcom/cps2comm.cpp b/src/mame/capcom/cps2comm.cpp index 95701ef264ddc..69dca5915777c 100644 --- a/src/mame/capcom/cps2comm.cpp +++ b/src/mame/capcom/cps2comm.cpp @@ -173,7 +173,7 @@ class cps2_comm_device::context void stop() { - m_ioctx.post( + asio::post(m_ioctx.get_executor(), [this] () { m_stopping = true; @@ -191,7 +191,7 @@ class cps2_comm_device::context void set_routing(u8 val) { - m_ioctx.post( + asio::post(m_ioctx.get_executor(), [this, val] () { if (BIT(val, 0, 2) == 0U) @@ -216,7 +216,7 @@ class cps2_comm_device::context void send_in(u8 data) { - m_ioctx.post( + asio::post(m_ioctx.get_executor(), [this, data] () { if (m_in_connected) @@ -231,7 +231,7 @@ class cps2_comm_device::context void send_out(u8 data) { - m_ioctx.post( + asio::post(m_ioctx.get_executor(), [this, data] () { if (m_out_sock.is_open())