Skip to content

Commit

Permalink
fix(executor): io_context doesn't stop when exiting app
Browse files Browse the repository at this point in the history
  • Loading branch information
Mairon1206 committed Aug 10, 2024
1 parent 40a150e commit 764b74c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/Controller/AsyncExecutor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public:
}

~AsyncExecutor() {
_ioc.stop();
if (_ioc_thread.joinable()) {
_ioc_thread.join();
}
Expand Down
14 changes: 7 additions & 7 deletions src/Infrastructure/Network/NetworkClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ NetworkClient::NetworkClient(net::ssl::context& ctx)
: _ctx(ctx)
, _manager(std::make_unique<HttpsAccessManager>(_ctx, true)) {}

NetworkClient* NetworkClient::getInstance() {
static ssl::context ctx(ssl::context::sslv23);
ctx.set_default_verify_paths();
static NetworkClient s_instance(ctx);
return &s_instance;
}

Task<Result<LoginResEntity>> NetworkClient::loginViaSastLink(const std::string& code) {
auto result = co_await this->request<api::Evento>(http::verb::post,
endpoint("/login/link"),
Expand All @@ -38,13 +45,6 @@ Task<Result<LoginResEntity>> NetworkClient::loginViaSastLink(const std::string&
co_return Ok(entity);
}

NetworkClient* NetworkClient::getInstance() {
static ssl::context ctx(ssl::context::sslv23);
ctx.set_default_verify_paths();
static NetworkClient s_instance(ctx);
return &s_instance;
}

Task<Result<UserInfoEntity>> NetworkClient::getUserInfo() {
auto result = co_await this->request<api::Evento>(http::verb::get, endpoint("/v2/user/profile"));
if (result.isErr())
Expand Down

0 comments on commit 764b74c

Please sign in to comment.