mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-16 16:00:30 +02:00
The libretro core is the frontend, and the headless tools are the test and debugging hosts. The Windows, UWP, Android, iOS, macOS and SDL apps, the UI framework and imgui go, along with what only they used: the Win32 debugger hooks (g_frameMutex, the shutdown lock), JNI thread attachment, the Android text drawer, RAIntegration, Discord, recent files, game installs, tilt input, the audio resamplers, the control mapper, memstick moving and the remote ISO and upload server modes. The web server keeps the debugger. The MSVC, Gradle and ndk-build projects go too.
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <mutex>
|
|
#include <atomic>
|
|
#include <utility>
|
|
|
|
// Note that the string pointed to must have a lifetime until the end of the thread,
|
|
// for AssertCurrentThreadName to work.
|
|
void SetCurrentThreadName(const char *threadName);
|
|
void AssertCurrentThreadName(const char *threadName);
|
|
|
|
// If TLS is not supported, this will return an empty string.
|
|
const char *GetCurrentThreadName();
|
|
|
|
// Just gets a cheap thread identifier so that you can see different threads in debug output,
|
|
// exactly what it is is badly specified and not useful for anything.
|
|
int GetCurrentThreadIdForDebug();
|
|
|
|
// Helper to detect if a type is std::atomic
|
|
template <typename T>
|
|
struct is_atomic : std::false_type {};
|
|
|
|
template <typename T>
|
|
struct is_atomic<std::atomic<T>> : std::true_type {};
|
|
|
|
template <typename T>
|
|
struct is_atomic<const std::atomic<T>> : std::true_type {};
|
|
|
|
template <typename T>
|
|
struct is_atomic<volatile std::atomic<T>> : std::true_type {};
|
|
|
|
template <typename T>
|
|
struct is_atomic<const volatile std::atomic<T>> : std::true_type {};
|
|
|
|
// Use on atomics to check if they're equal to one of multiple values.
|
|
template <typename T, typename... Ts>
|
|
bool equals_any(const T& first, const Ts... rest) {
|
|
// Make a single copy (or single load, if atomic)
|
|
using BaseType = std::remove_reference_t<T>;
|
|
if constexpr (is_atomic<BaseType>::value) {
|
|
auto value = first.load();
|
|
return ((value == rest) || ...);
|
|
} else {
|
|
return ((first == rest) || ...);
|
|
}
|
|
}
|