diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-07-09 03:46:06 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-07-09 03:46:06 +0200 |
| commit | c2e74a93804f0ba4e7e87a95e8881bbe817aa0a4 (patch) | |
| tree | 43e99e5f3f385c3301cbe77e0919ec50f52a00d8 /src/common/detached_tasks.cpp | |
| parent | e401414aabb37c903b4f02018d5a7fba3d767321 (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/common/detached_tasks.cpp')
| -rw-r--r-- | src/common/detached_tasks.cpp | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/src/common/detached_tasks.cpp b/src/common/detached_tasks.cpp deleted file mode 100644 index f2ed795cc2..0000000000 --- a/src/common/detached_tasks.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-FileCopyrightText: 2018 Citra Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include <thread> -#include "common/assert.h" -#include "common/detached_tasks.h" - -namespace Common { - -DetachedTasks* DetachedTasks::instance = nullptr; - -DetachedTasks::DetachedTasks() { - ASSERT(instance == nullptr); - instance = this; -} - -void DetachedTasks::WaitForAllTasks() { - std::unique_lock lock{mutex}; - cv.wait(lock, [this]() { return count == 0; }); -} - -DetachedTasks::~DetachedTasks() { - WaitForAllTasks(); - - std::unique_lock lock{mutex}; - ASSERT(count == 0); - instance = nullptr; -} - -void DetachedTasks::AddTask(std::function<void()> task) { - std::unique_lock lock{instance->mutex}; - ++instance->count; - std::thread([task_{std::move(task)}]() { - task_(); - std::unique_lock thread_lock{instance->mutex}; - --instance->count; - std::notify_all_at_thread_exit(instance->cv, std::move(thread_lock)); - }).detach(); -} - -} // namespace Common |
