Compare commits

...

6 commits

Author SHA1 Message Date
77c2e2bb20 [cmake] fix android once for all
All checks were successful
eden-license / license-header (pull_request) Successful in 16s
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2025-09-19 18:24:01 +02:00
74d76e8f91 [cmake] fix android?
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2025-09-19 18:24:01 +02:00
aac548a7b7 [common] use libc++ provided jthread instead of in-house one (which deadlocks on FBSD 14)
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2025-09-19 18:24:01 +02:00
6510818fca
[docs] fixup codeowners (#2529)
Reviewed-on: #2529
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev>
2025-09-19 18:20:51 +02:00
a487cea683
[core] Fix buiding with fmt 10 (#2524)
Signed-off-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Reviewed-on: #2524
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Co-committed-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
2025-09-19 17:02:53 +02:00
a3c0d59dc9
[android] update translations for dynarmic to say it's jit, remove "(slow)" from paranoid (#2527)
Signed-off-by: lizzie <lizzie@eden-emu.dev>
Reviewed-on: #2527
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
2025-09-19 16:57:34 +02:00
33 changed files with 108 additions and 407 deletions

View file

@ -316,6 +316,18 @@ if (YUZU_ROOM)
add_compile_definitions(YUZU_ROOM)
endif()
if (ANDROID OR PLATFORM_FREEBSD OR PLATFORM_OPENBSD OR PLATFORM_SUN)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# libc++ has stop_token and jthread as experimental
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexperimental-library")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexperimental-library")
else()
# Uses glibc, mostly?
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_ENABLE_EXPERIMENTAL=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LIBCPP_ENABLE_EXPERIMENTAL=1")
endif()
endif()
# Build/optimization presets
if (PLATFORM_LINUX OR CXX_CLANG)
if (ARCHITECTURE_x86_64)

View file

@ -10,17 +10,18 @@
/.ci @crueter
# cmake
*.cmake @crueter
*/CMakeLists.txt @crueter
*.in @crueter
*.cmake @crueter
*CMakeLists.txt @crueter
*.in @crueter
# individual stuff
/src/web_service @AleksandrPopovich
/src/dynarmic @Lizzie
/src/core @Lizzie @Maufeat @PavelBARABANOV @MrPurple666
/src/core/hle @Maufeat @PavelBARABANOV @SDK-Chan
/src/*_room @AleksandrPopovich
/src/video_core @CamilleLaVey @MaranBr @Wildcard @weakboson
src/web_service @AleksandrPopovich
src/dynarmic @Lizzie
src/core @Lizzie @Maufeat @PavelBARABANOV @MrPurple666 @JPikachu
src/core/hle @Maufeat @PavelBARABANOV @SDK-Chan
src/core/arm @Lizzie @MrPurple666
src/*_room @AleksandrPopovich
src/video_core @CamilleLaVey @MaranBr @Wildcard @weakboson
# Global owners/triage
* @CamilleLaVey @Maufeat @crueter @MrPurple666 @MaranBr @Lizzie

View file

@ -836,13 +836,13 @@
<string name="ratio_stretch">تمتد إلى النافذة</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">Dynarmic (بطيء)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">تنفيذ التعليمات البرمجية الأصلية (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">دقه</string>
<string name="cpu_accuracy_unsafe">غير آمن</string>
<string name="cpu_accuracy_paranoid">Paranoid (بطيء)</string>
<string name="cpu_accuracy_paranoid">Paranoid</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">الأسهم</string>

View file

@ -919,13 +919,13 @@
<string name="ratio_stretch">Ajustar a la ventana</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">DynARMic (lento)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">Ejecución nativa de código (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">Preciso</string>
<string name="cpu_accuracy_unsafe">Impreciso</string>
<string name="cpu_accuracy_paranoid">Paranoico (Lento)</string>
<string name="cpu_accuracy_paranoid">Paranoico</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">Cruceta</string>

View file

@ -918,13 +918,13 @@
<string name="ratio_stretch">کشش تا پر کردن پنجره</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">دینارمیک (کند)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">اجرای کد اصلی (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">دقیق</string>
<string name="cpu_accuracy_unsafe">ناامن</string>
<string name="cpu_accuracy_paranoid">بدگمان (کند)</string>
<string name="cpu_accuracy_paranoid">بدگمان</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">کلیدهای جهتی</string>

View file

@ -967,13 +967,13 @@
<string name="ratio_stretch">Étirer à la fenêtre</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">Dynarmic (Lent)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">Exécution de code natif (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">Précis</string>
<string name="cpu_accuracy_unsafe">Risqué</string>
<string name="cpu_accuracy_paranoid">Paranoïaque (Lent)</string>
<string name="cpu_accuracy_paranoid">Paranoïaque</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">Pavé directionnel</string>

View file

@ -844,13 +844,13 @@
<string name="ratio_stretch">הרחב לגודל המסך</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">דינמי (איטי)</string>
<string name="cpu_backend_dynarmic">דינמי</string>
<string name="cpu_backend_nce">ביצוע קוד מקורי (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">מדויק</string>
<string name="cpu_accuracy_unsafe">לא בטוח</string>
<string name="cpu_accuracy_paranoid">פראנואידי (איטי)</string>
<string name="cpu_accuracy_paranoid">פראנואידי</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">D-pad</string>

View file

@ -954,13 +954,13 @@
<string name="ratio_stretch">Ablakhoz nyújtás</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">Dinamikus (lassú)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">Natív kód végrehajtás (Native code execution (NCE))</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">Pontos</string>
<string name="cpu_accuracy_unsafe">Nem biztonságos</string>
<string name="cpu_accuracy_paranoid">Paranoid (Lassú)</string>
<string name="cpu_accuracy_paranoid">Paranoid</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">D-pad</string>

View file

@ -911,13 +911,13 @@
<string name="ratio_stretch">Merentangkan</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">Dynamic (Lambat)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">Native code execution (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">Akurat</string>
<string name="cpu_accuracy_unsafe">Berbahaya</string>
<string name="cpu_accuracy_paranoid">Paranoid (Slow)</string>
<string name="cpu_accuracy_paranoid">Paranoid</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">D Pad</string>

View file

@ -834,13 +834,13 @@
<string name="ratio_stretch">画面に合わせる</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">Dynarmic (低速)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">ネイティブコード実行 (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">正確</string>
<string name="cpu_accuracy_unsafe">不安定</string>
<string name="cpu_accuracy_paranoid">パラノイド (低速)</string>
<string name="cpu_accuracy_paranoid">パラノイド</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">方向ボタン</string>

View file

@ -910,13 +910,13 @@
<string name="ratio_stretch">화면에 맞춤</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">Dynarmic (느림)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">네이티브 코드 실행 (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">정확함</string>
<string name="cpu_accuracy_unsafe">최적화 (안전하지 않음)</string>
<string name="cpu_accuracy_paranoid">최적화하지 않음 (느림)</string>
<string name="cpu_accuracy_paranoid">최적화하지 않음</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">십자키</string>

View file

@ -968,13 +968,13 @@ uma tentativa de mapeamento automático</string>
<string name="ratio_stretch">Esticar à janela</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">Dynarmic (Lenta)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">Execução de código nativo (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">Precisa</string>
<string name="cpu_accuracy_unsafe">Não segura</string>
<string name="cpu_accuracy_paranoid">Paranoica (Lenta)</string>
<string name="cpu_accuracy_paranoid">Paranoica</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">Botões Direcionais</string>

View file

@ -968,13 +968,13 @@ uma tentativa de mapeamento automático</string>
<string name="ratio_stretch">Esticar à janela</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">Dynarmic (Lento)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">Native code execution (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">Preciso</string>
<string name="cpu_accuracy_unsafe">Inseguro</string>
<string name="cpu_accuracy_paranoid">Paranoid (Lento)</string>
<string name="cpu_accuracy_paranoid">Paranoid</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">Botões Direcionais</string>

View file

@ -969,13 +969,13 @@
<string name="ratio_stretch">Растянуть до окна</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">Dynarmic (Медленно)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">Нативное выполнение (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">Точно</string>
<string name="cpu_accuracy_unsafe">Небезопасно</string>
<string name="cpu_accuracy_paranoid">Параноик (медленно)</string>
<string name="cpu_accuracy_paranoid">Параноик</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">Крестовина</string>

View file

@ -988,13 +988,13 @@
<string name="ratio_stretch">Протезање до прозора</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">Динамина (споро)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">Извођење изворног кода (НЦЕ)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">Тачан</string>
<string name="cpu_accuracy_unsafe">Несигуран</string>
<string name="cpu_accuracy_paranoid">Параноичан (споро)</string>
<string name="cpu_accuracy_paranoid">Параноичан</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">Д-пад</string>

View file

@ -961,13 +961,13 @@
<string name="ratio_stretch">拉伸窗口</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">动态编译 (慢速)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">本机代码执行 (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">高精度</string>
<string name="cpu_accuracy_unsafe">低精度</string>
<string name="cpu_accuracy_paranoid">偏执模式 (慢速)</string>
<string name="cpu_accuracy_paranoid">偏执模式</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">十字方向键</string>

View file

@ -966,13 +966,13 @@
<string name="ratio_stretch">延展視窗</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">動態 (慢)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">機器碼執行 (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">高精度</string>
<string name="cpu_accuracy_unsafe">低精度</string>
<string name="cpu_accuracy_paranoid">不合理 (慢)</string>
<string name="cpu_accuracy_paranoid">不合理</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">方向鍵</string>

View file

@ -1014,13 +1014,13 @@
<string name="ratio_stretch">Stretch to window</string>
<!-- CPU Backend -->
<string name="cpu_backend_dynarmic">Dynarmic (Slow)</string>
<string name="cpu_backend_dynarmic">Dynarmic (JIT)</string>
<string name="cpu_backend_nce">Native code execution (NCE)</string>
<!-- CPU Accuracy -->
<string name="cpu_accuracy_accurate">Accurate</string>
<string name="cpu_accuracy_unsafe">Unsafe</string>
<string name="cpu_accuracy_paranoid">Paranoid (Slow)</string>
<string name="cpu_accuracy_paranoid">Paranoid</string>
<!-- Gamepad Buttons -->
<string name="gamepad_d_pad">D-pad</string>

View file

@ -293,8 +293,7 @@ void SinkStream::WaitFreeSpace(std::stop_token stop_token) {
release_cv.wait_for(lk, std::chrono::milliseconds(5),
[this]() { return paused || queued_buffers < max_queue_size; });
if (queued_buffers > max_queue_size + 3) {
Common::CondvarWait(release_cv, lk, stop_token,
[this] { return paused || queued_buffers < max_queue_size; });
release_cv.wait(lk, stop_token, [this] { return paused || queued_buffers < max_queue_size; });
}
}

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -123,7 +126,7 @@ private:
} else if constexpr (Mode == PopMode::WaitWithStopToken) {
// Wait until the queue is not empty.
std::unique_lock lock{consumer_cv_mutex};
Common::CondvarWait(consumer_cv, lock, stop_token, [this, read_index] {
consumer_cv.wait(lock, stop_token, [this, read_index] {
return read_index != m_write_index.load(std::memory_order::acquire);
});
if (stop_token.stop_requested()) {

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -7,23 +10,13 @@
#pragma once
#include <version>
#ifdef __cpp_lib_jthread
#include <chrono>
#include <condition_variable>
#include <stop_token>
#include <thread>
#include <utility>
namespace Common {
template <typename Condvar, typename Lock, typename Pred>
void CondvarWait(Condvar& cv, std::unique_lock<Lock>& lk, std::stop_token token, Pred&& pred) {
cv.wait(lk, token, std::forward<Pred>(pred));
}
template <typename Rep, typename Period>
bool StoppableTimedWait(std::stop_token token, const std::chrono::duration<Rep, Period>& rel_time) {
std::condition_variable_any cv;
@ -35,341 +28,3 @@ bool StoppableTimedWait(std::stop_token token, const std::chrono::duration<Rep,
}
} // namespace Common
#else
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <functional>
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <thread>
#include <type_traits>
#include <utility>
namespace std {
namespace polyfill {
using stop_state_callback = size_t;
class stop_state {
public:
stop_state() = default;
~stop_state() = default;
bool request_stop() {
unique_lock lk{m_lock};
if (m_stop_requested) {
// Already set, nothing to do.
return false;
}
// Mark stop requested.
m_stop_requested = true;
while (!m_callbacks.empty()) {
// Get an iterator to the first element.
const auto it = m_callbacks.begin();
// Move the callback function out of the map.
function<void()> f;
swap(it->second, f);
// Erase the now-empty map element.
m_callbacks.erase(it);
// Run the callback.
if (f) {
f();
}
}
return true;
}
bool stop_requested() const {
unique_lock lk{m_lock};
return m_stop_requested;
}
stop_state_callback insert_callback(function<void()> f) {
unique_lock lk{m_lock};
if (m_stop_requested) {
// Stop already requested. Don't insert anything,
// just run the callback synchronously.
if (f) {
f();
}
return 0;
}
// Insert the callback.
stop_state_callback ret = ++m_next_callback;
m_callbacks.emplace(ret, std::move(f));
return ret;
}
void remove_callback(stop_state_callback cb) {
unique_lock lk{m_lock};
m_callbacks.erase(cb);
}
private:
mutable recursive_mutex m_lock;
map<stop_state_callback, function<void()>> m_callbacks;
stop_state_callback m_next_callback{0};
bool m_stop_requested{false};
};
} // namespace polyfill
class stop_token;
class stop_source;
struct nostopstate_t {
explicit nostopstate_t() = default;
};
inline constexpr nostopstate_t nostopstate{};
template <class Callback>
class stop_callback;
class stop_token {
public:
stop_token() noexcept = default;
stop_token(const stop_token&) noexcept = default;
stop_token(stop_token&&) noexcept = default;
stop_token& operator=(const stop_token&) noexcept = default;
stop_token& operator=(stop_token&&) noexcept = default;
~stop_token() = default;
void swap(stop_token& other) noexcept {
m_stop_state.swap(other.m_stop_state);
}
[[nodiscard]] bool stop_requested() const noexcept {
return m_stop_state && m_stop_state->stop_requested();
}
[[nodiscard]] bool stop_possible() const noexcept {
return m_stop_state != nullptr;
}
private:
friend class stop_source;
template <typename Callback>
friend class stop_callback;
stop_token(shared_ptr<polyfill::stop_state> stop_state) : m_stop_state(std::move(stop_state)) {}
private:
shared_ptr<polyfill::stop_state> m_stop_state;
};
class stop_source {
public:
stop_source() : m_stop_state(make_shared<polyfill::stop_state>()) {}
explicit stop_source(nostopstate_t) noexcept {}
stop_source(const stop_source&) noexcept = default;
stop_source(stop_source&&) noexcept = default;
stop_source& operator=(const stop_source&) noexcept = default;
stop_source& operator=(stop_source&&) noexcept = default;
~stop_source() = default;
void swap(stop_source& other) noexcept {
m_stop_state.swap(other.m_stop_state);
}
[[nodiscard]] stop_token get_token() const noexcept {
return stop_token(m_stop_state);
}
[[nodiscard]] bool stop_possible() const noexcept {
return m_stop_state != nullptr;
}
[[nodiscard]] bool stop_requested() const noexcept {
return m_stop_state && m_stop_state->stop_requested();
}
bool request_stop() noexcept {
return m_stop_state && m_stop_state->request_stop();
}
private:
friend class jthread;
explicit stop_source(shared_ptr<polyfill::stop_state> stop_state)
: m_stop_state(std::move(stop_state)) {}
private:
shared_ptr<polyfill::stop_state> m_stop_state;
};
template <typename Callback>
class stop_callback {
static_assert(is_nothrow_destructible_v<Callback>);
static_assert(is_invocable_v<Callback>);
public:
using callback_type = Callback;
template <typename C>
requires constructible_from<Callback, C>
explicit stop_callback(const stop_token& st,
C&& cb) noexcept(is_nothrow_constructible_v<Callback, C>)
: m_stop_state(st.m_stop_state) {
if (m_stop_state) {
m_callback = m_stop_state->insert_callback(std::move(cb));
}
}
template <typename C>
requires constructible_from<Callback, C>
explicit stop_callback(stop_token&& st,
C&& cb) noexcept(is_nothrow_constructible_v<Callback, C>)
: m_stop_state(std::move(st.m_stop_state)) {
if (m_stop_state) {
m_callback = m_stop_state->insert_callback(std::move(cb));
}
}
~stop_callback() {
if (m_stop_state && m_callback) {
m_stop_state->remove_callback(m_callback);
}
}
stop_callback(const stop_callback&) = delete;
stop_callback(stop_callback&&) = delete;
stop_callback& operator=(const stop_callback&) = delete;
stop_callback& operator=(stop_callback&&) = delete;
private:
shared_ptr<polyfill::stop_state> m_stop_state;
polyfill::stop_state_callback m_callback;
};
template <typename Callback>
stop_callback(stop_token, Callback) -> stop_callback<Callback>;
class jthread {
public:
using id = thread::id;
using native_handle_type = thread::native_handle_type;
jthread() noexcept = default;
template <typename F, typename... Args,
typename = enable_if_t<!is_same_v<remove_cvref_t<F>, jthread>>>
explicit jthread(F&& f, Args&&... args)
: m_stop_state(make_shared<polyfill::stop_state>()),
m_thread(make_thread(std::forward<F>(f), std::forward<Args>(args)...)) {}
~jthread() {
if (joinable()) {
request_stop();
join();
}
}
jthread(const jthread&) = delete;
jthread(jthread&&) noexcept = default;
jthread& operator=(const jthread&) = delete;
jthread& operator=(jthread&& other) noexcept {
m_thread.swap(other.m_thread);
m_stop_state.swap(other.m_stop_state);
return *this;
}
void swap(jthread& other) noexcept {
m_thread.swap(other.m_thread);
m_stop_state.swap(other.m_stop_state);
}
[[nodiscard]] bool joinable() const noexcept {
return m_thread.joinable();
}
void join() {
m_thread.join();
}
void detach() {
m_thread.detach();
m_stop_state.reset();
}
[[nodiscard]] id get_id() const noexcept {
return m_thread.get_id();
}
[[nodiscard]] native_handle_type native_handle() {
return m_thread.native_handle();
}
[[nodiscard]] stop_source get_stop_source() noexcept {
return stop_source(m_stop_state);
}
[[nodiscard]] stop_token get_stop_token() const noexcept {
return stop_source(m_stop_state).get_token();
}
bool request_stop() noexcept {
return get_stop_source().request_stop();
}
[[nodiscard]] static unsigned int hardware_concurrency() noexcept {
return thread::hardware_concurrency();
}
private:
template <typename F, typename... Args>
thread make_thread(F&& f, Args&&... args) {
if constexpr (is_invocable_v<decay_t<F>, stop_token, decay_t<Args>...>) {
return thread(std::forward<F>(f), get_stop_token(), std::forward<Args>(args)...);
} else {
return thread(std::forward<F>(f), std::forward<Args>(args)...);
}
}
shared_ptr<polyfill::stop_state> m_stop_state;
thread m_thread;
};
} // namespace std
namespace Common {
template <typename Condvar, typename Lock, typename Pred>
void CondvarWait(Condvar& cv, std::unique_lock<Lock>& lk, std::stop_token token, Pred pred) {
if (token.stop_requested()) {
return;
}
std::stop_callback callback(token, [&] {
{ std::scoped_lock lk2{*lk.mutex()}; }
cv.notify_all();
});
cv.wait(lk, [&] { return pred() || token.stop_requested(); });
}
template <typename Rep, typename Period>
bool StoppableTimedWait(std::stop_token token, const std::chrono::duration<Rep, Period>& rel_time) {
if (token.stop_requested()) {
return false;
}
bool stop_requested = false;
std::condition_variable cv;
std::mutex m;
std::stop_callback cb(token, [&] {
// Wake up the waiting thread.
{
std::scoped_lock lk{m};
stop_requested = true;
}
cv.notify_one();
});
// Perform the timed wait.
std::unique_lock lk{m};
return !cv.wait_for(lk, rel_time, [&] { return stop_requested; });
}
} // namespace Common
#endif

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2013 Dolphin Emulator Project
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -80,7 +83,7 @@ public:
condvar.notify_all();
return true;
} else {
CondvarWait(condvar, lk, token,
condvar.wait(lk, token,
[this, current_generation] { return current_generation != generation; });
return !token.stop_requested();
}

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -47,8 +50,8 @@ public:
if (requests.empty()) {
wait_condition.notify_all();
}
Common::CondvarWait(condition, lock, stop_token,
[this] { return !requests.empty(); });
condition.wait(lock, stop_token,
[this] { return !requests.empty(); });
if (stop_token.stop_requested()) {
break;
}

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2010 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -99,7 +102,11 @@ public:
T PopWait(std::stop_token stop_token) {
if (Empty()) {
std::unique_lock lock{cv_mutex};
Common::CondvarWait(cv, lock, stop_token, [this] { return !Empty(); });
if constexpr (with_stop_token) {
cv.wait(lock, stop_token, [this] { return !Empty(); });
} else {
cv.wait(lock, [this] { return !Empty(); });
}
}
if (stop_token.stop_requested()) {
return T{};

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2017 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -41,7 +44,14 @@ PerfStats::~PerfStats() {
const auto path = Common::FS::GetEdenPath(Common::FS::EdenPath::LogDir);
// %F Date format expanded is "%Y-%m-%d"
const auto filename = fmt::format("{:%F-%H-%M}_{:016X}.csv", *std::localtime(&t), title_id);
const auto filename = fmt::format("{}_{:016X}.csv",
[&] {
std::ostringstream oss;
oss << std::put_time(std::localtime(&t), "%F-%H-%M");
return oss.str();
}(),
title_id);
const auto filepath = path / filename;
if (Common::FS::CreateParentDir(filepath)) {

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -33,7 +36,9 @@ std::filesystem::path GetPath(std::string_view type, u64 title_id, std::string_v
std::string GetTimestamp() {
const auto time = std::time(nullptr);
return fmt::format("{:%FT%H-%M-%S}", *std::localtime(&time));
std::ostringstream oss;
oss << std::put_time(std::localtime(&time), "%FT%H-%M-%S");
return oss.str();
}
using namespace nlohmann;

View file

@ -39,8 +39,8 @@ void CDmaPusher::ProcessEntries(std::stop_token stop_token) {
while (!stop_token.stop_requested()) {
{
std::unique_lock l{command_mutex};
Common::CondvarWait(command_cv, l, stop_token,
[this]() { return command_lists.size() > 0; });
command_cv.wait(l, stop_token,
[this]() { return command_lists.size() > 0; });
if (stop_token.stop_requested()) {
return;
}

View file

@ -116,7 +116,7 @@ u64 ThreadManager::PushCommand(CommandData&& command_data, bool block) {
state.queue.EmplaceWait(std::move(command_data), fence, block);
if (block) {
Common::CondvarWait(state.cv, lk, thread.get_stop_token(), [this, fence] {
state.cv.wait(lk, thread.get_stop_token(), [this, fence] {
return fence <= state.signaled_fence.load(std::memory_order_relaxed);
});
}

View file

@ -208,7 +208,7 @@ void MasterSemaphore::WaitThread(std::stop_token token) {
vk::Fence fence;
{
std::unique_lock lock{wait_mutex};
Common::CondvarWait(wait_cv, lock, token, [this] { return !wait_queue.empty(); });
wait_cv.wait(lock, token, [this] { return !wait_queue.empty(); });
if (token.stop_requested()) {
return;
}

View file

@ -279,7 +279,7 @@ void PresentManager::PresentThread(std::stop_token token) {
std::unique_lock lock{queue_mutex};
// Wait for presentation frames
Common::CondvarWait(frame_cv, lock, token, [this] { return !present_queue.empty(); });
frame_cv.wait(lock, token, [this] { return !present_queue.empty(); });
if (token.stop_requested()) {
return;
}

View file

@ -166,7 +166,7 @@ void Scheduler::WorkerThread(std::stop_token stop_token) {
std::unique_lock lk{queue_mutex};
// Wait for work.
Common::CondvarWait(event_cv, lk, stop_token, [&] { return TryPopQueue(work); });
event_cv.wait(lk, stop_token, [&] { return TryPopQueue(work); });
// If we've been asked to stop, we're done.
if (stop_token.stop_requested()) {

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -224,7 +227,7 @@ void TurboMode::Run(std::stop_token stop_token) {
#endif
// Wait for the next graphics queue submission if necessary.
std::unique_lock lk{m_submission_lock};
Common::CondvarWait(m_submission_cv, lk, stop_token, [this] {
m_submission_cv.wait(lk, stop_token, [this] {
return (std::chrono::steady_clock::now() - m_submission_time) <=
std::chrono::milliseconds{100};
});

View file

@ -108,13 +108,13 @@ void EmuThread::run() {
m_system.Run();
m_stopped.Reset();
Common::CondvarWait(m_should_run_cv, lk, stop_token, [&] { return !m_should_run; });
m_should_run_cv.wait(lk, stop_token, [&] { return !m_should_run; });
} else {
m_system.Pause();
m_stopped.Set();
EmulationPaused(lk);
Common::CondvarWait(m_should_run_cv, lk, stop_token, [&] { return m_should_run; });
m_should_run_cv.wait(lk, stop_token, [&] { return m_should_run; });
EmulationResumed(lk);
}
}