11#include < array>
2- #include < boost/asio/io_context.hpp>
32#include < cstdio>
43#include < fstream>
54#include < map>
1817#include " boost_wrapper.hpp"
1918#include " exception.hpp"
2019#include " http_client.hpp"
21- #include " io_runner.hpp"
2220#include " logging.hpp"
2321#include " network_parameters.hpp"
2422#include " utils.hpp"
@@ -313,11 +311,11 @@ namespace sdk {
313311
314312 nlohmann::json wamp_cast_json (const autobahn::wamp_call_result& result) { return wamp_cast_json_impl (result); }
315313
316- wamp_transport::wamp_transport (const network_parameters& net_params, io_runner& runner,
317- boost::asio::io_context::strand& strand , wamp_transport::notify_fn_t fn, std::string server_prefix)
314+ wamp_transport::wamp_transport (
315+ const network_parameters& net_params , wamp_transport::notify_fn_t fn, std::string server_prefix)
318316 : m_net_params(net_params)
319- , m_io(runner )
320- , m_strand(strand )
317+ , m_io()
318+ , m_work_guard(asio::make_work_guard(m_io) )
321319 , m_server_prefix(std::move(server_prefix))
322320 , m_server(m_net_params.get_connection_string(m_server_prefix))
323321 , m_wamp_host_name(websocketpp::uri(m_net_params.gait_wamp_url(m_server_prefix)).get_host())
@@ -333,12 +331,13 @@ namespace sdk {
333331
334332 m_wamp_call_options.set_timeout (std::chrono::seconds (WAMP_CALL_TIMEOUT_SECS));
335333
334+ m_run_thread = std::thread ([this ] { m_io.run (); });
336335 m_reconnect_thread = std::thread ([this ] { reconnect_handler (); });
337336
338337 if (!m_net_params.is_tls_connection (m_server_prefix)) {
339338 m_client = std::make_unique<client>();
340339 m_client->set_pong_timeout_handler (std::bind (&wamp_transport::heartbeat_timeout_cb, this , _1, _2));
341- m_client->init_asio (&m_io. get_io_context () );
340+ m_client->init_asio (&m_io);
342341 return ;
343342 }
344343
@@ -348,13 +347,15 @@ namespace sdk {
348347 return tls_init (m_wamp_host_name, m_net_params.gait_wamp_cert_roots (), m_net_params.gait_wamp_cert_pins (),
349348 m_net_params.cert_expiry_threshold ());
350349 });
351- m_client_tls->init_asio (&m_io. get_io_context () );
350+ m_client_tls->init_asio (&m_io);
352351 }
353352
354353 wamp_transport::~wamp_transport ()
355354 {
356355 no_std_exception_escape ([this ] { change_state_to (state_t ::exited, std::string (), false ); }, " wamp dtor(1)" );
357356 no_std_exception_escape ([this ] { m_reconnect_thread.join (); }, " wamp dtor(2)" );
357+ no_std_exception_escape ([this ] { m_work_guard.reset (); }, " wamp dtor(2)" );
358+ no_std_exception_escape ([this ] { m_run_thread.join (); }, " wamp dtor(3)" );
358359 }
359360
360361 void wamp_transport::connect (const std::string& proxy) { change_state_to (state_t ::connected, proxy, true ); }
@@ -492,7 +493,7 @@ namespace sdk {
492493 {
493494 const bool is_tls = m_net_params.is_tls_connection (m_server_prefix);
494495 const bool is_debug = gdk_config ()[" log_level" ] == " debug" ;
495- const auto & executor = m_io.get_io_context (). get_executor ();
496+ const auto & executor = m_io.get_executor ();
496497
497498 // The last failure number that we handled
498499 auto last_handled_failure_count = m_failure_count.load ();
@@ -580,7 +581,7 @@ namespace sdk {
580581 } else {
581582 t = std::make_shared<transport>(*m_client, m_server, proxy, is_debug);
582583 }
583- s = std::make_shared<autobahn::wamp_session>(m_io. get_io_context () , is_debug);
584+ s = std::make_shared<autobahn::wamp_session>(m_io, is_debug);
584585 t->attach (std::static_pointer_cast<autobahn::wamp_transport_handler>(s));
585586 bool failed = false ;
586587 if (no_std_exception_escape (
0 commit comments