aboutsummaryrefslogtreecommitdiff
path: root/src/web_service
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2026-07-09 03:46:06 +0200
committercrueter <crueter@eden-emu.dev>2026-07-09 03:46:06 +0200
commitc2e74a93804f0ba4e7e87a95e8881bbe817aa0a4 (patch)
tree43e99e5f3f385c3301cbe77e0919ec50f52a00d8 /src/web_service
parente401414aabb37c903b4f02018d5a7fba3d767321 (diff)
[common] remove DetachedTasks object usage (#4096)
this was only ever used for announce room json on one single instance this object is pretty much a danger to society and shouldnt exist, especially since its: a) a singleton b) spawns objects out of thin air c) doesn't respect RAII and can outlive its parent objects (big no no) generally we shouldnt endorse objects like these in the future, but alas, it existed, now it has to begone additionally there is a similar object in KWorkerTaskManager but it's not as egregious as this one. check that this didnt break the usual announce room json logic Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4096 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Diffstat (limited to 'src/web_service')
-rw-r--r--src/web_service/announce_room_json.cpp14
-rw-r--r--src/web_service/announce_room_json.h6
2 files changed, 13 insertions, 7 deletions
diff --git a/src/web_service/announce_room_json.cpp b/src/web_service/announce_room_json.cpp
index b80caa49dc..c3a44257ef 100644
--- a/src/web_service/announce_room_json.cpp
+++ b/src/web_service/announce_room_json.cpp
@@ -6,7 +6,6 @@
#include <future>
#include <nlohmann/json.hpp>
-#include "common/detached_tasks.h"
#include "common/logging.h"
#include "web_service/announce_room_json.h"
#include "web_service/web_backend.h"
@@ -136,13 +135,14 @@ AnnounceMultiplayerRoom::RoomList RoomJson::GetRoomList() {
void RoomJson::Delete() {
if (room_id.empty()) {
LOG_ERROR(WebService, "Room must be registered to be deleted");
- return;
+ } else {
+ // This jthread won't be destroyed until after the dtor has been ran
+ // Once the thread finishes it will stay resident on the vector -- destroyed and freed by dtor()
+ // this is still valid while in dtor, so... yeah
+ detached_tasks.emplace_back([this](std::stop_token stop_token) {
+ client.DeleteJson(fmt::format("/lobby/{}", room_id), "", false);
+ });
}
- Common::DetachedTasks::AddTask([host_{this->host}, username_{this->username},
- token_{this->token}, room_id_{this->room_id}]() {
- // create a new client here because the this->client might be destroyed.
- Client{host_, username_, token_}.DeleteJson(fmt::format("/lobby/{}", room_id_), "", false);
- });
}
} // namespace WebService
diff --git a/src/web_service/announce_room_json.h b/src/web_service/announce_room_json.h
index 32c08858dd..a991325349 100644
--- a/src/web_service/announce_room_json.h
+++ b/src/web_service/announce_room_json.h
@@ -1,8 +1,13 @@
+// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
+#include <thread>
+#include <vector>
#include <functional>
#include <string>
#include "common/announce_multiplayer_room.h"
@@ -30,6 +35,7 @@ public:
void Delete() override;
private:
+ std::vector<std::jthread> detached_tasks;
AnnounceMultiplayerRoom::Room room;
Client client;
std::string host;