summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2026-10-18 12:25:46 +0200
committerGitHub <noreply@github.com>2026-10-18 12:25:46 +0200
commit8c19346fa956c37264751868a8ac4d674bfff6de (patch)
treecd48986a05abe5c2e2c63bff71762940ec4eb6e0 /Source
parentb869a2ab2035f0ff0c0ca71becb4e33131ebb1b7 (diff)
parent1acbcaceffdf11d5b6d90fe2c864a8683b930908 (diff)
Merge pull request #14621 from jordan-woyak/cached-blob-jthread
DiscIO/CachedBlob: Minor cleanup by replacing std::thread with std::jthread.
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt13
-rw-r--r--Source/Core/DiscIO/CachedBlob.cpp11
2 files changed, 15 insertions, 9 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 140abb02d7..cdfabd36c8 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -19,6 +19,19 @@ if (NOT MSVC)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
+
+ # std::jthread is guarded behind -fexperimental-library prior to libc++ version 20
+ check_cxx_source_compiles([[
+ #include <version>
+ #if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 200000
+ #error libc++ version < 20
+ #endif
+ int main() {}
+ ]] IS_JTHREAD_STABLE)
+
+ if(NOT IS_JTHREAD_STABLE)
+ add_compile_options(-fexperimental-library)
+ endif()
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
diff --git a/Source/Core/DiscIO/CachedBlob.cpp b/Source/Core/DiscIO/CachedBlob.cpp
index f1bbf055ee..f59e09a095 100644
--- a/Source/Core/DiscIO/CachedBlob.cpp
+++ b/Source/Core/DiscIO/CachedBlob.cpp
@@ -24,12 +24,6 @@ public:
{
}
- ~CacheFiller()
- {
- m_stop_thread.store(true, std::memory_order_relaxed);
- m_thread.join();
- }
-
bool Read(u64 offset, u64 size, u8* out_ptr)
{
if (size == 0)
@@ -126,7 +120,7 @@ private:
while (true)
{
- if (m_stop_thread.load(std::memory_order_relaxed))
+ if (m_thread.get_stop_token().stop_requested())
{
INFO_LOG_FMT(DISCIO, "CachedBlobReader: Stopped");
break;
@@ -178,8 +172,7 @@ private:
DiscScrubber m_scrubber;
- std::atomic_bool m_stop_thread{};
- std::thread m_thread;
+ std::jthread m_thread;
};
class CachedBlobReader final : public BlobReader