From 096424b60b9f727f030baef8e5a423446725fb6b Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 29 Apr 2025 04:24:48 +0000 Subject: [PATCH] refactor: Use WebsocketClient fn run_in_background in binance gws --- .../binance_execution/spots/spots_gateway.cpp | 9 +-------- .../usds_futures/usds_futures_gateway.cpp | 7 +------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/lib_binance_execution/binance_execution/spots/spots_gateway.cpp b/src/lib_binance_execution/binance_execution/spots/spots_gateway.cpp index 5155286f3..ba87fc4cd 100644 --- a/src/lib_binance_execution/binance_execution/spots/spots_gateway.cpp +++ b/src/lib_binance_execution/binance_execution/spots/spots_gateway.cpp @@ -135,7 +135,6 @@ struct SpotsGateway::PImpl { GatewayConfig config; std::shared_ptr jetfix_connection; optional ws_client; - optional ws_run_thread; unordered_map> response_handlers; unordered_map inflight_orders; @@ -193,7 +192,6 @@ struct SpotsGateway::PImpl { void start() { INFO_FN("start"); - bts_assert(!ws_run_thread); LOG(OrderMan, bts::Info, "Creating websocket client. url: {}", config.ws_endpoint); // Init websocket @@ -207,12 +205,7 @@ struct SpotsGateway::PImpl { ws_cli.close_handler().bind<&PImpl::on_close>(*this); INFO_FN("start", "Creating websocket client. url: {}", url); ws_cli.connect(); - ws_run_thread.emplace([&]() { - bts::threading::configure_current_thread("binance_spots_gw_ws"); - DIAG_FN("binance_spots_exe_ws", "Begin. url: {}", url); - ws_cli.run(); - DIAG_FN("binance_spots_exe_ws", "End. url: {}", url); - }); + ws_cli.run_in_background(); } void logon() { diff --git a/src/lib_binance_execution/binance_execution/usds_futures/usds_futures_gateway.cpp b/src/lib_binance_execution/binance_execution/usds_futures/usds_futures_gateway.cpp index 63df5e554..5406c62e9 100644 --- a/src/lib_binance_execution/binance_execution/usds_futures/usds_futures_gateway.cpp +++ b/src/lib_binance_execution/binance_execution/usds_futures/usds_futures_gateway.cpp @@ -182,12 +182,7 @@ struct UsdsFuturesGateway::PImpl { ws_cli.close_handler().bind<&PImpl::on_close>(*this); INFO_FN("start", "Creating websocket client. url: {}", url); ws_cli.connect(); - ws_run_thread.emplace([&]() { - configure_current_thread("binance_ufuts_gw_ws"); - DIAG_FN("binance_ufuts_exe_ws", "Begin. url: {}", url); - ws_cli.run(); - DIAG_FN("binance_ufuts_exe_ws", "End. url: {}", url); - }); + ws_cli.run_in_background(); } void on_open(const std::error_code &ec) {