diff --git a/src/core/cdrom_async_reader.cpp b/src/core/cdrom_async_reader.cpp index fa8c3cf6d..62efa8154 100644 --- a/src/core/cdrom_async_reader.cpp +++ b/src/core/cdrom_async_reader.cpp @@ -24,7 +24,7 @@ void CDROMAsyncReader::StartThread(u32 readahead_count) EmptyBuffers(); m_shutdown_flag.store(false); - m_read_thread = std::thread(&CDROMAsyncReader::WorkerThreadEntryPoint, this); + m_read_thread.Start([this]() { WorkerThreadEntryPoint(); }); INFO_LOG("Read thread started with readahead of {} sectors", readahead_count); } @@ -39,7 +39,7 @@ void CDROMAsyncReader::StopThread() m_do_read_cv.notify_one(); } - m_read_thread.join(); + m_read_thread.Join(); EmptyBuffers(); m_buffers.clear(); } @@ -224,7 +224,7 @@ void CDROMAsyncReader::EmptyBuffers() m_buffer_count.store(0); } -bool CDROMAsyncReader::ReadSectorIntoBuffer(std::unique_lock& lock) +bool CDROMAsyncReader::ReadSectorIntoBuffer(std::unique_lock& lock) { Timer timer; diff --git a/src/core/cdrom_async_reader.h b/src/core/cdrom_async_reader.h index b3d297cf5..54863a7e0 100644 --- a/src/core/cdrom_async_reader.h +++ b/src/core/cdrom_async_reader.h @@ -2,12 +2,16 @@ // SPDX-License-Identifier: CC-BY-NC-ND-4.0 #pragma once -#include "util/cd_image.h" + #include "types.h" + +#include "util/cd_image.h" + +#include "common/threading.h" + #include #include -#include -#include +#include class ProgressCallback; @@ -39,7 +43,7 @@ public: CDImage* GetMedia() { return m_media.get(); } const std::string& GetMediaPath() const { return m_media->GetPath(); } - bool IsUsingThread() const { return m_read_thread.joinable(); } + bool IsUsingThread() const { return m_read_thread.Joinable(); } void StartThread(u32 readahead_count = 8); void StopThread(); @@ -59,7 +63,7 @@ public: private: void EmptyBuffers(); - bool ReadSectorIntoBuffer(std::unique_lock& lock); + bool ReadSectorIntoBuffer(std::unique_lock& lock); void ReadSectorNonThreaded(CDImage::LBA lba); bool InternalReadSectorUncached(CDImage::LBA lba, CDImage::SubChannelQ* subq, SectorBuffer* data); void CancelReadahead(); @@ -68,10 +72,10 @@ private: std::unique_ptr m_media; - std::mutex m_mutex; - std::thread m_read_thread; - std::condition_variable m_do_read_cv; - std::condition_variable m_notify_read_complete_cv; + Threading::Mutex m_mutex; + Threading::Thread m_read_thread; + Threading::ConditionVariable m_do_read_cv; + Threading::ConditionVariable m_notify_read_complete_cv; std::atomic m_next_position{}; std::atomic_bool m_next_position_set{false};